diff options
Diffstat (limited to 'chromium/v8/src/factory.cc')
-rw-r--r-- | chromium/v8/src/factory.cc | 106 |
1 files changed, 71 insertions, 35 deletions
diff --git a/chromium/v8/src/factory.cc b/chromium/v8/src/factory.cc index 3ca0efa2107..acbaf3c862c 100644 --- a/chromium/v8/src/factory.cc +++ b/chromium/v8/src/factory.cc @@ -130,7 +130,8 @@ Handle<DescriptorArray> Factory::NewDescriptorArray(int number_of_descriptors, int slack) { ASSERT(0 <= number_of_descriptors); CALL_HEAP_FUNCTION(isolate(), - DescriptorArray::Allocate(number_of_descriptors, slack), + DescriptorArray::Allocate( + isolate(), number_of_descriptors, slack), DescriptorArray); } @@ -140,7 +141,8 @@ Handle<DeoptimizationInputData> Factory::NewDeoptimizationInputData( PretenureFlag pretenure) { ASSERT(deopt_entry_count > 0); CALL_HEAP_FUNCTION(isolate(), - DeoptimizationInputData::Allocate(deopt_entry_count, + DeoptimizationInputData::Allocate(isolate(), + deopt_entry_count, pretenure), DeoptimizationInputData); } @@ -151,7 +153,8 @@ Handle<DeoptimizationOutputData> Factory::NewDeoptimizationOutputData( PretenureFlag pretenure) { ASSERT(deopt_entry_count > 0); CALL_HEAP_FUNCTION(isolate(), - DeoptimizationOutputData::Allocate(deopt_entry_count, + DeoptimizationOutputData::Allocate(isolate(), + deopt_entry_count, pretenure), DeoptimizationOutputData); } @@ -664,7 +667,7 @@ Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( return result; } - if (V8::UseCrankshaft() && + if (isolate()->use_crankshaft() && FLAG_always_opt && result->is_compiled() && !function_info->is_toplevel() && @@ -806,7 +809,7 @@ Handle<String> Factory::EmergencyNewError(const char* message, *p++ = ' '; space--; if (space > 0) { - MaybeObject* maybe_arg = args->GetElement(i); + MaybeObject* maybe_arg = args->GetElement(isolate(), i); Handle<String> arg_str(reinterpret_cast<String*>(maybe_arg)); const char* arg = *arg_str->ToCString(); Vector<char> v2(p, static_cast<int>(space)); @@ -1023,10 +1026,11 @@ Handle<GlobalObject> Factory::NewGlobalObject( Handle<JSObject> Factory::NewJSObjectFromMap(Handle<Map> map, - PretenureFlag pretenure) { + PretenureFlag pretenure, + bool alloc_props) { CALL_HEAP_FUNCTION( isolate(), - isolate()->heap()->AllocateJSObjectFromMap(*map, pretenure), + isolate()->heap()->AllocateJSObjectFromMap(*map, pretenure, alloc_props), JSObject); } @@ -1079,13 +1083,6 @@ void Factory::SetContent(Handle<JSArray> array, } -void Factory::EnsureCanContainHeapObjectElements(Handle<JSArray> array) { - CALL_HEAP_FUNCTION_VOID( - isolate(), - array->EnsureCanContainHeapObjectElements()); -} - - void Factory::EnsureCanContainElements(Handle<JSArray> array, Handle<FixedArrayBase> elements, uint32_t length, @@ -1189,13 +1186,6 @@ void Factory::BecomeJSFunction(Handle<JSReceiver> object) { } -void Factory::SetIdentityHash(Handle<JSObject> object, Smi* hash) { - CALL_HEAP_FUNCTION_VOID( - isolate(), - object->SetIdentityHash(hash, ALLOW_CREATION)); -} - - Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( Handle<String> name, int number_of_literals, @@ -1215,6 +1205,7 @@ Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( shared->set_num_literals(literals_array_size); if (is_generator) { shared->set_instance_class_name(isolate()->heap()->Generator_string()); + shared->DisableOptimization(kGenerator); } return shared; } @@ -1326,7 +1317,7 @@ Handle<JSFunction> Factory::NewFunctionWithoutPrototype( Handle<Object> Factory::ToObject(Handle<Object> object) { - CALL_HEAP_FUNCTION(isolate(), object->ToObject(), Object); + CALL_HEAP_FUNCTION(isolate(), object->ToObject(isolate()), Object); } @@ -1391,8 +1382,10 @@ Handle<JSFunction> Factory::CreateApiFunction( Smi::cast(instance_template->internal_field_count())->value(); } + // TODO(svenpanne) Kill ApiInstanceType and refactor things by generalizing + // JSObject::GetHeaderSize. int instance_size = kPointerSize * internal_field_count; - InstanceType type = INVALID_TYPE; + InstanceType type; switch (instance_type) { case JavaScriptObject: type = JS_OBJECT_TYPE; @@ -1407,9 +1400,10 @@ Handle<JSFunction> Factory::CreateApiFunction( instance_size += JSGlobalProxy::kSize; break; default: + UNREACHABLE(); + type = JS_OBJECT_TYPE; // Keep the compiler happy. break; } - ASSERT(type != INVALID_TYPE); Handle<JSFunction> result = NewFunction(Factory::empty_string(), @@ -1462,15 +1456,29 @@ Handle<JSFunction> Factory::CreateApiFunction( result->shared()->set_construct_stub(*construct_stub); result->shared()->DontAdaptArguments(); - // Recursively copy parent templates' accessors, 'data' may be modified. + // Recursively copy parent instance templates' accessors, + // 'data' may be modified. int max_number_of_additional_properties = 0; + int max_number_of_static_properties = 0; FunctionTemplateInfo* info = *obj; while (true) { - Object* props = info->property_accessors(); - if (!props->IsUndefined()) { - Handle<Object> props_handle(props, isolate()); - NeanderArray props_array(props_handle); - max_number_of_additional_properties += props_array.length(); + if (!info->instance_template()->IsUndefined()) { + Object* props = + ObjectTemplateInfo::cast( + info->instance_template())->property_accessors(); + if (!props->IsUndefined()) { + Handle<Object> props_handle(props, isolate()); + NeanderArray props_array(props_handle); + max_number_of_additional_properties += props_array.length(); + } + } + if (!info->property_accessors()->IsUndefined()) { + Object* props = info->property_accessors(); + if (!props->IsUndefined()) { + Handle<Object> props_handle(props, isolate()); + NeanderArray props_array(props_handle); + max_number_of_static_properties += props_array.length(); + } } Object* parent = info->parent_template(); if (parent->IsUndefined()) break; @@ -1479,17 +1487,44 @@ Handle<JSFunction> Factory::CreateApiFunction( Map::EnsureDescriptorSlack(map, max_number_of_additional_properties); + // Use a temporary FixedArray to acculumate static accessors + int valid_descriptors = 0; + Handle<FixedArray> array; + if (max_number_of_static_properties > 0) { + array = NewFixedArray(max_number_of_static_properties); + } + while (true) { - Handle<Object> props = Handle<Object>(obj->property_accessors(), - isolate()); - if (!props->IsUndefined()) { - Map::AppendCallbackDescriptors(map, props); + // Install instance descriptors + if (!obj->instance_template()->IsUndefined()) { + Handle<ObjectTemplateInfo> instance = + Handle<ObjectTemplateInfo>( + ObjectTemplateInfo::cast(obj->instance_template()), isolate()); + Handle<Object> props = Handle<Object>(instance->property_accessors(), + isolate()); + if (!props->IsUndefined()) { + Map::AppendCallbackDescriptors(map, props); + } + } + // Accumulate static accessors + if (!obj->property_accessors()->IsUndefined()) { + Handle<Object> props = Handle<Object>(obj->property_accessors(), + isolate()); + valid_descriptors = + AccessorInfo::AppendUnique(props, array, valid_descriptors); } + // Climb parent chain Handle<Object> parent = Handle<Object>(obj->parent_template(), isolate()); if (parent->IsUndefined()) break; obj = Handle<FunctionTemplateInfo>::cast(parent); } + // Install accumulated static accessors + for (int i = 0; i < valid_descriptors; i++) { + Handle<AccessorInfo> accessor(AccessorInfo::cast(array->get(i))); + JSObject::SetAccessor(result, accessor); + } + ASSERT(result->shared()->IsApiFunction()); return result; } @@ -1588,7 +1623,8 @@ void Factory::ConfigureInstance(Handle<FunctionTemplateInfo> desc, // instance template. Handle<Object> instance_template(desc->instance_template(), isolate()); if (!instance_template->IsUndefined()) { - Execution::ConfigureInstance(instance, + Execution::ConfigureInstance(isolate(), + instance, instance_template, pending_exception); } else { |