From 806fb8be96df5ee90c70602e395f04071e159509 Mon Sep 17 00:00:00 2001 From: "mstarzinger@chromium.org" Date: Mon, 23 Jul 2012 16:18:25 +0000 Subject: [PATCH] Fix bootstrapping without snapshot and low GC interval. R=yangguo@chromium.org BUG=v8:2249 TEST=mjsunit/regress/regress-2249 (snapshot=off) Review URL: https://chromiumcodereview.appspot.com/10818005 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12177 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/bootstrapper.cc | 179 ++++++++++++++++------------- test/mjsunit/{ => regress}/regress-2249.js | 0 2 files changed, 101 insertions(+), 78 deletions(-) rename test/mjsunit/{ => regress}/regress-2249.js (100%) diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index 8501cc3..c72af5c 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -387,30 +387,34 @@ void Genesis::SetFunctionInstanceDescriptor( Handle map, PrototypePropertyMode prototypeMode) { int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; Handle descriptors(factory()->NewDescriptorArray(size)); + DescriptorArray::WhitenessWitness witness(*descriptors); + + Handle length(factory()->NewForeign(&Accessors::FunctionLength)); + Handle name(factory()->NewForeign(&Accessors::FunctionName)); + Handle args(factory()->NewForeign(&Accessors::FunctionArguments)); + Handle caller(factory()->NewForeign(&Accessors::FunctionCaller)); + Handle prototype; + if (prototypeMode != DONT_ADD_PROTOTYPE) { + prototype = factory()->NewForeign(&Accessors::FunctionPrototype); + } PropertyAttributes attribs = static_cast( DONT_ENUM | DONT_DELETE | READ_ONLY); - - DescriptorArray::WhitenessWitness witness(*descriptors); map->set_instance_descriptors(*descriptors); { // Add length. - Handle f(factory()->NewForeign(&Accessors::FunctionLength)); - CallbacksDescriptor d(*factory()->length_symbol(), *f, attribs); + CallbacksDescriptor d(*factory()->length_symbol(), *length, attribs); map->AppendDescriptor(&d, witness); } { // Add name. - Handle f(factory()->NewForeign(&Accessors::FunctionName)); - CallbacksDescriptor d(*factory()->name_symbol(), *f, attribs); + CallbacksDescriptor d(*factory()->name_symbol(), *name, attribs); map->AppendDescriptor(&d, witness); } { // Add arguments. - Handle f(factory()->NewForeign(&Accessors::FunctionArguments)); - CallbacksDescriptor d(*factory()->arguments_symbol(), *f, attribs); + CallbacksDescriptor d(*factory()->arguments_symbol(), *args, attribs); map->AppendDescriptor(&d, witness); } { // Add caller. - Handle f(factory()->NewForeign(&Accessors::FunctionCaller)); - CallbacksDescriptor d(*factory()->caller_symbol(), *f, attribs); + CallbacksDescriptor d(*factory()->caller_symbol(), *caller, attribs); map->AppendDescriptor(&d, witness); } if (prototypeMode != DONT_ADD_PROTOTYPE) { @@ -418,8 +422,7 @@ void Genesis::SetFunctionInstanceDescriptor( if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) { attribs = static_cast(attribs & ~READ_ONLY); } - Handle f(factory()->NewForeign(&Accessors::FunctionPrototype)); - CallbacksDescriptor d(*factory()->prototype_symbol(), *f, attribs); + CallbacksDescriptor d(*factory()->prototype_symbol(), *prototype, attribs); map->AppendDescriptor(&d, witness); } } @@ -525,40 +528,42 @@ void Genesis::SetStrictFunctionInstanceDescriptor( Handle map, PrototypePropertyMode prototypeMode) { int size = (prototypeMode == DONT_ADD_PROTOTYPE) ? 4 : 5; Handle descriptors(factory()->NewDescriptorArray(size)); + DescriptorArray::WhitenessWitness witness(*descriptors); + + Handle length(factory()->NewForeign(&Accessors::FunctionLength)); + Handle name(factory()->NewForeign(&Accessors::FunctionName)); + Handle arguments(factory()->NewAccessorPair()); + Handle caller(factory()->NewAccessorPair()); + Handle prototype; + if (prototypeMode != DONT_ADD_PROTOTYPE) { + prototype = factory()->NewForeign(&Accessors::FunctionPrototype); + } PropertyAttributes attribs = static_cast( DONT_ENUM | DONT_DELETE); - - DescriptorArray::WhitenessWitness witness(*descriptors); map->set_instance_descriptors(*descriptors); { // Add length. - Handle f(factory()->NewForeign(&Accessors::FunctionLength)); - CallbacksDescriptor d(*factory()->length_symbol(), *f, attribs); + CallbacksDescriptor d(*factory()->length_symbol(), *length, attribs); map->AppendDescriptor(&d, witness); } { // Add name. - Handle f(factory()->NewForeign(&Accessors::FunctionName)); - CallbacksDescriptor d(*factory()->name_symbol(), *f, attribs); + CallbacksDescriptor d(*factory()->name_symbol(), *name, attribs); map->AppendDescriptor(&d, witness); } { // Add arguments. - Handle arguments(factory()->NewAccessorPair()); CallbacksDescriptor d(*factory()->arguments_symbol(), *arguments, attribs); map->AppendDescriptor(&d, witness); } { // Add caller. - Handle caller(factory()->NewAccessorPair()); CallbacksDescriptor d(*factory()->caller_symbol(), *caller, attribs); map->AppendDescriptor(&d, witness); } - if (prototypeMode != DONT_ADD_PROTOTYPE) { // Add prototype. if (prototypeMode != ADD_WRITEABLE_PROTOTYPE) { attribs = static_cast(attribs | READ_ONLY); } - Handle f(factory()->NewForeign(&Accessors::FunctionPrototype)); - CallbacksDescriptor d(*factory()->prototype_symbol(), *f, attribs); + CallbacksDescriptor d(*factory()->prototype_symbol(), *prototype, attribs); map->AppendDescriptor(&d, witness); } } @@ -858,21 +863,20 @@ bool Genesis::InitializeGlobal(Handle inner_global, isolate->builtins()->builtin(Builtins::kArrayConstructCode)); array_function->shared()->DontAdaptArguments(); - // This seems a bit hackish, but we need to make sure Array.length // is 1. array_function->shared()->set_length(1); Handle array_descriptors(factory->NewDescriptorArray(1)); + DescriptorArray::WhitenessWitness witness(*array_descriptors); + + Handle array_length(factory->NewForeign(&Accessors::ArrayLength)); PropertyAttributes attribs = static_cast( DONT_ENUM | DONT_DELETE); - - DescriptorArray::WhitenessWitness witness(*array_descriptors); array_function->initial_map()->set_instance_descriptors(*array_descriptors); { // Add length. - Handle f(factory->NewForeign(&Accessors::ArrayLength)); - CallbacksDescriptor d(*factory->length_symbol(), *f, attribs); + CallbacksDescriptor d(*factory->length_symbol(), *array_length, attribs); array_function->initial_map()->AppendDescriptor(&d, witness); } @@ -911,15 +915,16 @@ bool Genesis::InitializeGlobal(Handle inner_global, Handle string_map = Handle(global_context()->string_function()->initial_map()); Handle string_descriptors(factory->NewDescriptorArray(1)); + DescriptorArray::WhitenessWitness witness(*string_descriptors); + + Handle string_length( + factory->NewForeign(&Accessors::StringLength)); PropertyAttributes attribs = static_cast( DONT_ENUM | DONT_DELETE | READ_ONLY); - - DescriptorArray::WhitenessWitness witness(*string_descriptors); string_map->set_instance_descriptors(*string_descriptors); { // Add length. - Handle f(factory->NewForeign(&Accessors::StringLength)); - CallbacksDescriptor d(*factory->length_symbol(), *f, attribs); + CallbacksDescriptor d(*factory->length_symbol(), *string_length, attribs); string_map->AppendDescriptor(&d, witness); } } @@ -1473,112 +1478,128 @@ bool Genesis::InstallNatives() { SetPrototype(script_fun, prototype); global_context()->set_script_function(*script_fun); - PropertyAttributes attribs = - static_cast(DONT_ENUM | DONT_DELETE | READ_ONLY); - Handle script_map = Handle(script_fun->initial_map()); Handle script_descriptors( factory()->NewDescriptorArray(13)); - DescriptorArray::WhitenessWitness witness(*script_descriptors); + + Handle script_source( + factory()->NewForeign(&Accessors::ScriptSource)); + Handle script_name(factory()->NewForeign(&Accessors::ScriptName)); + Handle id_symbol(factory()->LookupAsciiSymbol("id")); + Handle script_id(factory()->NewForeign(&Accessors::ScriptId)); + Handle line_offset_symbol( + factory()->LookupAsciiSymbol("line_offset")); + Handle script_line_offset( + factory()->NewForeign(&Accessors::ScriptLineOffset)); + Handle column_offset_symbol( + factory()->LookupAsciiSymbol("column_offset")); + Handle script_column_offset( + factory()->NewForeign(&Accessors::ScriptColumnOffset)); + Handle data_symbol(factory()->LookupAsciiSymbol("data")); + Handle script_data(factory()->NewForeign(&Accessors::ScriptData)); + Handle type_symbol(factory()->LookupAsciiSymbol("type")); + Handle script_type(factory()->NewForeign(&Accessors::ScriptType)); + Handle compilation_type_symbol( + factory()->LookupAsciiSymbol("compilation_type")); + Handle script_compilation_type( + factory()->NewForeign(&Accessors::ScriptCompilationType)); + Handle line_ends_symbol(factory()->LookupAsciiSymbol("line_ends")); + Handle script_line_ends( + factory()->NewForeign(&Accessors::ScriptLineEnds)); + Handle context_data_symbol( + factory()->LookupAsciiSymbol("context_data")); + Handle script_context_data( + factory()->NewForeign(&Accessors::ScriptContextData)); + Handle eval_from_script_symbol( + factory()->LookupAsciiSymbol("eval_from_script")); + Handle script_eval_from_script( + factory()->NewForeign(&Accessors::ScriptEvalFromScript)); + Handle eval_from_script_position_symbol( + factory()->LookupAsciiSymbol("eval_from_script_position")); + Handle script_eval_from_script_position( + factory()->NewForeign(&Accessors::ScriptEvalFromScriptPosition)); + Handle eval_from_function_name_symbol( + factory()->LookupAsciiSymbol("eval_from_function_name")); + Handle script_eval_from_function_name( + factory()->NewForeign(&Accessors::ScriptEvalFromFunctionName)); + PropertyAttributes attribs = + static_cast(DONT_ENUM | DONT_DELETE | READ_ONLY); script_map->set_instance_descriptors(*script_descriptors); { - Handle f(factory()->NewForeign(&Accessors::ScriptSource)); CallbacksDescriptor d( - *factory()->LookupAsciiSymbol("source"), *f, attribs); + *factory()->source_symbol(), *script_source, attribs); script_map->AppendDescriptor(&d, witness); } { - Handle f(factory()->NewForeign(&Accessors::ScriptName)); - CallbacksDescriptor d( - *factory()->LookupAsciiSymbol("name"), *f, attribs); + CallbacksDescriptor d(*factory()->name_symbol(), *script_name, attribs); script_map->AppendDescriptor(&d, witness); } { - Handle f(factory()->NewForeign(&Accessors::ScriptId)); - CallbacksDescriptor d( - *factory()->LookupAsciiSymbol("id"), *f, attribs); + CallbacksDescriptor d(*id_symbol, *script_id, attribs); script_map->AppendDescriptor(&d, witness); } { - Handle f(factory()->NewForeign(&Accessors::ScriptLineOffset)); - CallbacksDescriptor d( - *factory()->LookupAsciiSymbol("line_offset"), *f, attribs); + CallbacksDescriptor d(*line_offset_symbol, *script_line_offset, attribs); script_map->AppendDescriptor(&d, witness); } { - Handle f(factory()->NewForeign(&Accessors::ScriptColumnOffset)); CallbacksDescriptor d( - *factory()->LookupAsciiSymbol("column_offset"), *f, attribs); + *column_offset_symbol, *script_column_offset, attribs); script_map->AppendDescriptor(&d, witness); } { - Handle f(factory()->NewForeign(&Accessors::ScriptData)); - CallbacksDescriptor d( - *factory()->LookupAsciiSymbol("data"), *f, attribs); + CallbacksDescriptor d(*data_symbol, *script_data, attribs); script_map->AppendDescriptor(&d, witness); } { - Handle f(factory()->NewForeign(&Accessors::ScriptType)); - CallbacksDescriptor d( - *factory()->LookupAsciiSymbol("type"), *f, attribs); + CallbacksDescriptor d(*type_symbol, *script_type, attribs); script_map->AppendDescriptor(&d, witness); } { - Handle f(factory()->NewForeign( - &Accessors::ScriptCompilationType)); CallbacksDescriptor d( - *factory()->LookupAsciiSymbol("compilation_type"), *f, attribs); + *compilation_type_symbol, *script_compilation_type, attribs); script_map->AppendDescriptor(&d, witness); } { - Handle f(factory()->NewForeign(&Accessors::ScriptLineEnds)); - CallbacksDescriptor d( - *factory()->LookupAsciiSymbol("line_ends"), *f, attribs); + CallbacksDescriptor d(*line_ends_symbol, *script_line_ends, attribs); script_map->AppendDescriptor(&d, witness); } { - Handle f(factory()->NewForeign(&Accessors::ScriptContextData)); CallbacksDescriptor d( - *factory()->LookupAsciiSymbol("context_data"), *f, attribs); + *context_data_symbol, *script_context_data, attribs); script_map->AppendDescriptor(&d, witness); } { - Handle f(factory()->NewForeign( - &Accessors::ScriptEvalFromScript)); CallbacksDescriptor d( - *factory()->LookupAsciiSymbol("eval_from_script"), *f, attribs); + *eval_from_script_symbol, *script_eval_from_script, attribs); script_map->AppendDescriptor(&d, witness); } { - Handle f(factory()->NewForeign( - &Accessors::ScriptEvalFromScriptPosition)); CallbacksDescriptor d( - *factory()->LookupAsciiSymbol("eval_from_script_position"), - *f, + *eval_from_script_position_symbol, + *script_eval_from_script_position, attribs); script_map->AppendDescriptor(&d, witness); } { - Handle f(factory()->NewForeign( - &Accessors::ScriptEvalFromFunctionName)); CallbacksDescriptor d( - *factory()->LookupAsciiSymbol("eval_from_function_name"), - *f, + *eval_from_function_name_symbol, + *script_eval_from_function_name, attribs); script_map->AppendDescriptor(&d, witness); } @@ -1639,15 +1660,17 @@ bool Genesis::InstallNatives() { // Make "length" magic on instances. Handle array_descriptors(factory()->NewDescriptorArray(1)); + DescriptorArray::WhitenessWitness witness(*array_descriptors); + + Handle array_length(factory()->NewForeign( + &Accessors::ArrayLength)); PropertyAttributes attribs = static_cast( DONT_ENUM | DONT_DELETE); - - DescriptorArray::WhitenessWitness witness(*array_descriptors); array_function->initial_map()->set_instance_descriptors(*array_descriptors); { // Add length. - Handle f(factory()->NewForeign(&Accessors::ArrayLength)); - CallbacksDescriptor d(*factory()->length_symbol(), *f, attribs); + CallbacksDescriptor d( + *factory()->length_symbol(), *array_length, attribs); array_function->initial_map()->AppendDescriptor(&d, witness); } diff --git a/test/mjsunit/regress-2249.js b/test/mjsunit/regress/regress-2249.js similarity index 100% rename from test/mjsunit/regress-2249.js rename to test/mjsunit/regress/regress-2249.js -- 2.7.4