diff options
Diffstat (limited to 'deps/v8/src/bootstrapper.cc')
-rw-r--r-- | deps/v8/src/bootstrapper.cc | 63 |
1 files changed, 40 insertions, 23 deletions
diff --git a/deps/v8/src/bootstrapper.cc b/deps/v8/src/bootstrapper.cc index 6e6c2c639..aa8d8e5ac 100644 --- a/deps/v8/src/bootstrapper.cc +++ b/deps/v8/src/bootstrapper.cc @@ -1064,8 +1064,11 @@ bool Genesis::InstallNatives() { // global object. static const PropertyAttributes attributes = static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); - SetProperty(builtins, Factory::LookupAsciiSymbol("global"), - Handle<Object>(global_context()->global()), attributes); + Handle<String> global_symbol = Factory::LookupAsciiSymbol("global"); + SetProperty(builtins, + global_symbol, + Handle<Object>(global_context()->global()), + attributes); // Setup the reference from the global object to the builtins object. JSGlobalObject::cast(global_context()->global())->set_builtins(*builtins); @@ -1344,33 +1347,41 @@ bool Genesis::InstallNatives() { } -static void InstallCustomCallGenerator( - Handle<JSFunction> holder_function, - CallStubCompiler::CustomGeneratorOwner owner_flag, - const char* function_name, - int id) { - Handle<JSObject> owner; - if (owner_flag == CallStubCompiler::FUNCTION) { - owner = Handle<JSObject>::cast(holder_function); - } else { - ASSERT(owner_flag == CallStubCompiler::INSTANCE_PROTOTYPE); - owner = Handle<JSObject>( - JSObject::cast(holder_function->instance_prototype())); +static Handle<JSObject> ResolveCustomCallGeneratorHolder( + Handle<Context> global_context, + const char* holder_expr) { + Handle<GlobalObject> global(global_context->global()); + const char* period_pos = strchr(holder_expr, '.'); + if (period_pos == NULL) { + return Handle<JSObject>::cast( + GetProperty(global, Factory::LookupAsciiSymbol(holder_expr))); } + ASSERT_EQ(".prototype", period_pos); + Vector<const char> property(holder_expr, + static_cast<int>(period_pos - holder_expr)); + Handle<JSFunction> function = Handle<JSFunction>::cast( + GetProperty(global, Factory::LookupSymbol(property))); + return Handle<JSObject>(JSObject::cast(function->prototype())); +} + + +static void InstallCustomCallGenerator(Handle<JSObject> holder, + const char* function_name, + int id) { Handle<String> name = Factory::LookupAsciiSymbol(function_name); - Handle<JSFunction> function(JSFunction::cast(owner->GetProperty(*name))); + Handle<JSFunction> function(JSFunction::cast(holder->GetProperty(*name))); function->shared()->set_function_data(Smi::FromInt(id)); } void Genesis::InstallCustomCallGenerators() { HandleScope scope; -#define INSTALL_CALL_GENERATOR(holder_fun, owner_flag, fun_name, name) \ - { \ - Handle<JSFunction> holder(global_context()->holder_fun##_function()); \ - const int id = CallStubCompiler::k##name##CallGenerator; \ - InstallCustomCallGenerator(holder, CallStubCompiler::owner_flag, \ - #fun_name, id); \ +#define INSTALL_CALL_GENERATOR(holder_expr, fun_name, name) \ + { \ + Handle<JSObject> holder = ResolveCustomCallGeneratorHolder( \ + global_context(), #holder_expr); \ + const int id = CallStubCompiler::k##name##CallGenerator; \ + InstallCustomCallGenerator(holder, #fun_name, id); \ } CUSTOM_CALL_IC_GENERATORS(INSTALL_CALL_GENERATOR) #undef INSTALL_CALL_GENERATOR @@ -1405,8 +1416,14 @@ void Genesis::InstallJSFunctionResultCaches() { Handle<FixedArray> caches = Factory::NewFixedArray(kNumberOfCaches, TENURED); int index = 0; -#define F(size, func) caches->set(index++, CreateCache(size, func)); - JSFUNCTION_RESULT_CACHE_LIST(F) + +#define F(size, func) do { \ + FixedArray* cache = CreateCache((size), (func)); \ + caches->set(index++, cache); \ + } while (false) + + JSFUNCTION_RESULT_CACHE_LIST(F); + #undef F global_context()->set_jsfunction_result_caches(*caches); |