Merge branch 'master' into geppetto

This commit is contained in:
Ilmir Usmanov 2014-08-01 15:25:49 +04:00
commit 0ee1b9b54e
9 changed files with 222 additions and 31 deletions

View File

@ -0,0 +1,30 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var count = 10000000;
var x = 7;
var y = 3;
var tmp1;
var tmp2;
var tmp3;
var tmp4;
for (var i = 0; i < count; i++)
{
tmp1 = x * x;
tmp2 = y * y;
tmp3 = tmp1 * tmp1;
tmp4 = tmp2 * tmp2;
}

View File

@ -16,20 +16,115 @@
#include "globals.h"
static const char* generated_source = ""
"var count = 10000;\n"
"var x = 7;\n"
"var y = 3;\n"
"var tmp, a, b = 1, c = 2, d, e = 3, g = 4;\n"
"\n"
"var tmp1;\n"
"var tmp2;\n"
"var tmp3;\n"
"var tmp4;\n"
"var count = 1000;\n"
"\n"
"for (var i = 0; i < count; i++)\n"
"tmp = b * c;\n"
"a = tmp + g;\n"
"d = tmp * e + a;\n"
"\n"
"var waitTime = 600000;\n"
"var numOfIterations = 10;\n"
"\n"
"while (1)\n"
"{\n"
"tmp1 = x * x;\n"
"tmp2 = y * y;\n"
"tmp3 = tmp1 * tmp1;\n"
"tmp4 = tmp2 * tmp2;\n"
"for (var j = 0; j < numOfIterations; j += 1)\n"
"{\n"
"LEDOn(12);\n"
"LEDOn(13);\n"
"LEDOn(14);\n"
"LEDOn(15);\n"
"wait(waitTime * 2);\n"
"LEDOff(12);\n"
"LEDOff(13);\n"
"LEDOff(14);\n"
"LEDOff(15);\n"
"wait(waitTime * 2);\n"
"}\n"
"\n"
"for (var j = 0; j < numOfIterations; j += 1)\n"
"{\n"
"LEDOn(12);\n"
"wait(waitTime);\n"
"LEDOff(12);\n"
"wait(waitTime);\n"
"LEDOn(13);\n"
"wait(waitTime);\n"
"LEDOff(13);\n"
"wait(waitTime);\n"
"LEDOn(14);\n"
"wait(waitTime);\n"
"LEDOff(14);\n"
"wait(waitTime);\n"
"LEDOn(15);\n"
"wait(waitTime);\n"
"LEDOff(15);\n"
"wait(waitTime);\n"
"}\n"
"\n"
"for (var j = 0; j < numOfIterations; j += 1)\n"
"{\n"
"LEDOn(12);\n"
"wait(waitTime);\n"
"LEDOff(12);\n"
"LEDOn(13);\n"
"wait(waitTime);\n"
"LEDOff(13);\n"
"LEDOn(14);\n"
"wait(waitTime);\n"
"LEDOff(14);\n"
"LEDOn(15);\n"
"wait(waitTime);\n"
"LEDOff(15);\n"
"}\n"
"\n"
"for (var j = 0; j < numOfIterations; j += 1)\n"
"{\n"
"LEDOn(12);\n"
"wait(waitTime / 2);\n"
"LEDOff(12);\n"
"LEDOn(13);\n"
"wait(waitTime / 2);\n"
"LEDOff(13);\n"
"LEDOn(14);\n"
"wait(waitTime / 2);\n"
"LEDOff(14);\n"
"LEDOn(15);\n"
"wait(waitTime / 2);\n"
"LEDOff(15);\n"
"}\n"
"\n"
"for (var j = 0; j < numOfIterations; j += 1)\n"
"{\n"
"LEDOn(12);\n"
"wait(waitTime / 3);\n"
"LEDOff(12);\n"
"LEDOn(13);\n"
"wait(waitTime / 3);\n"
"LEDOff(13);\n"
"LEDOn(14);\n"
"wait(waitTime / 3);\n"
"LEDOff(14);\n"
"LEDOn(15);\n"
"wait(waitTime / 3);\n"
"LEDOff(15);\n"
"}\n"
"\n"
"for (var j = 0; j < numOfIterations; j += 1)\n"
"{\n"
"LEDOn(12);\n"
"wait(waitTime / 6);\n"
"LEDOff(12);\n"
"LEDOn(13);\n"
"wait(waitTime / 6);\n"
"LEDOff(13);\n"
"LEDOn(14);\n"
"wait(waitTime / 6);\n"
"LEDOff(14);\n"
"LEDOn(15);\n"
"wait(waitTime / 6);\n"
"LEDOff(15);\n"
"}\n"
"}\n"
;

View File

@ -18,8 +18,11 @@
*/
#include "ecma-exceptions.h"
#include "ecma-gc.h"
#include "ecma-global-object.h"
#include "ecma-helpers.h"
#include "ecma-lex-env.h"
#include "ecma-objects-properties.h"
#include "ecma-operations.h"
/** \addtogroup ecma ---TODO---
@ -135,13 +138,19 @@ ecma_op_put_value(ecma_reference_t ref, /**< ECMA-reference */
return ecma_make_throw_value( ecma_new_standard_error( ECMA_ERROR_REFERENCE));
} else // PutValue_3.b
{
/*
ecma_object_t *global_object_p = ecma_GetGlobalObject();
ecma_object_t *global_object_p = ecma_get_global_object();
return global_object_p->[[Put]]( ref.referenced_name_p, value, false);
*/
ecma_completion_value_t completion = ecma_op_object_put( global_object_p,
ref.referenced_name_p,
value,
false);
JERRY_UNIMPLEMENTED();
ecma_deref_object( global_object_p);
JERRY_ASSERT( ecma_is_completion_value_normal_true( completion)
|| ecma_is_completion_value_normal_false( completion) );
return ecma_make_empty_completion_value();
}
} else if ( is_property_reference ) // PutValue_4
{

View File

@ -14,6 +14,7 @@
*/
#include "globals.h"
#include "ecma-gc.h"
#include "ecma-globals.h"
#include "ecma-global-object.h"
#include "ecma-helpers.h"
@ -26,6 +27,27 @@
* @{
*/
/**
* Global object
*/
static ecma_object_t* ecma_global_object_p = NULL;
/**
* Get Global object
*
* @return pointer to the Global object
* caller should free the reference by calling ecma_deref_object
*/
ecma_object_t*
ecma_get_global_object( void)
{
JERRY_ASSERT( ecma_global_object_p != NULL );
ecma_ref_object( ecma_global_object_p);
return ecma_global_object_p;
} /* ecma_get_global_object */
/**
* The Global Object construction routine.
*
@ -36,6 +58,8 @@
ecma_object_t*
ecma_op_create_global_object( void)
{
JERRY_ASSERT( ecma_global_object_p == NULL );
ecma_object_t *glob_obj_p = ecma_create_object( NULL, true, ECMA_OBJECT_TYPE_GENERAL);
ecma_property_t *undefined_prop_p = ecma_create_named_data_property( glob_obj_p,
@ -47,6 +71,9 @@ ecma_op_create_global_object( void)
TODO( /* Define NaN, Infinity, eval, parseInt, parseFloat, isNaN, isFinite properties */ );
ecma_ref_object( glob_obj_p);
ecma_global_object_p = glob_obj_p;
return glob_obj_p;
} /* ecma_op_create_global_object */

View File

@ -25,6 +25,7 @@
* @{
*/
extern ecma_object_t* ecma_get_global_object(void);
extern ecma_object_t* ecma_op_create_global_object( void);
/**

View File

@ -212,7 +212,8 @@ ecma_op_object_put( ecma_object_t *obj_p, /**< the object */
ecma_property_t *own_desc_p = ecma_op_object_get_own_property( obj_p, property_name_p);
// 3.
if ( own_desc_p->type == ECMA_PROPERTY_NAMEDDATA )
if ( own_desc_p != NULL
&& own_desc_p->type == ECMA_PROPERTY_NAMEDDATA )
{
// a.
ecma_property_descriptor_t value_desc = ecma_make_empty_property_descriptor();
@ -232,7 +233,8 @@ ecma_op_object_put( ecma_object_t *obj_p, /**< the object */
ecma_property_t *desc_p = ecma_op_object_get_property( obj_p, property_name_p);
// 5.
if ( desc_p->type == ECMA_PROPERTY_NAMEDACCESSOR )
if ( desc_p != NULL
&& desc_p->type == ECMA_PROPERTY_NAMEDACCESSOR )
{
// a.
ecma_object_t *setter_p = ecma_get_pointer( desc_p->u.named_accessor_property.set_p);

View File

@ -130,12 +130,17 @@ read_sources (const char *script_file_names[],
__rewind( file);
const size_t source_size = (size_t)script_len;
size_t bytes_read = 0;
const size_t current_source_size = (size_t)script_len;
while ( bytes_read < source_size )
if ( source_buffer_tail + current_source_size >= source_buffer + sizeof(source_buffer) )
{
bytes_read += __fread( source_buffer_tail, 1, source_size, file);
jerry_exit (ERR_MEMORY);
}
size_t bytes_read = 0;
while ( bytes_read < current_source_size )
{
bytes_read += __fread( source_buffer_tail + bytes_read, sizeof(uint8_t), current_source_size - bytes_read, file);
if ( __ferror( file) != 0 )
{
@ -145,11 +150,14 @@ read_sources (const char *script_file_names[],
__fclose( file);
source_buffer_tail += source_size;
*out_source_size_p += source_size;
source_buffer_tail += current_source_size;
}
const size_t source_size = (size_t) (source_buffer_tail - source_buffer);
JERRY_ASSERT( source_size < sizeof(source_buffer) );
*out_source_size_p = source_size;
return (const char*)source_buffer;
}

View File

@ -0,0 +1,19 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var a = 1;
var b = 2;
assertEquals(a+b, 3);
assertEquals(b+a, 3);

View File

@ -14,12 +14,12 @@
#!/bin/bash
echo "#include \"globals.h\"" > "generated.h"
echo "" >> "generated.h"
echo "static const char* generated_source = \"\"" >> "generated.h"
echo "#include \"globals.h\"" > $2
echo "" >> $2
echo "static const char* generated_source = \"\"" >> $2
while read line
do
echo "\"$line\n\"" >> "generated.h"
echo "\"$line\n\"" >> $2
done < $1
echo ";" >> "generated.h"
echo ";" >> $2