From: ager@chromium.org Date: Mon, 28 Mar 2011 13:09:37 +0000 (+0000) Subject: Cleanup of Isolate::Current(), FACTORY and HEAP usage in bootstrapper.cc. X-Git-Tag: upstream/4.7.83~19791 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=68176825e23af6a897077e5552906da623d60fb3;p=platform%2Fupstream%2Fv8.git Cleanup of Isolate::Current(), FACTORY and HEAP usage in bootstrapper.cc. BUG= TEST= Review URL: http://codereview.chromium.org/6758005 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7389 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index e7c0554..9c9bac7 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -69,23 +69,26 @@ Bootstrapper::Bootstrapper() Handle Bootstrapper::NativesSourceLookup(int index) { ASSERT(0 <= index && index < Natives::GetBuiltinsCount()); - if (HEAP->natives_source_cache()->get(index)->IsUndefined()) { + Isolate* isolate = Isolate::Current(); + Factory* factory = isolate->factory(); + Heap* heap = isolate->heap(); + if (heap->natives_source_cache()->get(index)->IsUndefined()) { if (!Snapshot::IsEnabled() || FLAG_new_snapshot) { // We can use external strings for the natives. NativesExternalStringResource* resource = new NativesExternalStringResource(this, Natives::GetScriptSource(index).start()); Handle source_code = - FACTORY->NewExternalStringFromAscii(resource); - HEAP->natives_source_cache()->set(index, *source_code); + factory->NewExternalStringFromAscii(resource); + heap->natives_source_cache()->set(index, *source_code); } else { // Old snapshot code can't cope with external strings at all. Handle source_code = - FACTORY->NewStringFromAscii(Natives::GetScriptSource(index)); - HEAP->natives_source_cache()->set(index, *source_code); + factory->NewStringFromAscii(Natives::GetScriptSource(index)); + heap->natives_source_cache()->set(index, *source_code); } } - Handle cached_source(HEAP->natives_source_cache()->get(index)); + Handle cached_source(heap->natives_source_cache()->get(index)); return Handle::cast(cached_source); } @@ -292,9 +295,10 @@ static void SetObjectPrototype(Handle object, Handle proto) { void Bootstrapper::DetachGlobal(Handle env) { - JSGlobalProxy::cast(env->global_proxy())->set_context(*FACTORY->null_value()); + Factory* factory = Isolate::Current()->factory(); + JSGlobalProxy::cast(env->global_proxy())->set_context(*factory->null_value()); SetObjectPrototype(Handle(env->global_proxy()), - FACTORY->null_value()); + factory->null_value()); env->set_global_proxy(env->global()); env->global()->set_global_receiver(env->global()); } @@ -318,12 +322,13 @@ static Handle InstallFunction(Handle target, Handle prototype, Builtins::Name call, bool is_ecma_native) { - Handle symbol = FACTORY->LookupAsciiSymbol(name); - Handle call_code = Handle( - Isolate::Current()->builtins()->builtin(call)); + Isolate* isolate = Isolate::Current(); + Factory* factory = isolate->factory(); + Handle symbol = factory->LookupAsciiSymbol(name); + Handle call_code = Handle(isolate->builtins()->builtin(call)); Handle function = prototype.is_null() ? - FACTORY->NewFunctionWithoutPrototype(symbol, call_code) : - FACTORY->NewFunctionWithPrototype(symbol, + factory->NewFunctionWithoutPrototype(symbol, call_code) : + factory->NewFunctionWithPrototype(symbol, type, instance_size, prototype, @@ -339,29 +344,30 @@ static Handle InstallFunction(Handle target, Handle Genesis::ComputeFunctionInstanceDescriptor( PrototypePropertyMode prototypeMode) { + Factory* factory = Isolate::Current()->factory(); Handle descriptors = - FACTORY->NewDescriptorArray(prototypeMode == DONT_ADD_PROTOTYPE ? 4 : 5); + factory->NewDescriptorArray(prototypeMode == DONT_ADD_PROTOTYPE ? 4 : 5); PropertyAttributes attributes = static_cast(DONT_ENUM | DONT_DELETE | READ_ONLY); { // Add length. - Handle proxy = FACTORY->NewProxy(&Accessors::FunctionLength); - CallbacksDescriptor d(*FACTORY->length_symbol(), *proxy, attributes); + Handle proxy = factory->NewProxy(&Accessors::FunctionLength); + CallbacksDescriptor d(*factory->length_symbol(), *proxy, attributes); descriptors->Set(0, &d); } { // Add name. - Handle proxy = FACTORY->NewProxy(&Accessors::FunctionName); - CallbacksDescriptor d(*FACTORY->name_symbol(), *proxy, attributes); + Handle proxy = factory->NewProxy(&Accessors::FunctionName); + CallbacksDescriptor d(*factory->name_symbol(), *proxy, attributes); descriptors->Set(1, &d); } { // Add arguments. - Handle proxy = FACTORY->NewProxy(&Accessors::FunctionArguments); - CallbacksDescriptor d(*FACTORY->arguments_symbol(), *proxy, attributes); + Handle proxy = factory->NewProxy(&Accessors::FunctionArguments); + CallbacksDescriptor d(*factory->arguments_symbol(), *proxy, attributes); descriptors->Set(2, &d); } { // Add caller. - Handle proxy = FACTORY->NewProxy(&Accessors::FunctionCaller); - CallbacksDescriptor d(*FACTORY->caller_symbol(), *proxy, attributes); + Handle proxy = factory->NewProxy(&Accessors::FunctionCaller); + CallbacksDescriptor d(*factory->caller_symbol(), *proxy, attributes); descriptors->Set(3, &d); } if (prototypeMode != DONT_ADD_PROTOTYPE) { @@ -369,8 +375,8 @@ Handle Genesis::ComputeFunctionInstanceDescriptor( if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) { attributes = static_cast(attributes & ~READ_ONLY); } - Handle proxy = FACTORY->NewProxy(&Accessors::FunctionPrototype); - CallbacksDescriptor d(*FACTORY->prototype_symbol(), *proxy, attributes); + Handle proxy = factory->NewProxy(&Accessors::FunctionPrototype); + CallbacksDescriptor d(*factory->prototype_symbol(), *proxy, attributes); descriptors->Set(4, &d); } descriptors->Sort(); @@ -413,43 +419,47 @@ Handle Genesis::CreateEmptyFunction() { function_instance_map_writable_prototype_ = CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE); - Handle object_name = Handle(HEAP->Object_symbol()); + Isolate* isolate = Isolate::Current(); + Factory* factory = isolate->factory(); + Heap* heap = isolate->heap(); + + Handle object_name = Handle(heap->Object_symbol()); { // --- O b j e c t --- Handle object_fun = - FACTORY->NewFunction(object_name, FACTORY->null_value()); + factory->NewFunction(object_name, factory->null_value()); Handle object_function_map = - FACTORY->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); + factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); object_fun->set_initial_map(*object_function_map); object_function_map->set_constructor(*object_fun); global_context()->set_object_function(*object_fun); // Allocate a new prototype for the object function. - Handle prototype = FACTORY->NewJSObject( - Isolate::Current()->object_function(), + Handle prototype = factory->NewJSObject( + isolate->object_function(), TENURED); global_context()->set_initial_object_prototype(*prototype); SetPrototype(object_fun, prototype); object_function_map-> - set_instance_descriptors(HEAP->empty_descriptor_array()); + set_instance_descriptors(heap->empty_descriptor_array()); } // Allocate the empty function as the prototype for function ECMAScript // 262 15.3.4. - Handle symbol = FACTORY->LookupAsciiSymbol("Empty"); + Handle symbol = factory->LookupAsciiSymbol("Empty"); Handle empty_function = - FACTORY->NewFunctionWithoutPrototype(symbol, kNonStrictMode); + factory->NewFunctionWithoutPrototype(symbol, kNonStrictMode); // --- E m p t y --- Handle code = - Handle(Isolate::Current()->builtins()->builtin( + Handle(isolate->builtins()->builtin( Builtins::kEmptyFunction)); empty_function->set_code(*code); empty_function->shared()->set_code(*code); - Handle source = FACTORY->NewStringFromAscii(CStrVector("() {}")); - Handle