Commit 68176825 authored by ager@chromium.org's avatar ager@chromium.org

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
parent 2531480d
...@@ -69,23 +69,26 @@ Bootstrapper::Bootstrapper() ...@@ -69,23 +69,26 @@ Bootstrapper::Bootstrapper()
Handle<String> Bootstrapper::NativesSourceLookup(int index) { Handle<String> Bootstrapper::NativesSourceLookup(int index) {
ASSERT(0 <= index && index < Natives::GetBuiltinsCount()); 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) { if (!Snapshot::IsEnabled() || FLAG_new_snapshot) {
// We can use external strings for the natives. // We can use external strings for the natives.
NativesExternalStringResource* resource = NativesExternalStringResource* resource =
new NativesExternalStringResource(this, new NativesExternalStringResource(this,
Natives::GetScriptSource(index).start()); Natives::GetScriptSource(index).start());
Handle<String> source_code = Handle<String> source_code =
FACTORY->NewExternalStringFromAscii(resource); factory->NewExternalStringFromAscii(resource);
HEAP->natives_source_cache()->set(index, *source_code); heap->natives_source_cache()->set(index, *source_code);
} else { } else {
// Old snapshot code can't cope with external strings at all. // Old snapshot code can't cope with external strings at all.
Handle<String> source_code = Handle<String> source_code =
FACTORY->NewStringFromAscii(Natives::GetScriptSource(index)); factory->NewStringFromAscii(Natives::GetScriptSource(index));
HEAP->natives_source_cache()->set(index, *source_code); heap->natives_source_cache()->set(index, *source_code);
} }
} }
Handle<Object> cached_source(HEAP->natives_source_cache()->get(index)); Handle<Object> cached_source(heap->natives_source_cache()->get(index));
return Handle<String>::cast(cached_source); return Handle<String>::cast(cached_source);
} }
...@@ -292,9 +295,10 @@ static void SetObjectPrototype(Handle<JSObject> object, Handle<Object> proto) { ...@@ -292,9 +295,10 @@ static void SetObjectPrototype(Handle<JSObject> object, Handle<Object> proto) {
void Bootstrapper::DetachGlobal(Handle<Context> env) { void Bootstrapper::DetachGlobal(Handle<Context> 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<JSObject>(env->global_proxy()), SetObjectPrototype(Handle<JSObject>(env->global_proxy()),
FACTORY->null_value()); factory->null_value());
env->set_global_proxy(env->global()); env->set_global_proxy(env->global());
env->global()->set_global_receiver(env->global()); env->global()->set_global_receiver(env->global());
} }
...@@ -318,12 +322,13 @@ static Handle<JSFunction> InstallFunction(Handle<JSObject> target, ...@@ -318,12 +322,13 @@ static Handle<JSFunction> InstallFunction(Handle<JSObject> target,
Handle<JSObject> prototype, Handle<JSObject> prototype,
Builtins::Name call, Builtins::Name call,
bool is_ecma_native) { bool is_ecma_native) {
Handle<String> symbol = FACTORY->LookupAsciiSymbol(name); Isolate* isolate = Isolate::Current();
Handle<Code> call_code = Handle<Code>( Factory* factory = isolate->factory();
Isolate::Current()->builtins()->builtin(call)); Handle<String> symbol = factory->LookupAsciiSymbol(name);
Handle<Code> call_code = Handle<Code>(isolate->builtins()->builtin(call));
Handle<JSFunction> function = prototype.is_null() ? Handle<JSFunction> function = prototype.is_null() ?
FACTORY->NewFunctionWithoutPrototype(symbol, call_code) : factory->NewFunctionWithoutPrototype(symbol, call_code) :
FACTORY->NewFunctionWithPrototype(symbol, factory->NewFunctionWithPrototype(symbol,
type, type,
instance_size, instance_size,
prototype, prototype,
...@@ -339,29 +344,30 @@ static Handle<JSFunction> InstallFunction(Handle<JSObject> target, ...@@ -339,29 +344,30 @@ static Handle<JSFunction> InstallFunction(Handle<JSObject> target,
Handle<DescriptorArray> Genesis::ComputeFunctionInstanceDescriptor( Handle<DescriptorArray> Genesis::ComputeFunctionInstanceDescriptor(
PrototypePropertyMode prototypeMode) { PrototypePropertyMode prototypeMode) {
Factory* factory = Isolate::Current()->factory();
Handle<DescriptorArray> descriptors = Handle<DescriptorArray> descriptors =
FACTORY->NewDescriptorArray(prototypeMode == DONT_ADD_PROTOTYPE ? 4 : 5); factory->NewDescriptorArray(prototypeMode == DONT_ADD_PROTOTYPE ? 4 : 5);
PropertyAttributes attributes = PropertyAttributes attributes =
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
{ // Add length. { // Add length.
Handle<Proxy> proxy = FACTORY->NewProxy(&Accessors::FunctionLength); Handle<Proxy> proxy = factory->NewProxy(&Accessors::FunctionLength);
CallbacksDescriptor d(*FACTORY->length_symbol(), *proxy, attributes); CallbacksDescriptor d(*factory->length_symbol(), *proxy, attributes);
descriptors->Set(0, &d); descriptors->Set(0, &d);
} }
{ // Add name. { // Add name.
Handle<Proxy> proxy = FACTORY->NewProxy(&Accessors::FunctionName); Handle<Proxy> proxy = factory->NewProxy(&Accessors::FunctionName);
CallbacksDescriptor d(*FACTORY->name_symbol(), *proxy, attributes); CallbacksDescriptor d(*factory->name_symbol(), *proxy, attributes);
descriptors->Set(1, &d); descriptors->Set(1, &d);
} }
{ // Add arguments. { // Add arguments.
Handle<Proxy> proxy = FACTORY->NewProxy(&Accessors::FunctionArguments); Handle<Proxy> proxy = factory->NewProxy(&Accessors::FunctionArguments);
CallbacksDescriptor d(*FACTORY->arguments_symbol(), *proxy, attributes); CallbacksDescriptor d(*factory->arguments_symbol(), *proxy, attributes);
descriptors->Set(2, &d); descriptors->Set(2, &d);
} }
{ // Add caller. { // Add caller.
Handle<Proxy> proxy = FACTORY->NewProxy(&Accessors::FunctionCaller); Handle<Proxy> proxy = factory->NewProxy(&Accessors::FunctionCaller);
CallbacksDescriptor d(*FACTORY->caller_symbol(), *proxy, attributes); CallbacksDescriptor d(*factory->caller_symbol(), *proxy, attributes);
descriptors->Set(3, &d); descriptors->Set(3, &d);
} }
if (prototypeMode != DONT_ADD_PROTOTYPE) { if (prototypeMode != DONT_ADD_PROTOTYPE) {
...@@ -369,8 +375,8 @@ Handle<DescriptorArray> Genesis::ComputeFunctionInstanceDescriptor( ...@@ -369,8 +375,8 @@ Handle<DescriptorArray> Genesis::ComputeFunctionInstanceDescriptor(
if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) { if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) {
attributes = static_cast<PropertyAttributes>(attributes & ~READ_ONLY); attributes = static_cast<PropertyAttributes>(attributes & ~READ_ONLY);
} }
Handle<Proxy> proxy = FACTORY->NewProxy(&Accessors::FunctionPrototype); Handle<Proxy> proxy = factory->NewProxy(&Accessors::FunctionPrototype);
CallbacksDescriptor d(*FACTORY->prototype_symbol(), *proxy, attributes); CallbacksDescriptor d(*factory->prototype_symbol(), *proxy, attributes);
descriptors->Set(4, &d); descriptors->Set(4, &d);
} }
descriptors->Sort(); descriptors->Sort();
...@@ -413,43 +419,47 @@ Handle<JSFunction> Genesis::CreateEmptyFunction() { ...@@ -413,43 +419,47 @@ Handle<JSFunction> Genesis::CreateEmptyFunction() {
function_instance_map_writable_prototype_ = function_instance_map_writable_prototype_ =
CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE); CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE);
Handle<String> object_name = Handle<String>(HEAP->Object_symbol()); Isolate* isolate = Isolate::Current();
Factory* factory = isolate->factory();
Heap* heap = isolate->heap();
Handle<String> object_name = Handle<String>(heap->Object_symbol());
{ // --- O b j e c t --- { // --- O b j e c t ---
Handle<JSFunction> object_fun = Handle<JSFunction> object_fun =
FACTORY->NewFunction(object_name, FACTORY->null_value()); factory->NewFunction(object_name, factory->null_value());
Handle<Map> object_function_map = Handle<Map> 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_fun->set_initial_map(*object_function_map);
object_function_map->set_constructor(*object_fun); object_function_map->set_constructor(*object_fun);
global_context()->set_object_function(*object_fun); global_context()->set_object_function(*object_fun);
// Allocate a new prototype for the object function. // Allocate a new prototype for the object function.
Handle<JSObject> prototype = FACTORY->NewJSObject( Handle<JSObject> prototype = factory->NewJSObject(
Isolate::Current()->object_function(), isolate->object_function(),
TENURED); TENURED);
global_context()->set_initial_object_prototype(*prototype); global_context()->set_initial_object_prototype(*prototype);
SetPrototype(object_fun, prototype); SetPrototype(object_fun, prototype);
object_function_map-> 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 // Allocate the empty function as the prototype for function ECMAScript
// 262 15.3.4. // 262 15.3.4.
Handle<String> symbol = FACTORY->LookupAsciiSymbol("Empty"); Handle<String> symbol = factory->LookupAsciiSymbol("Empty");
Handle<JSFunction> empty_function = Handle<JSFunction> empty_function =
FACTORY->NewFunctionWithoutPrototype(symbol, kNonStrictMode); factory->NewFunctionWithoutPrototype(symbol, kNonStrictMode);
// --- E m p t y --- // --- E m p t y ---
Handle<Code> code = Handle<Code> code =
Handle<Code>(Isolate::Current()->builtins()->builtin( Handle<Code>(isolate->builtins()->builtin(
Builtins::kEmptyFunction)); Builtins::kEmptyFunction));
empty_function->set_code(*code); empty_function->set_code(*code);
empty_function->shared()->set_code(*code); empty_function->shared()->set_code(*code);
Handle<String> source = FACTORY->NewStringFromAscii(CStrVector("() {}")); Handle<String> source = factory->NewStringFromAscii(CStrVector("() {}"));
Handle<Script> script = FACTORY->NewScript(source); Handle<Script> script = factory->NewScript(source);
script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
empty_function->shared()->set_script(*script); empty_function->shared()->set_script(*script);
empty_function->shared()->set_start_position(0); empty_function->shared()->set_start_position(0);
...@@ -466,7 +476,7 @@ Handle<JSFunction> Genesis::CreateEmptyFunction() { ...@@ -466,7 +476,7 @@ Handle<JSFunction> Genesis::CreateEmptyFunction() {
// Allocate the function map first and then patch the prototype later // Allocate the function map first and then patch the prototype later
Handle<Map> function_without_prototype_map( Handle<Map> function_without_prototype_map(
global_context()->function_without_prototype_map()); global_context()->function_without_prototype_map());
Handle<Map> empty_fm = FACTORY->CopyMapDropDescriptors( Handle<Map> empty_fm = factory->CopyMapDropDescriptors(
function_without_prototype_map); function_without_prototype_map);
empty_fm->set_instance_descriptors( empty_fm->set_instance_descriptors(
function_without_prototype_map->instance_descriptors()); function_without_prototype_map->instance_descriptors());
...@@ -480,27 +490,28 @@ Handle<DescriptorArray> Genesis::ComputeStrictFunctionInstanceDescriptor( ...@@ -480,27 +490,28 @@ Handle<DescriptorArray> Genesis::ComputeStrictFunctionInstanceDescriptor(
PrototypePropertyMode prototypeMode, PrototypePropertyMode prototypeMode,
Handle<FixedArray> arguments, Handle<FixedArray> arguments,
Handle<FixedArray> caller) { Handle<FixedArray> caller) {
Factory* factory = Isolate::Current()->factory();
Handle<DescriptorArray> descriptors = Handle<DescriptorArray> descriptors =
FACTORY->NewDescriptorArray(prototypeMode == DONT_ADD_PROTOTYPE ? 4 : 5); factory->NewDescriptorArray(prototypeMode == DONT_ADD_PROTOTYPE ? 4 : 5);
PropertyAttributes attributes = static_cast<PropertyAttributes>( PropertyAttributes attributes = static_cast<PropertyAttributes>(
DONT_ENUM | DONT_DELETE | READ_ONLY); DONT_ENUM | DONT_DELETE | READ_ONLY);
{ // length { // length
Handle<Proxy> proxy = FACTORY->NewProxy(&Accessors::FunctionLength); Handle<Proxy> proxy = factory->NewProxy(&Accessors::FunctionLength);
CallbacksDescriptor d(*FACTORY->length_symbol(), *proxy, attributes); CallbacksDescriptor d(*factory->length_symbol(), *proxy, attributes);
descriptors->Set(0, &d); descriptors->Set(0, &d);
} }
{ // name { // name
Handle<Proxy> proxy = FACTORY->NewProxy(&Accessors::FunctionName); Handle<Proxy> proxy = factory->NewProxy(&Accessors::FunctionName);
CallbacksDescriptor d(*FACTORY->name_symbol(), *proxy, attributes); CallbacksDescriptor d(*factory->name_symbol(), *proxy, attributes);
descriptors->Set(1, &d); descriptors->Set(1, &d);
} }
{ // arguments { // arguments
CallbacksDescriptor d(*FACTORY->arguments_symbol(), *arguments, attributes); CallbacksDescriptor d(*factory->arguments_symbol(), *arguments, attributes);
descriptors->Set(2, &d); descriptors->Set(2, &d);
} }
{ // caller { // caller
CallbacksDescriptor d(*FACTORY->caller_symbol(), *caller, attributes); CallbacksDescriptor d(*factory->caller_symbol(), *caller, attributes);
descriptors->Set(3, &d); descriptors->Set(3, &d);
} }
...@@ -509,8 +520,8 @@ Handle<DescriptorArray> Genesis::ComputeStrictFunctionInstanceDescriptor( ...@@ -509,8 +520,8 @@ Handle<DescriptorArray> Genesis::ComputeStrictFunctionInstanceDescriptor(
if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) { if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) {
attributes = static_cast<PropertyAttributes>(attributes & ~READ_ONLY); attributes = static_cast<PropertyAttributes>(attributes & ~READ_ONLY);
} }
Handle<Proxy> proxy = FACTORY->NewProxy(&Accessors::FunctionPrototype); Handle<Proxy> proxy = factory->NewProxy(&Accessors::FunctionPrototype);
CallbacksDescriptor d(*FACTORY->prototype_symbol(), *proxy, attributes); CallbacksDescriptor d(*factory->prototype_symbol(), *proxy, attributes);
descriptors->Set(4, &d); descriptors->Set(4, &d);
} }
...@@ -522,11 +533,14 @@ Handle<DescriptorArray> Genesis::ComputeStrictFunctionInstanceDescriptor( ...@@ -522,11 +533,14 @@ Handle<DescriptorArray> Genesis::ComputeStrictFunctionInstanceDescriptor(
// ECMAScript 5th Edition, 13.2.3 // ECMAScript 5th Edition, 13.2.3
Handle<JSFunction> Genesis::CreateThrowTypeErrorFunction( Handle<JSFunction> Genesis::CreateThrowTypeErrorFunction(
Builtins::Name builtin) { Builtins::Name builtin) {
Handle<String> name = FACTORY->LookupAsciiSymbol("ThrowTypeError"); Isolate* isolate = Isolate::Current();
Factory* factory = isolate->factory();
Handle<String> name = factory->LookupAsciiSymbol("ThrowTypeError");
Handle<JSFunction> throw_type_error = Handle<JSFunction> throw_type_error =
FACTORY->NewFunctionWithoutPrototype(name, kStrictMode); factory->NewFunctionWithoutPrototype(name, kStrictMode);
Handle<Code> code = Handle<Code>( Handle<Code> code = Handle<Code>(
Isolate::Current()->builtins()->builtin(builtin)); isolate->builtins()->builtin(builtin));
throw_type_error->set_map(global_context()->strict_mode_function_map()); throw_type_error->set_map(global_context()->strict_mode_function_map());
throw_type_error->set_code(*code); throw_type_error->set_code(*code);
...@@ -559,8 +573,9 @@ Handle<Map> Genesis::CreateStrictModeFunctionMap( ...@@ -559,8 +573,9 @@ Handle<Map> Genesis::CreateStrictModeFunctionMap(
void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) { void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) {
// Create the callbacks arrays for ThrowTypeError functions. // Create the callbacks arrays for ThrowTypeError functions.
// The get/set callacks are filled in after the maps are created below. // The get/set callacks are filled in after the maps are created below.
Handle<FixedArray> arguments = FACTORY->NewFixedArray(2, TENURED); Factory* factory = Isolate::Current()->factory();
Handle<FixedArray> caller = FACTORY->NewFixedArray(2, TENURED); Handle<FixedArray> arguments = factory->NewFixedArray(2, TENURED);
Handle<FixedArray> caller = factory->NewFixedArray(2, TENURED);
// Allocate map for the strict mode function instances. // Allocate map for the strict mode function instances.
global_context()->set_strict_mode_function_instance_map( global_context()->set_strict_mode_function_instance_map(
...@@ -670,12 +685,16 @@ Handle<JSGlobalProxy> Genesis::CreateNewGlobals( ...@@ -670,12 +685,16 @@ Handle<JSGlobalProxy> Genesis::CreateNewGlobals(
} }
} }
Isolate* isolate = Isolate::Current();
Factory* factory = isolate->factory();
Heap* heap = isolate->heap();
if (js_global_template.is_null()) { if (js_global_template.is_null()) {
Handle<String> name = Handle<String>(HEAP->empty_symbol()); Handle<String> name = Handle<String>(heap->empty_symbol());
Handle<Code> code = Handle<Code>(Isolate::Current()->builtins()->builtin( Handle<Code> code = Handle<Code>(isolate->builtins()->builtin(
Builtins::kIllegal)); Builtins::kIllegal));
js_global_function = js_global_function =
FACTORY->NewFunction(name, JS_GLOBAL_OBJECT_TYPE, factory->NewFunction(name, JS_GLOBAL_OBJECT_TYPE,
JSGlobalObject::kSize, code, true); JSGlobalObject::kSize, code, true);
// Change the constructor property of the prototype of the // Change the constructor property of the prototype of the
// hidden global function to refer to the Object function. // hidden global function to refer to the Object function.
...@@ -684,20 +703,20 @@ Handle<JSGlobalProxy> Genesis::CreateNewGlobals( ...@@ -684,20 +703,20 @@ Handle<JSGlobalProxy> Genesis::CreateNewGlobals(
JSObject::cast(js_global_function->instance_prototype())); JSObject::cast(js_global_function->instance_prototype()));
SetLocalPropertyNoThrow( SetLocalPropertyNoThrow(
prototype, prototype,
FACTORY->constructor_symbol(), factory->constructor_symbol(),
Isolate::Current()->object_function(), isolate->object_function(),
NONE); NONE);
} else { } else {
Handle<FunctionTemplateInfo> js_global_constructor( Handle<FunctionTemplateInfo> js_global_constructor(
FunctionTemplateInfo::cast(js_global_template->constructor())); FunctionTemplateInfo::cast(js_global_template->constructor()));
js_global_function = js_global_function =
FACTORY->CreateApiFunction(js_global_constructor, factory->CreateApiFunction(js_global_constructor,
FACTORY->InnerGlobalObject); factory->InnerGlobalObject);
} }
js_global_function->initial_map()->set_is_hidden_prototype(); js_global_function->initial_map()->set_is_hidden_prototype();
Handle<GlobalObject> inner_global = Handle<GlobalObject> inner_global =
FACTORY->NewGlobalObject(js_global_function); factory->NewGlobalObject(js_global_function);
if (inner_global_out != NULL) { if (inner_global_out != NULL) {
*inner_global_out = inner_global; *inner_global_out = inner_global;
} }
...@@ -705,11 +724,11 @@ Handle<JSGlobalProxy> Genesis::CreateNewGlobals( ...@@ -705,11 +724,11 @@ Handle<JSGlobalProxy> Genesis::CreateNewGlobals(
// Step 2: create or re-initialize the global proxy object. // Step 2: create or re-initialize the global proxy object.
Handle<JSFunction> global_proxy_function; Handle<JSFunction> global_proxy_function;
if (global_template.IsEmpty()) { if (global_template.IsEmpty()) {
Handle<String> name = Handle<String>(HEAP->empty_symbol()); Handle<String> name = Handle<String>(heap->empty_symbol());
Handle<Code> code = Handle<Code>(Isolate::Current()->builtins()->builtin( Handle<Code> code = Handle<Code>(isolate->builtins()->builtin(
Builtins::kIllegal)); Builtins::kIllegal));
global_proxy_function = global_proxy_function =
FACTORY->NewFunction(name, JS_GLOBAL_PROXY_TYPE, factory->NewFunction(name, JS_GLOBAL_PROXY_TYPE,
JSGlobalProxy::kSize, code, true); JSGlobalProxy::kSize, code, true);
} else { } else {
Handle<ObjectTemplateInfo> data = Handle<ObjectTemplateInfo> data =
...@@ -717,11 +736,11 @@ Handle<JSGlobalProxy> Genesis::CreateNewGlobals( ...@@ -717,11 +736,11 @@ Handle<JSGlobalProxy> Genesis::CreateNewGlobals(
Handle<FunctionTemplateInfo> global_constructor( Handle<FunctionTemplateInfo> global_constructor(
FunctionTemplateInfo::cast(data->constructor())); FunctionTemplateInfo::cast(data->constructor()));
global_proxy_function = global_proxy_function =
FACTORY->CreateApiFunction(global_constructor, factory->CreateApiFunction(global_constructor,
FACTORY->OuterGlobalObject); factory->OuterGlobalObject);
} }
Handle<String> global_name = FACTORY->LookupAsciiSymbol("global"); Handle<String> global_name = factory->LookupAsciiSymbol("global");
global_proxy_function->shared()->set_instance_class_name(*global_name); global_proxy_function->shared()->set_instance_class_name(*global_name);
global_proxy_function->initial_map()->set_is_access_check_needed(true); global_proxy_function->initial_map()->set_is_access_check_needed(true);
...@@ -735,7 +754,7 @@ Handle<JSGlobalProxy> Genesis::CreateNewGlobals( ...@@ -735,7 +754,7 @@ Handle<JSGlobalProxy> Genesis::CreateNewGlobals(
Handle<JSGlobalProxy>::cast(global_object)); Handle<JSGlobalProxy>::cast(global_object));
} else { } else {
return Handle<JSGlobalProxy>::cast( return Handle<JSGlobalProxy>::cast(
FACTORY->NewJSObject(global_proxy_function, TENURED)); factory->NewJSObject(global_proxy_function, TENURED));
} }
} }
...@@ -788,9 +807,13 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, ...@@ -788,9 +807,13 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
// object reinitialization. // object reinitialization.
global_context()->set_security_token(*inner_global); global_context()->set_security_token(*inner_global);
Handle<String> object_name = Handle<String>(HEAP->Object_symbol()); Isolate* isolate = Isolate::Current();
Factory* factory = isolate->factory();
Heap* heap = isolate->heap();
Handle<String> object_name = Handle<String>(heap->Object_symbol());
SetLocalPropertyNoThrow(inner_global, object_name, SetLocalPropertyNoThrow(inner_global, object_name,
Isolate::Current()->object_function(), DONT_ENUM); isolate->object_function(), DONT_ENUM);
Handle<JSObject> global = Handle<JSObject>(global_context()->global()); Handle<JSObject> global = Handle<JSObject>(global_context()->global());
...@@ -801,20 +824,20 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, ...@@ -801,20 +824,20 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
{ // --- A r r a y --- { // --- A r r a y ---
Handle<JSFunction> array_function = Handle<JSFunction> array_function =
InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize,
Isolate::Current()->initial_object_prototype(), isolate->initial_object_prototype(),
Builtins::kArrayCode, true); Builtins::kArrayCode, true);
array_function->shared()->set_construct_stub( array_function->shared()->set_construct_stub(
Isolate::Current()->builtins()->builtin(Builtins::kArrayConstructCode)); isolate->builtins()->builtin(Builtins::kArrayConstructCode));
array_function->shared()->DontAdaptArguments(); array_function->shared()->DontAdaptArguments();
// This seems a bit hackish, but we need to make sure Array.length // This seems a bit hackish, but we need to make sure Array.length
// is 1. // is 1.
array_function->shared()->set_length(1); array_function->shared()->set_length(1);
Handle<DescriptorArray> array_descriptors = Handle<DescriptorArray> array_descriptors =
FACTORY->CopyAppendProxyDescriptor( factory->CopyAppendProxyDescriptor(
FACTORY->empty_descriptor_array(), factory->empty_descriptor_array(),
FACTORY->length_symbol(), factory->length_symbol(),
FACTORY->NewProxy(&Accessors::ArrayLength), factory->NewProxy(&Accessors::ArrayLength),
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE)); static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE));
// Cache the fast JavaScript array map // Cache the fast JavaScript array map
...@@ -831,7 +854,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, ...@@ -831,7 +854,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
{ // --- N u m b e r --- { // --- N u m b e r ---
Handle<JSFunction> number_fun = Handle<JSFunction> number_fun =
InstallFunction(global, "Number", JS_VALUE_TYPE, JSValue::kSize, InstallFunction(global, "Number", JS_VALUE_TYPE, JSValue::kSize,
Isolate::Current()->initial_object_prototype(), isolate->initial_object_prototype(),
Builtins::kIllegal, true); Builtins::kIllegal, true);
global_context()->set_number_function(*number_fun); global_context()->set_number_function(*number_fun);
} }
...@@ -839,7 +862,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, ...@@ -839,7 +862,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
{ // --- B o o l e a n --- { // --- B o o l e a n ---
Handle<JSFunction> boolean_fun = Handle<JSFunction> boolean_fun =
InstallFunction(global, "Boolean", JS_VALUE_TYPE, JSValue::kSize, InstallFunction(global, "Boolean", JS_VALUE_TYPE, JSValue::kSize,
Isolate::Current()->initial_object_prototype(), isolate->initial_object_prototype(),
Builtins::kIllegal, true); Builtins::kIllegal, true);
global_context()->set_boolean_function(*boolean_fun); global_context()->set_boolean_function(*boolean_fun);
} }
...@@ -847,18 +870,17 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, ...@@ -847,18 +870,17 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
{ // --- S t r i n g --- { // --- S t r i n g ---
Handle<JSFunction> string_fun = Handle<JSFunction> string_fun =
InstallFunction(global, "String", JS_VALUE_TYPE, JSValue::kSize, InstallFunction(global, "String", JS_VALUE_TYPE, JSValue::kSize,
Isolate::Current()->initial_object_prototype(), isolate->initial_object_prototype(),
Builtins::kIllegal, true); Builtins::kIllegal, true);
string_fun->shared()->set_construct_stub( string_fun->shared()->set_construct_stub(
Isolate::Current()->builtins()->builtin( isolate->builtins()->builtin(Builtins::kStringConstructCode));
Builtins::kStringConstructCode));
global_context()->set_string_function(*string_fun); global_context()->set_string_function(*string_fun);
// Add 'length' property to strings. // Add 'length' property to strings.
Handle<DescriptorArray> string_descriptors = Handle<DescriptorArray> string_descriptors =
FACTORY->CopyAppendProxyDescriptor( factory->CopyAppendProxyDescriptor(
FACTORY->empty_descriptor_array(), factory->empty_descriptor_array(),
FACTORY->length_symbol(), factory->length_symbol(),
FACTORY->NewProxy(&Accessors::StringLength), factory->NewProxy(&Accessors::StringLength),
static_cast<PropertyAttributes>(DONT_ENUM | static_cast<PropertyAttributes>(DONT_ENUM |
DONT_DELETE | DONT_DELETE |
READ_ONLY)); READ_ONLY));
...@@ -872,7 +894,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, ...@@ -872,7 +894,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
// Builtin functions for Date.prototype. // Builtin functions for Date.prototype.
Handle<JSFunction> date_fun = Handle<JSFunction> date_fun =
InstallFunction(global, "Date", JS_VALUE_TYPE, JSValue::kSize, InstallFunction(global, "Date", JS_VALUE_TYPE, JSValue::kSize,
Isolate::Current()->initial_object_prototype(), isolate->initial_object_prototype(),
Builtins::kIllegal, true); Builtins::kIllegal, true);
global_context()->set_date_function(*date_fun); global_context()->set_date_function(*date_fun);
...@@ -883,7 +905,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, ...@@ -883,7 +905,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
// Builtin functions for RegExp.prototype. // Builtin functions for RegExp.prototype.
Handle<JSFunction> regexp_fun = Handle<JSFunction> regexp_fun =
InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize,
Isolate::Current()->initial_object_prototype(), isolate->initial_object_prototype(),
Builtins::kIllegal, true); Builtins::kIllegal, true);
global_context()->set_regexp_function(*regexp_fun); global_context()->set_regexp_function(*regexp_fun);
...@@ -892,13 +914,13 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, ...@@ -892,13 +914,13 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
ASSERT_EQ(0, initial_map->inobject_properties()); ASSERT_EQ(0, initial_map->inobject_properties());
Handle<DescriptorArray> descriptors = FACTORY->NewDescriptorArray(5); Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(5);
PropertyAttributes final = PropertyAttributes final =
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
int enum_index = 0; int enum_index = 0;
{ {
// ECMA-262, section 15.10.7.1. // ECMA-262, section 15.10.7.1.
FieldDescriptor field(HEAP->source_symbol(), FieldDescriptor field(heap->source_symbol(),
JSRegExp::kSourceFieldIndex, JSRegExp::kSourceFieldIndex,
final, final,
enum_index++); enum_index++);
...@@ -906,7 +928,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, ...@@ -906,7 +928,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
} }
{ {
// ECMA-262, section 15.10.7.2. // ECMA-262, section 15.10.7.2.
FieldDescriptor field(HEAP->global_symbol(), FieldDescriptor field(heap->global_symbol(),
JSRegExp::kGlobalFieldIndex, JSRegExp::kGlobalFieldIndex,
final, final,
enum_index++); enum_index++);
...@@ -914,7 +936,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, ...@@ -914,7 +936,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
} }
{ {
// ECMA-262, section 15.10.7.3. // ECMA-262, section 15.10.7.3.
FieldDescriptor field(HEAP->ignore_case_symbol(), FieldDescriptor field(heap->ignore_case_symbol(),
JSRegExp::kIgnoreCaseFieldIndex, JSRegExp::kIgnoreCaseFieldIndex,
final, final,
enum_index++); enum_index++);
...@@ -922,7 +944,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, ...@@ -922,7 +944,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
} }
{ {
// ECMA-262, section 15.10.7.4. // ECMA-262, section 15.10.7.4.
FieldDescriptor field(HEAP->multiline_symbol(), FieldDescriptor field(heap->multiline_symbol(),
JSRegExp::kMultilineFieldIndex, JSRegExp::kMultilineFieldIndex,
final, final,
enum_index++); enum_index++);
...@@ -932,7 +954,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, ...@@ -932,7 +954,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
// ECMA-262, section 15.10.7.5. // ECMA-262, section 15.10.7.5.
PropertyAttributes writable = PropertyAttributes writable =
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE);
FieldDescriptor field(HEAP->last_index_symbol(), FieldDescriptor field(heap->last_index_symbol(),
JSRegExp::kLastIndexFieldIndex, JSRegExp::kLastIndexFieldIndex,
writable, writable,
enum_index++); enum_index++);
...@@ -951,13 +973,13 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, ...@@ -951,13 +973,13 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
} }
{ // -- J S O N { // -- J S O N
Handle<String> name = FACTORY->NewStringFromAscii(CStrVector("JSON")); Handle<String> name = factory->NewStringFromAscii(CStrVector("JSON"));
Handle<JSFunction> cons = FACTORY->NewFunction( Handle<JSFunction> cons = factory->NewFunction(
name, name,
FACTORY->the_hole_value()); factory->the_hole_value());
cons->SetInstancePrototype(global_context()->initial_object_prototype()); cons->SetInstancePrototype(global_context()->initial_object_prototype());
cons->SetInstanceClassName(*name); cons->SetInstanceClassName(*name);
Handle<JSObject> json_object = FACTORY->NewJSObject(cons, TENURED); Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED);
ASSERT(json_object->IsJSObject()); ASSERT(json_object->IsJSObject());
SetLocalPropertyNoThrow(global, name, json_object, DONT_ENUM); SetLocalPropertyNoThrow(global, name, json_object, DONT_ENUM);
global_context()->set_json_object(*json_object); global_context()->set_json_object(*json_object);
...@@ -967,15 +989,15 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, ...@@ -967,15 +989,15 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
// Make sure we can recognize argument objects at runtime. // Make sure we can recognize argument objects at runtime.
// This is done by introducing an anonymous function with // This is done by introducing an anonymous function with
// class_name equals 'Arguments'. // class_name equals 'Arguments'.
Handle<String> symbol = FACTORY->LookupAsciiSymbol("Arguments"); Handle<String> symbol = factory->LookupAsciiSymbol("Arguments");
Handle<Code> code = Handle<Code>( Handle<Code> code = Handle<Code>(
Isolate::Current()->builtins()->builtin(Builtins::kIllegal)); isolate->builtins()->builtin(Builtins::kIllegal));
Handle<JSObject> prototype = Handle<JSObject> prototype =
Handle<JSObject>( Handle<JSObject>(
JSObject::cast(global_context()->object_function()->prototype())); JSObject::cast(global_context()->object_function()->prototype()));
Handle<JSFunction> function = Handle<JSFunction> function =
FACTORY->NewFunctionWithPrototype(symbol, factory->NewFunctionWithPrototype(symbol,
JS_OBJECT_TYPE, JS_OBJECT_TYPE,
JSObject::kHeaderSize, JSObject::kHeaderSize,
prototype, prototype,
...@@ -984,25 +1006,25 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, ...@@ -984,25 +1006,25 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
ASSERT(!function->has_initial_map()); ASSERT(!function->has_initial_map());
function->shared()->set_instance_class_name(*symbol); function->shared()->set_instance_class_name(*symbol);
function->shared()->set_expected_nof_properties(2); function->shared()->set_expected_nof_properties(2);
Handle<JSObject> result = FACTORY->NewJSObject(function); Handle<JSObject> result = factory->NewJSObject(function);
global_context()->set_arguments_boilerplate(*result); global_context()->set_arguments_boilerplate(*result);
// Note: length must be added as the first property and // Note: length must be added as the first property and
// callee must be added as the second property. // callee must be added as the second property.
SetLocalPropertyNoThrow(result, FACTORY->length_symbol(), SetLocalPropertyNoThrow(result, factory->length_symbol(),
FACTORY->undefined_value(), factory->undefined_value(),
DONT_ENUM); DONT_ENUM);
SetLocalPropertyNoThrow(result, FACTORY->callee_symbol(), SetLocalPropertyNoThrow(result, factory->callee_symbol(),
FACTORY->undefined_value(), factory->undefined_value(),
DONT_ENUM); DONT_ENUM);
#ifdef DEBUG #ifdef DEBUG
LookupResult lookup; LookupResult lookup;
result->LocalLookup(HEAP->callee_symbol(), &lookup); result->LocalLookup(heap->callee_symbol(), &lookup);
ASSERT(lookup.IsProperty() && (lookup.type() == FIELD)); ASSERT(lookup.IsProperty() && (lookup.type() == FIELD));
ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsCalleeIndex); ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsCalleeIndex);
result->LocalLookup(HEAP->length_symbol(), &lookup); result->LocalLookup(heap->length_symbol(), &lookup);
ASSERT(lookup.IsProperty() && (lookup.type() == FIELD)); ASSERT(lookup.IsProperty() && (lookup.type() == FIELD));
ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsLengthIndex); ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsLengthIndex);
...@@ -1020,8 +1042,8 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, ...@@ -1020,8 +1042,8 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
// Create the ThrowTypeError functions. // Create the ThrowTypeError functions.
Handle<FixedArray> callee = FACTORY->NewFixedArray(2, TENURED); Handle<FixedArray> callee = factory->NewFixedArray(2, TENURED);
Handle<FixedArray> caller = FACTORY->NewFixedArray(2, TENURED); Handle<FixedArray> caller = factory->NewFixedArray(2, TENURED);
Handle<JSFunction> callee_throw = Handle<JSFunction> callee_throw =
CreateThrowTypeErrorFunction(Builtins::kStrictArgumentsCallee); CreateThrowTypeErrorFunction(Builtins::kStrictArgumentsCallee);
...@@ -1035,23 +1057,23 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, ...@@ -1035,23 +1057,23 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
caller->set(1, *caller_throw); caller->set(1, *caller_throw);
// Create the descriptor array for the arguments object. // Create the descriptor array for the arguments object.
Handle<DescriptorArray> descriptors = FACTORY->NewDescriptorArray(3); Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(3);
{ // length { // length
FieldDescriptor d(*FACTORY->length_symbol(), 0, DONT_ENUM); FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM);
descriptors->Set(0, &d); descriptors->Set(0, &d);
} }
{ // callee { // callee
CallbacksDescriptor d(*FACTORY->callee_symbol(), *callee, attributes); CallbacksDescriptor d(*factory->callee_symbol(), *callee, attributes);
descriptors->Set(1, &d); descriptors->Set(1, &d);
} }
{ // caller { // caller
CallbacksDescriptor d(*FACTORY->caller_symbol(), *caller, attributes); CallbacksDescriptor d(*factory->caller_symbol(), *caller, attributes);
descriptors->Set(2, &d); descriptors->Set(2, &d);
} }
descriptors->Sort(); descriptors->Sort();
// Create the map. Allocate one in-object field for length. // Create the map. Allocate one in-object field for length.
Handle<Map> map = FACTORY->NewMap(JS_OBJECT_TYPE, Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE,
Heap::kArgumentsObjectSizeStrict); Heap::kArgumentsObjectSizeStrict);
map->set_instance_descriptors(*descriptors); map->set_instance_descriptors(*descriptors);
map->set_function_with_prototype(true); map->set_function_with_prototype(true);
...@@ -1064,17 +1086,17 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, ...@@ -1064,17 +1086,17 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
global_context()->arguments_boilerplate()->map()->constructor()); global_context()->arguments_boilerplate()->map()->constructor());
// Allocate the arguments boilerplate object. // Allocate the arguments boilerplate object.
Handle<JSObject> result = FACTORY->NewJSObjectFromMap(map); Handle<JSObject> result = factory->NewJSObjectFromMap(map);
global_context()->set_strict_mode_arguments_boilerplate(*result); global_context()->set_strict_mode_arguments_boilerplate(*result);
// Add length property only for strict mode boilerplate. // Add length property only for strict mode boilerplate.
SetLocalPropertyNoThrow(result, FACTORY->length_symbol(), SetLocalPropertyNoThrow(result, factory->length_symbol(),
FACTORY->undefined_value(), factory->undefined_value(),
DONT_ENUM); DONT_ENUM);
#ifdef DEBUG #ifdef DEBUG
LookupResult lookup; LookupResult lookup;
result->LocalLookup(HEAP->length_symbol(), &lookup); result->LocalLookup(heap->length_symbol(), &lookup);
ASSERT(lookup.IsProperty() && (lookup.type() == FIELD)); ASSERT(lookup.IsProperty() && (lookup.type() == FIELD));
ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsLengthIndex); ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsLengthIndex);
...@@ -1089,15 +1111,15 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, ...@@ -1089,15 +1111,15 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
{ // --- context extension { // --- context extension
// Create a function for the context extension objects. // Create a function for the context extension objects.
Handle<Code> code = Handle<Code>( Handle<Code> code = Handle<Code>(
Isolate::Current()->builtins()->builtin(Builtins::kIllegal)); isolate->builtins()->builtin(Builtins::kIllegal));
Handle<JSFunction> context_extension_fun = Handle<JSFunction> context_extension_fun =
FACTORY->NewFunction(FACTORY->empty_symbol(), factory->NewFunction(factory->empty_symbol(),
JS_CONTEXT_EXTENSION_OBJECT_TYPE, JS_CONTEXT_EXTENSION_OBJECT_TYPE,
JSObject::kHeaderSize, JSObject::kHeaderSize,
code, code,
true); true);
Handle<String> name = FACTORY->LookupAsciiSymbol("context_extension"); Handle<String> name = factory->LookupAsciiSymbol("context_extension");
context_extension_fun->shared()->set_instance_class_name(*name); context_extension_fun->shared()->set_instance_class_name(*name);
global_context()->set_context_extension_function(*context_extension_fun); global_context()->set_context_extension_function(*context_extension_fun);
} }
...@@ -1106,10 +1128,10 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, ...@@ -1106,10 +1128,10 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
{ {
// Setup the call-as-function delegate. // Setup the call-as-function delegate.
Handle<Code> code = Handle<Code> code =
Handle<Code>(Isolate::Current()->builtins()->builtin( Handle<Code>(isolate->builtins()->builtin(
Builtins::kHandleApiCallAsFunction)); Builtins::kHandleApiCallAsFunction));
Handle<JSFunction> delegate = Handle<JSFunction> delegate =
FACTORY->NewFunction(FACTORY->empty_symbol(), JS_OBJECT_TYPE, factory->NewFunction(factory->empty_symbol(), JS_OBJECT_TYPE,
JSObject::kHeaderSize, code, true); JSObject::kHeaderSize, code, true);
global_context()->set_call_as_function_delegate(*delegate); global_context()->set_call_as_function_delegate(*delegate);
delegate->shared()->DontAdaptArguments(); delegate->shared()->DontAdaptArguments();
...@@ -1118,20 +1140,20 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, ...@@ -1118,20 +1140,20 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
{ {
// Setup the call-as-constructor delegate. // Setup the call-as-constructor delegate.
Handle<Code> code = Handle<Code> code =
Handle<Code>(Isolate::Current()->builtins()->builtin( Handle<Code>(isolate->builtins()->builtin(
Builtins::kHandleApiCallAsConstructor)); Builtins::kHandleApiCallAsConstructor));
Handle<JSFunction> delegate = Handle<JSFunction> delegate =
FACTORY->NewFunction(FACTORY->empty_symbol(), JS_OBJECT_TYPE, factory->NewFunction(factory->empty_symbol(), JS_OBJECT_TYPE,
JSObject::kHeaderSize, code, true); JSObject::kHeaderSize, code, true);
global_context()->set_call_as_constructor_delegate(*delegate); global_context()->set_call_as_constructor_delegate(*delegate);
delegate->shared()->DontAdaptArguments(); delegate->shared()->DontAdaptArguments();
} }
// Initialize the out of memory slot. // Initialize the out of memory slot.
global_context()->set_out_of_memory(HEAP->false_value()); global_context()->set_out_of_memory(heap->false_value());
// Initialize the data slot. // Initialize the data slot.
global_context()->set_data(HEAP->undefined_value()); global_context()->set_data(heap->undefined_value());
} }
...@@ -1170,6 +1192,7 @@ bool Genesis::CompileScriptCached(Vector<const char> name, ...@@ -1170,6 +1192,7 @@ bool Genesis::CompileScriptCached(Vector<const char> name,
v8::Extension* extension, v8::Extension* extension,
Handle<Context> top_context, Handle<Context> top_context,
bool use_runtime_context) { bool use_runtime_context) {
Factory* factory = Isolate::Current()->factory();
HandleScope scope; HandleScope scope;
Handle<SharedFunctionInfo> function_info; Handle<SharedFunctionInfo> function_info;
...@@ -1177,7 +1200,7 @@ bool Genesis::CompileScriptCached(Vector<const char> name, ...@@ -1177,7 +1200,7 @@ bool Genesis::CompileScriptCached(Vector<const char> name,
// function and insert it into the cache. // function and insert it into the cache.
if (cache == NULL || !cache->Lookup(name, &function_info)) { if (cache == NULL || !cache->Lookup(name, &function_info)) {
ASSERT(source->IsAsciiRepresentation()); ASSERT(source->IsAsciiRepresentation());
Handle<String> script_name = FACTORY->NewStringFromUtf8(name); Handle<String> script_name = factory->NewStringFromUtf8(name);
function_info = Compiler::Compile( function_info = Compiler::Compile(
source, source,
script_name, script_name,
...@@ -1200,7 +1223,7 @@ bool Genesis::CompileScriptCached(Vector<const char> name, ...@@ -1200,7 +1223,7 @@ bool Genesis::CompileScriptCached(Vector<const char> name,
? Handle<Context>(top_context->runtime_context()) ? Handle<Context>(top_context->runtime_context())
: top_context); : top_context);
Handle<JSFunction> fun = Handle<JSFunction> fun =
FACTORY->NewFunctionFromSharedFunctionInfo(function_info, context); factory->NewFunctionFromSharedFunctionInfo(function_info, context);
// Call function using either the runtime object or the global // Call function using either the runtime object or the global
// object as the receiver. Provide no parameters. // object as the receiver. Provide no parameters.
...@@ -1217,12 +1240,13 @@ bool Genesis::CompileScriptCached(Vector<const char> name, ...@@ -1217,12 +1240,13 @@ bool Genesis::CompileScriptCached(Vector<const char> name,
#define INSTALL_NATIVE(Type, name, var) \ #define INSTALL_NATIVE(Type, name, var) \
Handle<String> var##_name = FACTORY->LookupAsciiSymbol(name); \ Handle<String> var##_name = factory->LookupAsciiSymbol(name); \
global_context()->set_##var(Type::cast( \ global_context()->set_##var(Type::cast( \
global_context()->builtins()->GetPropertyNoExceptionThrown(*var##_name))); global_context()->builtins()->GetPropertyNoExceptionThrown(*var##_name)));
void Genesis::InstallNativeFunctions() { void Genesis::InstallNativeFunctions() {
Factory* factory = Isolate::Current()->factory();
HandleScope scope; HandleScope scope;
INSTALL_NATIVE(JSFunction, "CreateDate", create_date_fun); INSTALL_NATIVE(JSFunction, "CreateDate", create_date_fun);
INSTALL_NATIVE(JSFunction, "ToNumber", to_number_fun); INSTALL_NATIVE(JSFunction, "ToNumber", to_number_fun);
...@@ -1247,6 +1271,7 @@ bool Genesis::InstallNatives() { ...@@ -1247,6 +1271,7 @@ bool Genesis::InstallNatives() {
HandleScope scope; HandleScope scope;
Isolate* isolate = Isolate::Current(); Isolate* isolate = Isolate::Current();
Factory* factory = isolate->factory(); Factory* factory = isolate->factory();
Heap* heap = isolate->heap();
// Create a function for the builtins object. Allocate space for the // Create a function for the builtins object. Allocate space for the
// JavaScript builtins, a reference to the builtins object // JavaScript builtins, a reference to the builtins object
...@@ -1412,7 +1437,7 @@ bool Genesis::InstallNatives() { ...@@ -1412,7 +1437,7 @@ bool Genesis::InstallNatives() {
// Allocate the empty script. // Allocate the empty script.
Handle<Script> script = factory->NewScript(factory->empty_string()); Handle<Script> script = factory->NewScript(factory->empty_string());
script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
HEAP->public_set_empty_script(*script); heap->public_set_empty_script(*script);
} }
{ {
// Builtin function for OpaqueReference -- a JSValue-based object, // Builtin function for OpaqueReference -- a JSValue-based object,
...@@ -1560,7 +1585,7 @@ bool Genesis::InstallNatives() { ...@@ -1560,7 +1585,7 @@ bool Genesis::InstallNatives() {
int enum_index = 0; int enum_index = 0;
{ {
FieldDescriptor index_field(HEAP->index_symbol(), FieldDescriptor index_field(heap->index_symbol(),
JSRegExpResult::kIndexIndex, JSRegExpResult::kIndexIndex,
NONE, NONE,
enum_index++); enum_index++);
...@@ -1568,7 +1593,7 @@ bool Genesis::InstallNatives() { ...@@ -1568,7 +1593,7 @@ bool Genesis::InstallNatives() {
} }
{ {
FieldDescriptor input_field(HEAP->input_symbol(), FieldDescriptor input_field(heap->input_symbol(),
JSRegExpResult::kInputIndex, JSRegExpResult::kInputIndex,
NONE, NONE,
enum_index++); enum_index++);
...@@ -1596,17 +1621,18 @@ bool Genesis::InstallNatives() { ...@@ -1596,17 +1621,18 @@ bool Genesis::InstallNatives() {
static Handle<JSObject> ResolveBuiltinIdHolder( static Handle<JSObject> ResolveBuiltinIdHolder(
Handle<Context> global_context, Handle<Context> global_context,
const char* holder_expr) { const char* holder_expr) {
Factory* factory = Isolate::Current()->factory();
Handle<GlobalObject> global(global_context->global()); Handle<GlobalObject> global(global_context->global());
const char* period_pos = strchr(holder_expr, '.'); const char* period_pos = strchr(holder_expr, '.');
if (period_pos == NULL) { if (period_pos == NULL) {
return Handle<JSObject>::cast( return Handle<JSObject>::cast(
GetProperty(global, FACTORY->LookupAsciiSymbol(holder_expr))); GetProperty(global, factory->LookupAsciiSymbol(holder_expr)));
} }
ASSERT_EQ(".prototype", period_pos); ASSERT_EQ(".prototype", period_pos);
Vector<const char> property(holder_expr, Vector<const char> property(holder_expr,
static_cast<int>(period_pos - holder_expr)); static_cast<int>(period_pos - holder_expr));
Handle<JSFunction> function = Handle<JSFunction>::cast( Handle<JSFunction> function = Handle<JSFunction>::cast(
GetProperty(global, FACTORY->LookupSymbol(property))); GetProperty(global, factory->LookupSymbol(property)));
return Handle<JSObject>(JSObject::cast(function->prototype())); return Handle<JSObject>(JSObject::cast(function->prototype()));
} }
...@@ -1697,20 +1723,21 @@ bool Bootstrapper::InstallExtensions(Handle<Context> global_context, ...@@ -1697,20 +1723,21 @@ bool Bootstrapper::InstallExtensions(Handle<Context> global_context,
void Genesis::InstallSpecialObjects(Handle<Context> global_context) { void Genesis::InstallSpecialObjects(Handle<Context> global_context) {
Factory* factory = Isolate::Current()->factory();
HandleScope scope; HandleScope scope;
Handle<JSGlobalObject> js_global( Handle<JSGlobalObject> js_global(
JSGlobalObject::cast(global_context->global())); JSGlobalObject::cast(global_context->global()));
// Expose the natives in global if a name for it is specified. // Expose the natives in global if a name for it is specified.
if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) { if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) {
Handle<String> natives_string = Handle<String> natives_string =
FACTORY->LookupAsciiSymbol(FLAG_expose_natives_as); factory->LookupAsciiSymbol(FLAG_expose_natives_as);
SetLocalPropertyNoThrow(js_global, natives_string, SetLocalPropertyNoThrow(js_global, natives_string,
Handle<JSObject>(js_global->builtins()), DONT_ENUM); Handle<JSObject>(js_global->builtins()), DONT_ENUM);
} }
Handle<Object> Error = GetProperty(js_global, "Error"); Handle<Object> Error = GetProperty(js_global, "Error");
if (Error->IsJSObject()) { if (Error->IsJSObject()) {
Handle<String> name = FACTORY->LookupAsciiSymbol("stackTraceLimit"); Handle<String> name = factory->LookupAsciiSymbol("stackTraceLimit");
SetLocalPropertyNoThrow(Handle<JSObject>::cast(Error), SetLocalPropertyNoThrow(Handle<JSObject>::cast(Error),
name, name,
Handle<Smi>(Smi::FromInt(FLAG_stack_trace_limit)), Handle<Smi>(Smi::FromInt(FLAG_stack_trace_limit)),
...@@ -1731,7 +1758,7 @@ void Genesis::InstallSpecialObjects(Handle<Context> global_context) { ...@@ -1731,7 +1758,7 @@ void Genesis::InstallSpecialObjects(Handle<Context> global_context) {
global_context->security_token()); global_context->security_token());
Handle<String> debug_string = Handle<String> debug_string =
FACTORY->LookupAsciiSymbol(FLAG_expose_debug_as); factory->LookupAsciiSymbol(FLAG_expose_debug_as);
Handle<Object> global_proxy(debug->debug_context()->global_proxy()); Handle<Object> global_proxy(debug->debug_context()->global_proxy());
SetLocalPropertyNoThrow(js_global, debug_string, global_proxy, DONT_ENUM); SetLocalPropertyNoThrow(js_global, debug_string, global_proxy, DONT_ENUM);
} }
...@@ -1812,19 +1839,18 @@ bool Genesis::InstallExtension(v8::RegisteredExtension* current) { ...@@ -1812,19 +1839,18 @@ bool Genesis::InstallExtension(v8::RegisteredExtension* current) {
for (int i = 0; i < extension->dependency_count(); i++) { for (int i = 0; i < extension->dependency_count(); i++) {
if (!InstallExtension(extension->dependencies()[i])) return false; if (!InstallExtension(extension->dependencies()[i])) return false;
} }
Isolate* isolate = Isolate::Current();
Vector<const char> source = CStrVector(extension->source()); Vector<const char> source = CStrVector(extension->source());
Handle<String> source_code = FACTORY->NewStringFromAscii(source); Handle<String> source_code = isolate->factory()->NewStringFromAscii(source);
bool result = CompileScriptCached(CStrVector(extension->name()), bool result = CompileScriptCached(CStrVector(extension->name()),
source_code, source_code,
Isolate::Current()->bootstrapper()-> isolate->bootstrapper()->extensions_cache(),
extensions_cache(),
extension, extension,
Handle<Context>( Handle<Context>(isolate->context()),
Isolate::Current()->context()),
false); false);
ASSERT(Isolate::Current()->has_pending_exception() != result); ASSERT(isolate->has_pending_exception() != result);
if (!result) { if (!result) {
Isolate::Current()->clear_pending_exception(); isolate->clear_pending_exception();
} }
current->set_state(v8::INSTALLED); current->set_state(v8::INSTALLED);
return result; return result;
...@@ -1884,12 +1910,13 @@ bool Genesis::ConfigureApiObject(Handle<JSObject> object, ...@@ -1884,12 +1910,13 @@ bool Genesis::ConfigureApiObject(Handle<JSObject> object,
ASSERT(object->IsInstanceOf( ASSERT(object->IsInstanceOf(
FunctionTemplateInfo::cast(object_template->constructor()))); FunctionTemplateInfo::cast(object_template->constructor())));
Isolate* isolate = Isolate::Current();
bool pending_exception = false; bool pending_exception = false;
Handle<JSObject> obj = Handle<JSObject> obj =
Execution::InstantiateObject(object_template, &pending_exception); Execution::InstantiateObject(object_template, &pending_exception);
if (pending_exception) { if (pending_exception) {
ASSERT(Isolate::Current()->has_pending_exception()); ASSERT(isolate->has_pending_exception());
Isolate::Current()->clear_pending_exception(); isolate->clear_pending_exception();
return false; return false;
} }
TransferObject(obj, object); TransferObject(obj, object);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment