Isolates: Cleanup usage of FACTORY in code stubs and bootstrapper.

Review URL: http://codereview.chromium.org/6720014

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7611 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 26e2d5a8
...@@ -3707,6 +3707,7 @@ Persistent<Context> v8::Context::New( ...@@ -3707,6 +3707,7 @@ Persistent<Context> v8::Context::New(
// Create the environment. // Create the environment.
env = isolate->bootstrapper()->CreateEnvironment( env = isolate->bootstrapper()->CreateEnvironment(
isolate,
Utils::OpenHandle(*global_object), Utils::OpenHandle(*global_object),
proxy_template, proxy_template,
extensions); extensions);
......
...@@ -3678,7 +3678,7 @@ void InstanceofStub::Generate(MacroAssembler* masm) { ...@@ -3678,7 +3678,7 @@ void InstanceofStub::Generate(MacroAssembler* masm) {
__ b(ne, &slow); __ b(ne, &slow);
// Null is not instance of anything. // Null is not instance of anything.
__ cmp(scratch, Operand(FACTORY->null_value())); __ cmp(scratch, Operand(masm->isolate()->factory()->null_value()));
__ b(ne, &object_not_null); __ b(ne, &object_not_null);
__ mov(r0, Operand(Smi::FromInt(1))); __ mov(r0, Operand(Smi::FromInt(1)));
__ Ret(HasArgsInRegisters() ? 0 : 2); __ Ret(HasArgsInRegisters() ? 0 : 2);
...@@ -4176,7 +4176,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { ...@@ -4176,7 +4176,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
__ bind(&failure); __ bind(&failure);
// For failure and exception return null. // For failure and exception return null.
__ mov(r0, Operand(FACTORY->null_value())); __ mov(r0, Operand(masm->isolate()->factory()->null_value()));
__ add(sp, sp, Operand(4 * kPointerSize)); __ add(sp, sp, Operand(4 * kPointerSize));
__ Ret(); __ Ret();
...@@ -4247,6 +4247,8 @@ void RegExpConstructResultStub::Generate(MacroAssembler* masm) { ...@@ -4247,6 +4247,8 @@ void RegExpConstructResultStub::Generate(MacroAssembler* masm) {
const int kMaxInlineLength = 100; const int kMaxInlineLength = 100;
Label slowcase; Label slowcase;
Label done; Label done;
Factory* factory = masm->isolate()->factory();
__ ldr(r1, MemOperand(sp, kPointerSize * 2)); __ ldr(r1, MemOperand(sp, kPointerSize * 2));
STATIC_ASSERT(kSmiTag == 0); STATIC_ASSERT(kSmiTag == 0);
STATIC_ASSERT(kSmiTagSize == 1); STATIC_ASSERT(kSmiTagSize == 1);
...@@ -4281,7 +4283,7 @@ void RegExpConstructResultStub::Generate(MacroAssembler* masm) { ...@@ -4281,7 +4283,7 @@ void RegExpConstructResultStub::Generate(MacroAssembler* masm) {
// Interleave operations for better latency. // Interleave operations for better latency.
__ ldr(r2, ContextOperand(cp, Context::GLOBAL_INDEX)); __ ldr(r2, ContextOperand(cp, Context::GLOBAL_INDEX));
__ add(r3, r0, Operand(JSRegExpResult::kSize)); __ add(r3, r0, Operand(JSRegExpResult::kSize));
__ mov(r4, Operand(FACTORY->empty_fixed_array())); __ mov(r4, Operand(factory->empty_fixed_array()));
__ ldr(r2, FieldMemOperand(r2, GlobalObject::kGlobalContextOffset)); __ ldr(r2, FieldMemOperand(r2, GlobalObject::kGlobalContextOffset));
__ str(r3, FieldMemOperand(r0, JSObject::kElementsOffset)); __ str(r3, FieldMemOperand(r0, JSObject::kElementsOffset));
__ ldr(r2, ContextOperand(r2, Context::REGEXP_RESULT_MAP_INDEX)); __ ldr(r2, ContextOperand(r2, Context::REGEXP_RESULT_MAP_INDEX));
...@@ -4302,13 +4304,13 @@ void RegExpConstructResultStub::Generate(MacroAssembler* masm) { ...@@ -4302,13 +4304,13 @@ void RegExpConstructResultStub::Generate(MacroAssembler* masm) {
// r5: Number of elements in array, untagged. // r5: Number of elements in array, untagged.
// Set map. // Set map.
__ mov(r2, Operand(FACTORY->fixed_array_map())); __ mov(r2, Operand(factory->fixed_array_map()));
__ str(r2, FieldMemOperand(r3, HeapObject::kMapOffset)); __ str(r2, FieldMemOperand(r3, HeapObject::kMapOffset));
// Set FixedArray length. // Set FixedArray length.
__ mov(r6, Operand(r5, LSL, kSmiTagSize)); __ mov(r6, Operand(r5, LSL, kSmiTagSize));
__ str(r6, FieldMemOperand(r3, FixedArray::kLengthOffset)); __ str(r6, FieldMemOperand(r3, FixedArray::kLengthOffset));
// Fill contents of fixed-array with the-hole. // Fill contents of fixed-array with the-hole.
__ mov(r2, Operand(FACTORY->the_hole_value())); __ mov(r2, Operand(factory->the_hole_value()));
__ add(r3, r3, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); __ add(r3, r3, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
// Fill fixed array elements with hole. // Fill fixed array elements with hole.
// r0: JSArray, tagged. // r0: JSArray, tagged.
......
// Copyright 2006-2008 the V8 project authors. All rights reserved. // Copyright 2011 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
...@@ -141,7 +141,8 @@ void Bootstrapper::TearDown() { ...@@ -141,7 +141,8 @@ void Bootstrapper::TearDown() {
class Genesis BASE_EMBEDDED { class Genesis BASE_EMBEDDED {
public: public:
Genesis(Handle<Object> global_object, Genesis(Isolate* isolate,
Handle<Object> global_object,
v8::Handle<v8::ObjectTemplate> global_template, v8::Handle<v8::ObjectTemplate> global_template,
v8::ExtensionConfiguration* extensions); v8::ExtensionConfiguration* extensions);
~Genesis() { } ~Genesis() { }
...@@ -150,8 +151,13 @@ class Genesis BASE_EMBEDDED { ...@@ -150,8 +151,13 @@ class Genesis BASE_EMBEDDED {
Genesis* previous() { return previous_; } Genesis* previous() { return previous_; }
Isolate* isolate() const { return isolate_; }
Factory* factory() const { return isolate_->factory(); }
Heap* heap() const { return isolate_->heap(); }
private: private:
Handle<Context> global_context_; Handle<Context> global_context_;
Isolate* isolate_;
// There may be more than one active genesis object: When GC is // There may be more than one active genesis object: When GC is
// triggered during environment creation there may be weak handle // triggered during environment creation there may be weak handle
...@@ -163,7 +169,7 @@ class Genesis BASE_EMBEDDED { ...@@ -163,7 +169,7 @@ class Genesis BASE_EMBEDDED {
// Creates some basic objects. Used for creating a context from scratch. // Creates some basic objects. Used for creating a context from scratch.
void CreateRoots(); void CreateRoots();
// Creates the empty function. Used for creating a context from scratch. // Creates the empty function. Used for creating a context from scratch.
Handle<JSFunction> CreateEmptyFunction(); Handle<JSFunction> CreateEmptyFunction(Isolate* isolate);
// Creates the ThrowTypeError function. ECMA 5th Ed. 13.2.3 // Creates the ThrowTypeError function. ECMA 5th Ed. 13.2.3
Handle<JSFunction> CreateThrowTypeErrorFunction(Builtins::Name builtin); Handle<JSFunction> CreateThrowTypeErrorFunction(Builtins::Name builtin);
...@@ -239,7 +245,7 @@ class Genesis BASE_EMBEDDED { ...@@ -239,7 +245,7 @@ class Genesis BASE_EMBEDDED {
Handle<FixedArray> arguments, Handle<FixedArray> arguments,
Handle<FixedArray> caller); Handle<FixedArray> caller);
static bool CompileBuiltin(int index); static bool CompileBuiltin(Isolate* isolate, int index);
static bool CompileNative(Vector<const char> name, Handle<String> source); static bool CompileNative(Vector<const char> name, Handle<String> source);
static bool CompileScriptCached(Vector<const char> name, static bool CompileScriptCached(Vector<const char> name,
Handle<String> source, Handle<String> source,
...@@ -269,12 +275,13 @@ void Bootstrapper::Iterate(ObjectVisitor* v) { ...@@ -269,12 +275,13 @@ void Bootstrapper::Iterate(ObjectVisitor* v) {
Handle<Context> Bootstrapper::CreateEnvironment( Handle<Context> Bootstrapper::CreateEnvironment(
Isolate* isolate,
Handle<Object> global_object, Handle<Object> global_object,
v8::Handle<v8::ObjectTemplate> global_template, v8::Handle<v8::ObjectTemplate> global_template,
v8::ExtensionConfiguration* extensions) { v8::ExtensionConfiguration* extensions) {
HandleScope scope; HandleScope scope;
Handle<Context> env; Handle<Context> env;
Genesis genesis(global_object, global_template, extensions); Genesis genesis(isolate, global_object, global_template, extensions);
env = genesis.result(); env = genesis.result();
if (!env.is_null()) { if (!env.is_null()) {
if (InstallExtensions(env, extensions)) { if (InstallExtensions(env, extensions)) {
...@@ -287,15 +294,16 @@ Handle<Context> Bootstrapper::CreateEnvironment( ...@@ -287,15 +294,16 @@ Handle<Context> Bootstrapper::CreateEnvironment(
static void SetObjectPrototype(Handle<JSObject> object, Handle<Object> proto) { static void SetObjectPrototype(Handle<JSObject> object, Handle<Object> proto) {
// object.__proto__ = proto; // object.__proto__ = proto;
Factory* factory = object->GetIsolate()->factory();
Handle<Map> old_to_map = Handle<Map>(object->map()); Handle<Map> old_to_map = Handle<Map>(object->map());
Handle<Map> new_to_map = FACTORY->CopyMapDropTransitions(old_to_map); Handle<Map> new_to_map = factory->CopyMapDropTransitions(old_to_map);
new_to_map->set_prototype(*proto); new_to_map->set_prototype(*proto);
object->set_map(*new_to_map); object->set_map(*new_to_map);
} }
void Bootstrapper::DetachGlobal(Handle<Context> env) { void Bootstrapper::DetachGlobal(Handle<Context> env) {
Factory* factory = Isolate::Current()->factory(); Factory* factory = env->GetIsolate()->factory();
JSGlobalProxy::cast(env->global_proxy())->set_context(*factory->null_value()); 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());
...@@ -322,7 +330,7 @@ static Handle<JSFunction> InstallFunction(Handle<JSObject> target, ...@@ -322,7 +330,7 @@ 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) {
Isolate* isolate = Isolate::Current(); Isolate* isolate = target->GetIsolate();
Factory* factory = isolate->factory(); Factory* factory = isolate->factory();
Handle<String> symbol = factory->LookupAsciiSymbol(name); Handle<String> symbol = factory->LookupAsciiSymbol(name);
Handle<Code> call_code = Handle<Code>(isolate->builtins()->builtin(call)); Handle<Code> call_code = Handle<Code>(isolate->builtins()->builtin(call));
...@@ -344,30 +352,29 @@ static Handle<JSFunction> InstallFunction(Handle<JSObject> target, ...@@ -344,30 +352,29 @@ 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) {
...@@ -375,8 +382,8 @@ Handle<DescriptorArray> Genesis::ComputeFunctionInstanceDescriptor( ...@@ -375,8 +382,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();
...@@ -385,7 +392,7 @@ Handle<DescriptorArray> Genesis::ComputeFunctionInstanceDescriptor( ...@@ -385,7 +392,7 @@ Handle<DescriptorArray> Genesis::ComputeFunctionInstanceDescriptor(
Handle<Map> Genesis::CreateFunctionMap(PrototypePropertyMode prototype_mode) { Handle<Map> Genesis::CreateFunctionMap(PrototypePropertyMode prototype_mode) {
Handle<Map> map = FACTORY->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize);
Handle<DescriptorArray> descriptors = Handle<DescriptorArray> descriptors =
ComputeFunctionInstanceDescriptor(prototype_mode); ComputeFunctionInstanceDescriptor(prototype_mode);
map->set_instance_descriptors(*descriptors); map->set_instance_descriptors(*descriptors);
...@@ -394,7 +401,7 @@ Handle<Map> Genesis::CreateFunctionMap(PrototypePropertyMode prototype_mode) { ...@@ -394,7 +401,7 @@ Handle<Map> Genesis::CreateFunctionMap(PrototypePropertyMode prototype_mode) {
} }
Handle<JSFunction> Genesis::CreateEmptyFunction() { Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) {
// Allocate the map for function instances. Maps are allocated first and their // Allocate the map for function instances. Maps are allocated first and their
// prototypes patched later, once empty function is created. // prototypes patched later, once empty function is created.
...@@ -422,7 +429,6 @@ Handle<JSFunction> Genesis::CreateEmptyFunction() { ...@@ -422,7 +429,6 @@ Handle<JSFunction> Genesis::CreateEmptyFunction() {
function_instance_map_writable_prototype_ = function_instance_map_writable_prototype_ =
CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE); CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE);
Isolate* isolate = Isolate::Current();
Factory* factory = isolate->factory(); Factory* factory = isolate->factory();
Heap* heap = isolate->heap(); Heap* heap = isolate->heap();
...@@ -491,28 +497,29 @@ Handle<DescriptorArray> Genesis::ComputeStrictFunctionInstanceDescriptor( ...@@ -491,28 +497,29 @@ 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);
} }
...@@ -521,8 +528,8 @@ Handle<DescriptorArray> Genesis::ComputeStrictFunctionInstanceDescriptor( ...@@ -521,8 +528,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);
} }
...@@ -534,14 +541,11 @@ Handle<DescriptorArray> Genesis::ComputeStrictFunctionInstanceDescriptor( ...@@ -534,14 +541,11 @@ 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) {
Isolate* isolate = Isolate::Current(); Handle<String> name = factory()->LookupAsciiSymbol("ThrowTypeError");
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->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,7 +563,7 @@ Handle<Map> Genesis::CreateStrictModeFunctionMap( ...@@ -559,7 +563,7 @@ Handle<Map> Genesis::CreateStrictModeFunctionMap(
Handle<JSFunction> empty_function, Handle<JSFunction> empty_function,
Handle<FixedArray> arguments_callbacks, Handle<FixedArray> arguments_callbacks,
Handle<FixedArray> caller_callbacks) { Handle<FixedArray> caller_callbacks) {
Handle<Map> map = FACTORY->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize); Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize);
Handle<DescriptorArray> descriptors = Handle<DescriptorArray> descriptors =
ComputeStrictFunctionInstanceDescriptor(prototype_mode, ComputeStrictFunctionInstanceDescriptor(prototype_mode,
arguments_callbacks, arguments_callbacks,
...@@ -574,7 +578,7 @@ Handle<Map> Genesis::CreateStrictModeFunctionMap( ...@@ -574,7 +578,7 @@ 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.
Factory* factory = Isolate::Current()->factory(); Factory* factory = empty->GetIsolate()->factory();
Handle<FixedArray> arguments = factory->NewFixedArray(2, TENURED); Handle<FixedArray> arguments = factory->NewFixedArray(2, TENURED);
Handle<FixedArray> caller = factory->NewFixedArray(2, TENURED); Handle<FixedArray> caller = factory->NewFixedArray(2, TENURED);
...@@ -623,7 +627,7 @@ void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) { ...@@ -623,7 +627,7 @@ void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) {
static void AddToWeakGlobalContextList(Context* context) { static void AddToWeakGlobalContextList(Context* context) {
ASSERT(context->IsGlobalContext()); ASSERT(context->IsGlobalContext());
Heap* heap = Isolate::Current()->heap(); Heap* heap = context->GetIsolate()->heap();
#ifdef DEBUG #ifdef DEBUG
{ // NOLINT { // NOLINT
ASSERT(context->get(Context::NEXT_CONTEXT_LINK)->IsUndefined()); ASSERT(context->get(Context::NEXT_CONTEXT_LINK)->IsUndefined());
...@@ -641,15 +645,14 @@ static void AddToWeakGlobalContextList(Context* context) { ...@@ -641,15 +645,14 @@ static void AddToWeakGlobalContextList(Context* context) {
void Genesis::CreateRoots() { void Genesis::CreateRoots() {
Isolate* isolate = Isolate::Current();
// Allocate the global context FixedArray first and then patch the // Allocate the global context FixedArray first and then patch the
// closure and extension object later (we need the empty function // closure and extension object later (we need the empty function
// and the global object, but in order to create those, we need the // and the global object, but in order to create those, we need the
// global context). // global context).
global_context_ = Handle<Context>::cast(isolate->global_handles()->Create( global_context_ = Handle<Context>::cast(isolate()->global_handles()->Create(
*isolate->factory()->NewGlobalContext())); *factory()->NewGlobalContext()));
AddToWeakGlobalContextList(*global_context_); AddToWeakGlobalContextList(*global_context_);
isolate->set_context(*global_context()); isolate()->set_context(*global_context());
// Allocate the message listeners object. // Allocate the message listeners object.
{ {
...@@ -692,17 +695,13 @@ Handle<JSGlobalProxy> Genesis::CreateNewGlobals( ...@@ -692,17 +695,13 @@ 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->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.
Handle<JSObject> prototype = Handle<JSObject> prototype =
...@@ -710,20 +709,20 @@ Handle<JSGlobalProxy> Genesis::CreateNewGlobals( ...@@ -710,20 +709,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->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;
} }
...@@ -731,23 +730,23 @@ Handle<JSGlobalProxy> Genesis::CreateNewGlobals( ...@@ -731,23 +730,23 @@ 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->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 =
v8::Utils::OpenHandle(*global_template); v8::Utils::OpenHandle(*global_template);
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);
...@@ -761,7 +760,7 @@ Handle<JSGlobalProxy> Genesis::CreateNewGlobals( ...@@ -761,7 +760,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));
} }
} }
...@@ -786,7 +785,7 @@ void Genesis::HookUpInnerGlobal(Handle<GlobalObject> inner_global) { ...@@ -786,7 +785,7 @@ void Genesis::HookUpInnerGlobal(Handle<GlobalObject> inner_global) {
static const PropertyAttributes attributes = static const PropertyAttributes attributes =
static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
ForceSetProperty(builtins_global, ForceSetProperty(builtins_global,
FACTORY->LookupAsciiSymbol("global"), factory()->LookupAsciiSymbol("global"),
inner_global, inner_global,
attributes); attributes);
// Setup the reference from the global object to the builtins object. // Setup the reference from the global object to the builtins object.
...@@ -814,7 +813,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, ...@@ -814,7 +813,7 @@ 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);
Isolate* isolate = Isolate::Current(); Isolate* isolate = inner_global->GetIsolate();
Factory* factory = isolate->factory(); Factory* factory = isolate->factory();
Heap* heap = isolate->heap(); Heap* heap = isolate->heap();
...@@ -1164,17 +1163,17 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global, ...@@ -1164,17 +1163,17 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
} }
bool Genesis::CompileBuiltin(int index) { bool Genesis::CompileBuiltin(Isolate* isolate, int index) {
Vector<const char> name = Natives::GetScriptName(index); Vector<const char> name = Natives::GetScriptName(index);
Handle<String> source_code = Handle<String> source_code =
Isolate::Current()->bootstrapper()->NativesSourceLookup(index); isolate->bootstrapper()->NativesSourceLookup(index);
return CompileNative(name, source_code); return CompileNative(name, source_code);
} }
bool Genesis::CompileNative(Vector<const char> name, Handle<String> source) { bool Genesis::CompileNative(Vector<const char> name, Handle<String> source) {
HandleScope scope; HandleScope scope;
Isolate* isolate = Isolate::Current(); Isolate* isolate = source->GetIsolate();
#ifdef ENABLE_DEBUGGER_SUPPORT #ifdef ENABLE_DEBUGGER_SUPPORT
isolate->debugger()->set_compiling_natives(true); isolate->debugger()->set_compiling_natives(true);
#endif #endif
...@@ -1199,7 +1198,7 @@ bool Genesis::CompileScriptCached(Vector<const char> name, ...@@ -1199,7 +1198,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(); Factory* factory = source->GetIsolate()->factory();
HandleScope scope; HandleScope scope;
Handle<SharedFunctionInfo> function_info; Handle<SharedFunctionInfo> function_info;
...@@ -1247,14 +1246,13 @@ bool Genesis::CompileScriptCached(Vector<const char> name, ...@@ -1247,14 +1246,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); \
Object* var##_native = \ Object* var##_native = \
global_context()->builtins()->GetPropertyNoExceptionThrown(*var##_name); \ global_context()->builtins()->GetPropertyNoExceptionThrown(*var##_name); \
global_context()->set_##var(Type::cast(var##_native)); global_context()->set_##var(Type::cast(var##_native));
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);
...@@ -1277,25 +1275,23 @@ void Genesis::InstallNativeFunctions() { ...@@ -1277,25 +1275,23 @@ void Genesis::InstallNativeFunctions() {
bool Genesis::InstallNatives() { bool Genesis::InstallNatives() {
HandleScope scope; HandleScope scope;
Isolate* isolate = Isolate::Current();
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
// (itself) and a reference to the global_context directly in the object. // (itself) and a reference to the global_context directly in the object.
Handle<Code> code = Handle<Code>( Handle<Code> code = Handle<Code>(
isolate->builtins()->builtin(Builtins::kIllegal)); isolate()->builtins()->builtin(Builtins::kIllegal));
Handle<JSFunction> builtins_fun = Handle<JSFunction> builtins_fun =
factory->NewFunction(factory->empty_symbol(), JS_BUILTINS_OBJECT_TYPE, factory()->NewFunction(factory()->empty_symbol(),
JSBuiltinsObject::kSize, code, true); JS_BUILTINS_OBJECT_TYPE,
JSBuiltinsObject::kSize, code, true);
Handle<String> name = factory->LookupAsciiSymbol("builtins"); Handle<String> name = factory()->LookupAsciiSymbol("builtins");
builtins_fun->shared()->set_instance_class_name(*name); builtins_fun->shared()->set_instance_class_name(*name);
// Allocate the builtins object. // Allocate the builtins object.
Handle<JSBuiltinsObject> builtins = Handle<JSBuiltinsObject> builtins =
Handle<JSBuiltinsObject>::cast(factory->NewGlobalObject(builtins_fun)); Handle<JSBuiltinsObject>::cast(factory()->NewGlobalObject(builtins_fun));
builtins->set_builtins(*builtins); builtins->set_builtins(*builtins);
builtins->set_global_context(*global_context()); builtins->set_global_context(*global_context());
builtins->set_global_receiver(*builtins); builtins->set_global_receiver(*builtins);
...@@ -1306,7 +1302,7 @@ bool Genesis::InstallNatives() { ...@@ -1306,7 +1302,7 @@ bool Genesis::InstallNatives() {
// global object. // global object.
static const PropertyAttributes attributes = static const PropertyAttributes attributes =
static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
Handle<String> global_symbol = factory->LookupAsciiSymbol("global"); Handle<String> global_symbol = factory()->LookupAsciiSymbol("global");
Handle<Object> global_obj(global_context()->global()); Handle<Object> global_obj(global_context()->global());
SetLocalPropertyNoThrow(builtins, global_symbol, global_obj, attributes); SetLocalPropertyNoThrow(builtins, global_symbol, global_obj, attributes);
...@@ -1315,12 +1311,13 @@ bool Genesis::InstallNatives() { ...@@ -1315,12 +1311,13 @@ bool Genesis::InstallNatives() {
// Create a bridge function that has context in the global context. // Create a bridge function that has context in the global context.
Handle<JSFunction> bridge = Handle<JSFunction> bridge =
factory->NewFunction(factory->empty_symbol(), factory->undefined_value()); factory()->NewFunction(factory()->empty_symbol(),
ASSERT(bridge->context() == *isolate->global_context()); factory()->undefined_value());
ASSERT(bridge->context() == *isolate()->global_context());
// Allocate the builtins context. // Allocate the builtins context.
Handle<Context> context = Handle<Context> context =
factory->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge); factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge);
context->set_global(*builtins); // override builtins global object context->set_global(*builtins); // override builtins global object
global_context()->set_runtime_context(*context); global_context()->set_runtime_context(*context);
...@@ -1329,113 +1326,113 @@ bool Genesis::InstallNatives() { ...@@ -1329,113 +1326,113 @@ bool Genesis::InstallNatives() {
// Builtin functions for Script. // Builtin functions for Script.
Handle<JSFunction> script_fun = Handle<JSFunction> script_fun =
InstallFunction(builtins, "Script", JS_VALUE_TYPE, JSValue::kSize, InstallFunction(builtins, "Script", JS_VALUE_TYPE, JSValue::kSize,
isolate->initial_object_prototype(), isolate()->initial_object_prototype(),
Builtins::kIllegal, false); Builtins::kIllegal, false);
Handle<JSObject> prototype = Handle<JSObject> prototype =
factory->NewJSObject(isolate->object_function(), TENURED); factory()->NewJSObject(isolate()->object_function(), TENURED);
SetPrototype(script_fun, prototype); SetPrototype(script_fun, prototype);
global_context()->set_script_function(*script_fun); global_context()->set_script_function(*script_fun);
// Add 'source' and 'data' property to scripts. // Add 'source' and 'data' property to scripts.
PropertyAttributes common_attributes = PropertyAttributes common_attributes =
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
Handle<Proxy> proxy_source = factory->NewProxy(&Accessors::ScriptSource); Handle<Proxy> proxy_source = factory()->NewProxy(&Accessors::ScriptSource);
Handle<DescriptorArray> script_descriptors = Handle<DescriptorArray> script_descriptors =
factory->CopyAppendProxyDescriptor( factory()->CopyAppendProxyDescriptor(
factory->empty_descriptor_array(), factory()->empty_descriptor_array(),
factory->LookupAsciiSymbol("source"), factory()->LookupAsciiSymbol("source"),
proxy_source, proxy_source,
common_attributes); common_attributes);
Handle<Proxy> proxy_name = factory->NewProxy(&Accessors::ScriptName); Handle<Proxy> proxy_name = factory()->NewProxy(&Accessors::ScriptName);
script_descriptors = script_descriptors =
factory->CopyAppendProxyDescriptor( factory()->CopyAppendProxyDescriptor(
script_descriptors, script_descriptors,
factory->LookupAsciiSymbol("name"), factory()->LookupAsciiSymbol("name"),
proxy_name, proxy_name,
common_attributes); common_attributes);
Handle<Proxy> proxy_id = factory->NewProxy(&Accessors::ScriptId); Handle<Proxy> proxy_id = factory()->NewProxy(&Accessors::ScriptId);
script_descriptors = script_descriptors =
factory->CopyAppendProxyDescriptor( factory()->CopyAppendProxyDescriptor(
script_descriptors, script_descriptors,
factory->LookupAsciiSymbol("id"), factory()->LookupAsciiSymbol("id"),
proxy_id, proxy_id,
common_attributes); common_attributes);
Handle<Proxy> proxy_line_offset = Handle<Proxy> proxy_line_offset =
factory->NewProxy(&Accessors::ScriptLineOffset); factory()->NewProxy(&Accessors::ScriptLineOffset);
script_descriptors = script_descriptors =
factory->CopyAppendProxyDescriptor( factory()->CopyAppendProxyDescriptor(
script_descriptors, script_descriptors,
factory->LookupAsciiSymbol("line_offset"), factory()->LookupAsciiSymbol("line_offset"),
proxy_line_offset, proxy_line_offset,
common_attributes); common_attributes);
Handle<Proxy> proxy_column_offset = Handle<Proxy> proxy_column_offset =
factory->NewProxy(&Accessors::ScriptColumnOffset); factory()->NewProxy(&Accessors::ScriptColumnOffset);
script_descriptors = script_descriptors =
factory->CopyAppendProxyDescriptor( factory()->CopyAppendProxyDescriptor(
script_descriptors, script_descriptors,
factory->LookupAsciiSymbol("column_offset"), factory()->LookupAsciiSymbol("column_offset"),
proxy_column_offset, proxy_column_offset,
common_attributes); common_attributes);
Handle<Proxy> proxy_data = factory->NewProxy(&Accessors::ScriptData); Handle<Proxy> proxy_data = factory()->NewProxy(&Accessors::ScriptData);
script_descriptors = script_descriptors =
factory->CopyAppendProxyDescriptor( factory()->CopyAppendProxyDescriptor(
script_descriptors, script_descriptors,
factory->LookupAsciiSymbol("data"), factory()->LookupAsciiSymbol("data"),
proxy_data, proxy_data,
common_attributes); common_attributes);
Handle<Proxy> proxy_type = factory->NewProxy(&Accessors::ScriptType); Handle<Proxy> proxy_type = factory()->NewProxy(&Accessors::ScriptType);
script_descriptors = script_descriptors =
factory->CopyAppendProxyDescriptor( factory()->CopyAppendProxyDescriptor(
script_descriptors, script_descriptors,
factory->LookupAsciiSymbol("type"), factory()->LookupAsciiSymbol("type"),
proxy_type, proxy_type,
common_attributes); common_attributes);
Handle<Proxy> proxy_compilation_type = Handle<Proxy> proxy_compilation_type =
factory->NewProxy(&Accessors::ScriptCompilationType); factory()->NewProxy(&Accessors::ScriptCompilationType);
script_descriptors = script_descriptors =
factory->CopyAppendProxyDescriptor( factory()->CopyAppendProxyDescriptor(
script_descriptors, script_descriptors,
factory->LookupAsciiSymbol("compilation_type"), factory()->LookupAsciiSymbol("compilation_type"),
proxy_compilation_type, proxy_compilation_type,
common_attributes); common_attributes);
Handle<Proxy> proxy_line_ends = Handle<Proxy> proxy_line_ends =
factory->NewProxy(&Accessors::ScriptLineEnds); factory()->NewProxy(&Accessors::ScriptLineEnds);
script_descriptors = script_descriptors =
factory->CopyAppendProxyDescriptor( factory()->CopyAppendProxyDescriptor(
script_descriptors, script_descriptors,
factory->LookupAsciiSymbol("line_ends"), factory()->LookupAsciiSymbol("line_ends"),
proxy_line_ends, proxy_line_ends,
common_attributes); common_attributes);
Handle<Proxy> proxy_context_data = Handle<Proxy> proxy_context_data =
factory->NewProxy(&Accessors::ScriptContextData); factory()->NewProxy(&Accessors::ScriptContextData);
script_descriptors = script_descriptors =
factory->CopyAppendProxyDescriptor( factory()->CopyAppendProxyDescriptor(
script_descriptors, script_descriptors,
factory->LookupAsciiSymbol("context_data"), factory()->LookupAsciiSymbol("context_data"),
proxy_context_data, proxy_context_data,
common_attributes); common_attributes);
Handle<Proxy> proxy_eval_from_script = Handle<Proxy> proxy_eval_from_script =
factory->NewProxy(&Accessors::ScriptEvalFromScript); factory()->NewProxy(&Accessors::ScriptEvalFromScript);
script_descriptors = script_descriptors =
factory->CopyAppendProxyDescriptor( factory()->CopyAppendProxyDescriptor(
script_descriptors, script_descriptors,
factory->LookupAsciiSymbol("eval_from_script"), factory()->LookupAsciiSymbol("eval_from_script"),
proxy_eval_from_script, proxy_eval_from_script,
common_attributes); common_attributes);
Handle<Proxy> proxy_eval_from_script_position = Handle<Proxy> proxy_eval_from_script_position =
factory->NewProxy(&Accessors::ScriptEvalFromScriptPosition); factory()->NewProxy(&Accessors::ScriptEvalFromScriptPosition);
script_descriptors = script_descriptors =
factory->CopyAppendProxyDescriptor( factory()->CopyAppendProxyDescriptor(
script_descriptors, script_descriptors,
factory->LookupAsciiSymbol("eval_from_script_position"), factory()->LookupAsciiSymbol("eval_from_script_position"),
proxy_eval_from_script_position, proxy_eval_from_script_position,
common_attributes); common_attributes);
Handle<Proxy> proxy_eval_from_function_name = Handle<Proxy> proxy_eval_from_function_name =
factory->NewProxy(&Accessors::ScriptEvalFromFunctionName); factory()->NewProxy(&Accessors::ScriptEvalFromFunctionName);
script_descriptors = script_descriptors =
factory->CopyAppendProxyDescriptor( factory()->CopyAppendProxyDescriptor(
script_descriptors, script_descriptors,
factory->LookupAsciiSymbol("eval_from_function_name"), factory()->LookupAsciiSymbol("eval_from_function_name"),
proxy_eval_from_function_name, proxy_eval_from_function_name,
common_attributes); common_attributes);
...@@ -1443,9 +1440,9 @@ bool Genesis::InstallNatives() { ...@@ -1443,9 +1440,9 @@ bool Genesis::InstallNatives() {
script_map->set_instance_descriptors(*script_descriptors); script_map->set_instance_descriptors(*script_descriptors);
// 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,
...@@ -1454,10 +1451,10 @@ bool Genesis::InstallNatives() { ...@@ -1454,10 +1451,10 @@ bool Genesis::InstallNatives() {
Handle<JSFunction> opaque_reference_fun = Handle<JSFunction> opaque_reference_fun =
InstallFunction(builtins, "OpaqueReference", JS_VALUE_TYPE, InstallFunction(builtins, "OpaqueReference", JS_VALUE_TYPE,
JSValue::kSize, JSValue::kSize,
isolate->initial_object_prototype(), isolate()->initial_object_prototype(),
Builtins::kIllegal, false); Builtins::kIllegal, false);
Handle<JSObject> prototype = Handle<JSObject> prototype =
factory->NewJSObject(isolate->object_function(), TENURED); factory()->NewJSObject(isolate()->object_function(), TENURED);
SetPrototype(opaque_reference_fun, prototype); SetPrototype(opaque_reference_fun, prototype);
global_context()->set_opaque_reference_function(*opaque_reference_fun); global_context()->set_opaque_reference_function(*opaque_reference_fun);
} }
...@@ -1476,23 +1473,23 @@ bool Genesis::InstallNatives() { ...@@ -1476,23 +1473,23 @@ bool Genesis::InstallNatives() {
"InternalArray", "InternalArray",
JS_ARRAY_TYPE, JS_ARRAY_TYPE,
JSArray::kSize, JSArray::kSize,
isolate->initial_object_prototype(), isolate()->initial_object_prototype(),
Builtins::kArrayCode, Builtins::kArrayCode,
true); true);
Handle<JSObject> prototype = Handle<JSObject> prototype =
factory->NewJSObject(isolate->object_function(), TENURED); factory()->NewJSObject(isolate()->object_function(), TENURED);
SetPrototype(array_function, prototype); SetPrototype(array_function, prototype);
array_function->shared()->set_construct_stub( array_function->shared()->set_construct_stub(
isolate->builtins()->builtin(Builtins::kArrayConstructCode)); isolate()->builtins()->builtin(Builtins::kArrayConstructCode));
array_function->shared()->DontAdaptArguments(); array_function->shared()->DontAdaptArguments();
// Make "length" magic on instances. // Make "length" magic on instances.
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));
array_function->initial_map()->set_instance_descriptors( array_function->initial_map()->set_instance_descriptors(
...@@ -1509,7 +1506,7 @@ bool Genesis::InstallNatives() { ...@@ -1509,7 +1506,7 @@ bool Genesis::InstallNatives() {
i < Natives::GetBuiltinsCount(); i < Natives::GetBuiltinsCount();
i++) { i++) {
Vector<const char> name = Natives::GetScriptName(i); Vector<const char> name = Natives::GetScriptName(i);
if (!CompileBuiltin(i)) return false; if (!CompileBuiltin(isolate(), i)) return false;
// TODO(ager): We really only need to install the JS builtin // TODO(ager): We really only need to install the JS builtin
// functions on the builtins object after compiling and running // functions on the builtins object after compiling and running
// runtime.js. // runtime.js.
...@@ -1529,9 +1526,9 @@ bool Genesis::InstallNatives() { ...@@ -1529,9 +1526,9 @@ bool Genesis::InstallNatives() {
InstallBuiltinFunctionIds(); InstallBuiltinFunctionIds();
// Install Function.prototype.call and apply. // Install Function.prototype.call and apply.
{ Handle<String> key = factory->function_class_symbol(); { Handle<String> key = factory()->function_class_symbol();
Handle<JSFunction> function = Handle<JSFunction> function =
Handle<JSFunction>::cast(GetProperty(isolate->global(), key)); Handle<JSFunction>::cast(GetProperty(isolate()->global(), key));
Handle<JSObject> proto = Handle<JSObject> proto =
Handle<JSObject>(JSObject::cast(function->instance_prototype())); Handle<JSObject>(JSObject::cast(function->instance_prototype()));
...@@ -1573,7 +1570,7 @@ bool Genesis::InstallNatives() { ...@@ -1573,7 +1570,7 @@ bool Genesis::InstallNatives() {
// Add initial map. // Add initial map.
Handle<Map> initial_map = Handle<Map> initial_map =
factory->NewMap(JS_ARRAY_TYPE, JSRegExpResult::kSize); factory()->NewMap(JS_ARRAY_TYPE, JSRegExpResult::kSize);
initial_map->set_constructor(*array_constructor); initial_map->set_constructor(*array_constructor);
// Set prototype on map. // Set prototype on map.
...@@ -1587,13 +1584,13 @@ bool Genesis::InstallNatives() { ...@@ -1587,13 +1584,13 @@ bool Genesis::InstallNatives() {
ASSERT_EQ(1, array_descriptors->number_of_descriptors()); ASSERT_EQ(1, array_descriptors->number_of_descriptors());
Handle<DescriptorArray> reresult_descriptors = Handle<DescriptorArray> reresult_descriptors =
factory->NewDescriptorArray(3); factory()->NewDescriptorArray(3);
reresult_descriptors->CopyFrom(0, *array_descriptors, 0); reresult_descriptors->CopyFrom(0, *array_descriptors, 0);
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++);
...@@ -1601,7 +1598,7 @@ bool Genesis::InstallNatives() { ...@@ -1601,7 +1598,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++);
...@@ -1629,7 +1626,7 @@ bool Genesis::InstallNatives() { ...@@ -1629,7 +1626,7 @@ 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(); Factory* factory = global_context->GetIsolate()->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) {
...@@ -1648,7 +1645,8 @@ static Handle<JSObject> ResolveBuiltinIdHolder( ...@@ -1648,7 +1645,8 @@ static Handle<JSObject> ResolveBuiltinIdHolder(
static void InstallBuiltinFunctionId(Handle<JSObject> holder, static void InstallBuiltinFunctionId(Handle<JSObject> holder,
const char* function_name, const char* function_name,
BuiltinFunctionId id) { BuiltinFunctionId id) {
Handle<String> name = FACTORY->LookupAsciiSymbol(function_name); Factory* factory = holder->GetIsolate()->factory();
Handle<String> name = factory->LookupAsciiSymbol(function_name);
Object* function_object = holder->GetProperty(*name)->ToObjectUnchecked(); Object* function_object = holder->GetProperty(*name)->ToObjectUnchecked();
Handle<JSFunction> function(JSFunction::cast(function_object)); Handle<JSFunction> function(JSFunction::cast(function_object));
function->shared()->set_function_data(Smi::FromInt(id)); function->shared()->set_function_data(Smi::FromInt(id));
...@@ -1675,13 +1673,14 @@ void Genesis::InstallBuiltinFunctionIds() { ...@@ -1675,13 +1673,14 @@ void Genesis::InstallBuiltinFunctionIds() {
F(16, global_context()->regexp_function()) F(16, global_context()->regexp_function())
static FixedArray* CreateCache(int size, JSFunction* factory) { static FixedArray* CreateCache(int size, JSFunction* factory_function) {
Factory* factory = factory_function->GetIsolate()->factory();
// Caches are supposed to live for a long time, allocate in old space. // Caches are supposed to live for a long time, allocate in old space.
int array_size = JSFunctionResultCache::kEntriesIndex + 2 * size; int array_size = JSFunctionResultCache::kEntriesIndex + 2 * size;
// Cannot use cast as object is not fully initialized yet. // Cannot use cast as object is not fully initialized yet.
JSFunctionResultCache* cache = reinterpret_cast<JSFunctionResultCache*>( JSFunctionResultCache* cache = reinterpret_cast<JSFunctionResultCache*>(
*FACTORY->NewFixedArrayWithHoles(array_size, TENURED)); *factory->NewFixedArrayWithHoles(array_size, TENURED));
cache->set(JSFunctionResultCache::kFactoryIndex, factory); cache->set(JSFunctionResultCache::kFactoryIndex, factory_function);
cache->MakeZeroSize(); cache->MakeZeroSize();
return cache; return cache;
} }
...@@ -1720,7 +1719,7 @@ void Genesis::InitializeNormalizedMapCaches() { ...@@ -1720,7 +1719,7 @@ void Genesis::InitializeNormalizedMapCaches() {
bool Bootstrapper::InstallExtensions(Handle<Context> global_context, bool Bootstrapper::InstallExtensions(Handle<Context> global_context,
v8::ExtensionConfiguration* extensions) { v8::ExtensionConfiguration* extensions) {
Isolate* isolate = Isolate::Current(); Isolate* isolate = global_context->GetIsolate();
BootstrapperActive active; BootstrapperActive active;
SaveContext saved_context(isolate); SaveContext saved_context(isolate);
isolate->set_context(*global_context); isolate->set_context(*global_context);
...@@ -1731,7 +1730,7 @@ bool Bootstrapper::InstallExtensions(Handle<Context> global_context, ...@@ -1731,7 +1730,7 @@ 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(); Factory* factory = global_context->GetIsolate()->factory();
HandleScope scope; HandleScope scope;
Handle<JSGlobalObject> js_global( Handle<JSGlobalObject> js_global(
JSGlobalObject::cast(global_context->global())); JSGlobalObject::cast(global_context->global()));
...@@ -1867,9 +1866,10 @@ bool Genesis::InstallExtension(v8::RegisteredExtension* current) { ...@@ -1867,9 +1866,10 @@ bool Genesis::InstallExtension(v8::RegisteredExtension* current) {
bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) { bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) {
HandleScope scope; HandleScope scope;
Factory* factory = builtins->GetIsolate()->factory();
for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) { for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) {
Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i); Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i);
Handle<String> name = FACTORY->LookupAsciiSymbol(Builtins::GetName(id)); Handle<String> name = factory->LookupAsciiSymbol(Builtins::GetName(id));
Object* function_object = builtins->GetPropertyNoExceptionThrown(*name); Object* function_object = builtins->GetPropertyNoExceptionThrown(*name);
Handle<JSFunction> function Handle<JSFunction> function
= Handle<JSFunction>(JSFunction::cast(function_object)); = Handle<JSFunction>(JSFunction::cast(function_object));
...@@ -1918,13 +1918,12 @@ bool Genesis::ConfigureApiObject(Handle<JSObject> object, ...@@ -1918,13 +1918,12 @@ 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->has_pending_exception()); ASSERT(isolate()->has_pending_exception());
isolate->clear_pending_exception(); isolate()->clear_pending_exception();
return false; return false;
} }
TransferObject(obj, object); TransferObject(obj, object);
...@@ -2023,6 +2022,7 @@ void Genesis::TransferIndexedProperties(Handle<JSObject> from, ...@@ -2023,6 +2022,7 @@ void Genesis::TransferIndexedProperties(Handle<JSObject> from,
void Genesis::TransferObject(Handle<JSObject> from, Handle<JSObject> to) { void Genesis::TransferObject(Handle<JSObject> from, Handle<JSObject> to) {
HandleScope outer; HandleScope outer;
Factory* factory = from->GetIsolate()->factory();
ASSERT(!from->IsJSArray()); ASSERT(!from->IsJSArray());
ASSERT(!to->IsJSArray()); ASSERT(!to->IsJSArray());
...@@ -2032,7 +2032,7 @@ void Genesis::TransferObject(Handle<JSObject> from, Handle<JSObject> to) { ...@@ -2032,7 +2032,7 @@ void Genesis::TransferObject(Handle<JSObject> from, Handle<JSObject> to) {
// Transfer the prototype (new map is needed). // Transfer the prototype (new map is needed).
Handle<Map> old_to_map = Handle<Map>(to->map()); Handle<Map> old_to_map = Handle<Map>(to->map());
Handle<Map> new_to_map = FACTORY->CopyMapDropTransitions(old_to_map); Handle<Map> new_to_map = factory->CopyMapDropTransitions(old_to_map);
new_to_map->set_prototype(from->map()->prototype()); new_to_map->set_prototype(from->map()->prototype());
to->set_map(*new_to_map); to->set_map(*new_to_map);
} }
...@@ -2053,10 +2053,10 @@ void Genesis::MakeFunctionInstancePrototypeWritable() { ...@@ -2053,10 +2053,10 @@ void Genesis::MakeFunctionInstancePrototypeWritable() {
} }
Genesis::Genesis(Handle<Object> global_object, Genesis::Genesis(Isolate* isolate,
Handle<Object> global_object,
v8::Handle<v8::ObjectTemplate> global_template, v8::Handle<v8::ObjectTemplate> global_template,
v8::ExtensionConfiguration* extensions) { v8::ExtensionConfiguration* extensions) : isolate_(isolate) {
Isolate* isolate = Isolate::Current();
result_ = Handle<Context>::null(); result_ = Handle<Context>::null();
// If V8 isn't running and cannot be initialized, just return. // If V8 isn't running and cannot be initialized, just return.
if (!V8::IsRunning() && !V8::Initialize(NULL)) return; if (!V8::IsRunning() && !V8::Initialize(NULL)) return;
...@@ -2086,7 +2086,7 @@ Genesis::Genesis(Handle<Object> global_object, ...@@ -2086,7 +2086,7 @@ Genesis::Genesis(Handle<Object> global_object,
} else { } else {
// We get here if there was no context snapshot. // We get here if there was no context snapshot.
CreateRoots(); CreateRoots();
Handle<JSFunction> empty_function = CreateEmptyFunction(); Handle<JSFunction> empty_function = CreateEmptyFunction(isolate);
CreateStrictModeFunctionMaps(empty_function); CreateStrictModeFunctionMaps(empty_function);
Handle<GlobalObject> inner_global; Handle<GlobalObject> inner_global;
Handle<JSGlobalProxy> global_proxy = Handle<JSGlobalProxy> global_proxy =
......
...@@ -93,6 +93,7 @@ class Bootstrapper { ...@@ -93,6 +93,7 @@ class Bootstrapper {
// Creates a JavaScript Global Context with initial object graph. // Creates a JavaScript Global Context with initial object graph.
// The returned value is a global handle casted to V8Environment*. // The returned value is a global handle casted to V8Environment*.
Handle<Context> CreateEnvironment( Handle<Context> CreateEnvironment(
Isolate* isolate,
Handle<Object> global_object, Handle<Object> global_object,
v8::Handle<v8::ObjectTemplate> global_template, v8::Handle<v8::ObjectTemplate> global_template,
v8::ExtensionConfiguration* extensions); v8::ExtensionConfiguration* extensions);
......
...@@ -843,6 +843,7 @@ bool Debug::Load() { ...@@ -843,6 +843,7 @@ bool Debug::Load() {
HandleScope scope(isolate_); HandleScope scope(isolate_);
Handle<Context> context = Handle<Context> context =
isolate_->bootstrapper()->CreateEnvironment( isolate_->bootstrapper()->CreateEnvironment(
isolate_,
Handle<Object>::null(), Handle<Object>::null(),
v8::Handle<ObjectTemplate>(), v8::Handle<ObjectTemplate>(),
NULL); NULL);
......
...@@ -1120,23 +1120,25 @@ void TypeRecordingBinaryOpStub::GenerateOddballStub(MacroAssembler* masm) { ...@@ -1120,23 +1120,25 @@ void TypeRecordingBinaryOpStub::GenerateOddballStub(MacroAssembler* masm) {
GenerateAddStrings(masm); GenerateAddStrings(masm);
} }
Factory* factory = masm->isolate()->factory();
// Convert odd ball arguments to numbers. // Convert odd ball arguments to numbers.
NearLabel check, done; NearLabel check, done;
__ cmp(edx, FACTORY->undefined_value()); __ cmp(edx, factory->undefined_value());
__ j(not_equal, &check); __ j(not_equal, &check);
if (Token::IsBitOp(op_)) { if (Token::IsBitOp(op_)) {
__ xor_(edx, Operand(edx)); __ xor_(edx, Operand(edx));
} else { } else {
__ mov(edx, Immediate(FACTORY->nan_value())); __ mov(edx, Immediate(factory->nan_value()));
} }
__ jmp(&done); __ jmp(&done);
__ bind(&check); __ bind(&check);
__ cmp(eax, FACTORY->undefined_value()); __ cmp(eax, factory->undefined_value());
__ j(not_equal, &done); __ j(not_equal, &done);
if (Token::IsBitOp(op_)) { if (Token::IsBitOp(op_)) {
__ xor_(eax, Operand(eax)); __ xor_(eax, Operand(eax));
} else { } else {
__ mov(eax, Immediate(FACTORY->nan_value())); __ mov(eax, Immediate(factory->nan_value()));
} }
__ bind(&done); __ bind(&done);
......
...@@ -2330,9 +2330,10 @@ void NumberToStringStub::GenerateLookupNumberStringCache(MacroAssembler* masm, ...@@ -2330,9 +2330,10 @@ void NumberToStringStub::GenerateLookupNumberStringCache(MacroAssembler* masm,
// Heap::GetNumberStringCache. // Heap::GetNumberStringCache.
Label is_smi; Label is_smi;
Label load_result_from_cache; Label load_result_from_cache;
Factory* factory = masm->isolate()->factory();
if (!object_is_smi) { if (!object_is_smi) {
__ JumpIfSmi(object, &is_smi); __ JumpIfSmi(object, &is_smi);
__ CheckMap(object, FACTORY->heap_number_map(), not_found, true); __ CheckMap(object, factory->heap_number_map(), not_found, true);
STATIC_ASSERT(8 == kDoubleSize); STATIC_ASSERT(8 == kDoubleSize);
__ movl(scratch, FieldOperand(object, HeapNumber::kValueOffset + 4)); __ movl(scratch, FieldOperand(object, HeapNumber::kValueOffset + 4));
...@@ -2419,6 +2420,7 @@ void CompareStub::Generate(MacroAssembler* masm) { ...@@ -2419,6 +2420,7 @@ void CompareStub::Generate(MacroAssembler* masm) {
ASSERT(lhs_.is(no_reg) && rhs_.is(no_reg)); ASSERT(lhs_.is(no_reg) && rhs_.is(no_reg));
Label check_unequal_objects, done; Label check_unequal_objects, done;
Factory* factory = masm->isolate()->factory();
// Compare two smis if required. // Compare two smis if required.
if (include_smi_compare_) { if (include_smi_compare_) {
...@@ -2466,7 +2468,6 @@ void CompareStub::Generate(MacroAssembler* masm) { ...@@ -2466,7 +2468,6 @@ void CompareStub::Generate(MacroAssembler* masm) {
// Note: if cc_ != equal, never_nan_nan_ is not used. // Note: if cc_ != equal, never_nan_nan_ is not used.
// We cannot set rax to EQUAL until just before return because // We cannot set rax to EQUAL until just before return because
// rax must be unchanged on jump to not_identical. // rax must be unchanged on jump to not_identical.
if (never_nan_nan_ && (cc_ == equal)) { if (never_nan_nan_ && (cc_ == equal)) {
__ Set(rax, EQUAL); __ Set(rax, EQUAL);
__ ret(0); __ ret(0);
...@@ -2474,7 +2475,7 @@ void CompareStub::Generate(MacroAssembler* masm) { ...@@ -2474,7 +2475,7 @@ void CompareStub::Generate(MacroAssembler* masm) {
NearLabel heap_number; NearLabel heap_number;
// If it's not a heap number, then return equal for (in)equality operator. // If it's not a heap number, then return equal for (in)equality operator.
__ Cmp(FieldOperand(rdx, HeapObject::kMapOffset), __ Cmp(FieldOperand(rdx, HeapObject::kMapOffset),
FACTORY->heap_number_map()); factory->heap_number_map());
__ j(equal, &heap_number); __ j(equal, &heap_number);
if (cc_ != equal) { if (cc_ != equal) {
// Call runtime on identical JSObjects. Otherwise return equal. // Call runtime on identical JSObjects. Otherwise return equal.
...@@ -2519,7 +2520,7 @@ void CompareStub::Generate(MacroAssembler* masm) { ...@@ -2519,7 +2520,7 @@ void CompareStub::Generate(MacroAssembler* masm) {
// Check if the non-smi operand is a heap number. // Check if the non-smi operand is a heap number.
__ Cmp(FieldOperand(rbx, HeapObject::kMapOffset), __ Cmp(FieldOperand(rbx, HeapObject::kMapOffset),
FACTORY->heap_number_map()); factory->heap_number_map());
// If heap number, handle it in the slow case. // If heap number, handle it in the slow case.
__ j(equal, &slow); __ j(equal, &slow);
// Return non-equal. ebx (the lower half of rbx) is not zero. // Return non-equal. ebx (the lower half of rbx) is not zero.
...@@ -3450,10 +3451,11 @@ void StringCharCodeAtGenerator::GenerateSlow( ...@@ -3450,10 +3451,11 @@ void StringCharCodeAtGenerator::GenerateSlow(
MacroAssembler* masm, const RuntimeCallHelper& call_helper) { MacroAssembler* masm, const RuntimeCallHelper& call_helper) {
__ Abort("Unexpected fallthrough to CharCodeAt slow case"); __ Abort("Unexpected fallthrough to CharCodeAt slow case");
Factory* factory = masm->isolate()->factory();
// Index is not a smi. // Index is not a smi.
__ bind(&index_not_smi_); __ bind(&index_not_smi_);
// If index is a heap number, try converting it to an integer. // If index is a heap number, try converting it to an integer.
__ CheckMap(index_, FACTORY->heap_number_map(), index_not_number_, true); __ CheckMap(index_, factory->heap_number_map(), index_not_number_, true);
call_helper.BeforeCall(masm); call_helper.BeforeCall(masm);
__ push(object_); __ push(object_);
__ push(index_); __ push(index_);
......
...@@ -650,6 +650,7 @@ MaybeObject* MacroAssembler::TryCallApiFunctionAndReturn( ...@@ -650,6 +650,7 @@ MaybeObject* MacroAssembler::TryCallApiFunctionAndReturn(
Label leave_exit_frame; Label leave_exit_frame;
Label write_back; Label write_back;
Factory* factory = isolate()->factory();
ExternalReference next_address = ExternalReference next_address =
ExternalReference::handle_scope_next_address(); ExternalReference::handle_scope_next_address();
const int kNextOffset = 0; const int kNextOffset = 0;
...@@ -697,7 +698,7 @@ MaybeObject* MacroAssembler::TryCallApiFunctionAndReturn( ...@@ -697,7 +698,7 @@ MaybeObject* MacroAssembler::TryCallApiFunctionAndReturn(
// Check if the function scheduled an exception. // Check if the function scheduled an exception.
movq(rsi, scheduled_exception_address); movq(rsi, scheduled_exception_address);
Cmp(Operand(rsi, 0), FACTORY->the_hole_value()); Cmp(Operand(rsi, 0), factory->the_hole_value());
j(not_equal, &promote_scheduled_exception); j(not_equal, &promote_scheduled_exception);
LeaveApiExitFrame(); LeaveApiExitFrame();
...@@ -712,7 +713,7 @@ MaybeObject* MacroAssembler::TryCallApiFunctionAndReturn( ...@@ -712,7 +713,7 @@ MaybeObject* MacroAssembler::TryCallApiFunctionAndReturn(
bind(&empty_result); bind(&empty_result);
// It was zero; the result is undefined. // It was zero; the result is undefined.
Move(rax, FACTORY->undefined_value()); Move(rax, factory->undefined_value());
jmp(&prologue); jmp(&prologue);
// HandleScope limit has changed. Delete allocated extensions. // HandleScope limit has changed. Delete allocated extensions.
...@@ -1895,7 +1896,7 @@ void MacroAssembler::AbortIfNotNumber(Register object) { ...@@ -1895,7 +1896,7 @@ void MacroAssembler::AbortIfNotNumber(Register object) {
Condition is_smi = CheckSmi(object); Condition is_smi = CheckSmi(object);
j(is_smi, &ok); j(is_smi, &ok);
Cmp(FieldOperand(object, HeapObject::kMapOffset), Cmp(FieldOperand(object, HeapObject::kMapOffset),
FACTORY->heap_number_map()); isolate()->factory()->heap_number_map());
Assert(equal, "Operand not a number"); Assert(equal, "Operand not a number");
bind(&ok); bind(&ok);
} }
...@@ -2152,7 +2153,7 @@ void MacroAssembler::EnterFrame(StackFrame::Type type) { ...@@ -2152,7 +2153,7 @@ void MacroAssembler::EnterFrame(StackFrame::Type type) {
push(kScratchRegister); push(kScratchRegister);
if (emit_debug_code()) { if (emit_debug_code()) {
movq(kScratchRegister, movq(kScratchRegister,
FACTORY->undefined_value(), isolate()->factory()->undefined_value(),
RelocInfo::EMBEDDED_OBJECT); RelocInfo::EMBEDDED_OBJECT);
cmpq(Operand(rsp, 0), kScratchRegister); cmpq(Operand(rsp, 0), kScratchRegister);
Check(not_equal, "code object not properly patched"); Check(not_equal, "code object not properly patched");
...@@ -2320,7 +2321,7 @@ void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg, ...@@ -2320,7 +2321,7 @@ void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg,
// Check the context is a global context. // Check the context is a global context.
if (emit_debug_code()) { if (emit_debug_code()) {
Cmp(FieldOperand(scratch, HeapObject::kMapOffset), Cmp(FieldOperand(scratch, HeapObject::kMapOffset),
FACTORY->global_context_map()); isolate()->factory()->global_context_map());
Check(equal, "JSGlobalObject::global_context should be a global context."); Check(equal, "JSGlobalObject::global_context should be a global context.");
} }
...@@ -2822,7 +2823,7 @@ void MacroAssembler::LoadGlobalFunctionInitialMap(Register function, ...@@ -2822,7 +2823,7 @@ void MacroAssembler::LoadGlobalFunctionInitialMap(Register function,
movq(map, FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); movq(map, FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset));
if (emit_debug_code()) { if (emit_debug_code()) {
Label ok, fail; Label ok, fail;
CheckMap(map, FACTORY->meta_map(), &fail, false); CheckMap(map, isolate()->factory()->meta_map(), &fail, false);
jmp(&ok); jmp(&ok);
bind(&fail); bind(&fail);
Abort("Global functions must have initial map"); Abort("Global functions must have initial map");
......
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