| Index: src/runtime.cc
|
| diff --git a/src/runtime.cc b/src/runtime.cc
|
| index e8003b6731cc77740ed36596a90a59fcfe957027..a85b6552466f72718483c9338e021ab9d888f55b 100644
|
| --- a/src/runtime.cc
|
| +++ b/src/runtime.cc
|
| @@ -136,14 +136,26 @@ namespace internal {
|
| static_cast<LanguageMode>(args.smi_at(index));
|
|
|
|
|
| -MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate,
|
| - JSObject* boilerplate) {
|
| +
|
| +MUST_USE_RESULT MaybeObject* Runtime::DeepCopyBoilerplate(
|
| + Isolate* isolate,
|
| + JSObject* boilerplate,
|
| + AllocationSiteMode allocation_site_mode) {
|
| StackLimitCheck check(isolate);
|
| if (check.HasOverflowed()) return isolate->StackOverflow();
|
|
|
| Heap* heap = isolate->heap();
|
| Object* result;
|
| - { MaybeObject* maybe_result = heap->CopyJSObject(boilerplate);
|
| + AllocationSiteMode current_object_mode = DONT_TRACK_ALLOCATION_SITE;
|
| + if (allocation_site_mode == TRACK_ALLOCATION_SITE &&
|
| + boilerplate->map()->CanTrackAllocationSite()) {
|
| + current_object_mode = boilerplate->IsJSArray()
|
| + ? AllocationSiteInfo::GetMode(boilerplate->GetElementsKind())
|
| + : TRACK_ALLOCATION_SITE;
|
| + }
|
| +
|
| + { MaybeObject* maybe_result = heap->CopyJSObject(boilerplate,
|
| + current_object_mode);
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
| JSObject* copy = JSObject::cast(result);
|
| @@ -155,7 +167,8 @@ MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate,
|
| Object* value = properties->get(i);
|
| if (value->IsJSObject()) {
|
| JSObject* js_object = JSObject::cast(value);
|
| - { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, js_object);
|
| + { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, js_object,
|
| + allocation_site_mode);
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
| properties->set(i, result);
|
| @@ -166,7 +179,8 @@ MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate,
|
| Object* value = copy->InObjectPropertyAt(i);
|
| if (value->IsJSObject()) {
|
| JSObject* js_object = JSObject::cast(value);
|
| - { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, js_object);
|
| + { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, js_object,
|
| + allocation_site_mode);
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
| copy->InObjectPropertyAtPut(i, result);
|
| @@ -192,7 +206,8 @@ MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate,
|
| copy->GetProperty(key_string, &attributes)->ToObjectUnchecked();
|
| if (value->IsJSObject()) {
|
| JSObject* js_object = JSObject::cast(value);
|
| - { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, js_object);
|
| + { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, js_object,
|
| + allocation_site_mode);
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
| { MaybeObject* maybe_result =
|
| @@ -229,7 +244,8 @@ MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate,
|
| if (value->IsJSObject()) {
|
| JSObject* js_object = JSObject::cast(value);
|
| { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate,
|
| - js_object);
|
| + js_object,
|
| + allocation_site_mode);
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
| elements->set(i, result);
|
| @@ -248,7 +264,8 @@ MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate,
|
| if (value->IsJSObject()) {
|
| JSObject* js_object = JSObject::cast(value);
|
| { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate,
|
| - js_object);
|
| + js_object,
|
| + allocation_site_mode);
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
| element_dictionary->ValueAtPut(i, result);
|
| @@ -582,6 +599,13 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteral) {
|
| CONVERT_SMI_ARG_CHECKED(flags, 3);
|
| bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0;
|
| bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0;
|
| + bool allocation_sites_allowed =
|
| + (flags & ObjectLiteral::kAllocationSiteInfoAllowed) != 0;
|
| +
|
| + AllocationSiteMode allocation_site_mode = DONT_TRACK_ALLOCATION_SITE;
|
| + if (FLAG_track_allocation_sites && allocation_sites_allowed) {
|
| + allocation_site_mode = TRACK_ALLOCATION_SITE;
|
| + }
|
|
|
| // Check if boilerplate exists. If not, create it first.
|
| Handle<Object> boilerplate(literals->get(literals_index), isolate);
|
| @@ -595,7 +619,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteral) {
|
| // Update the functions literal and return the boilerplate.
|
| literals->set(literals_index, *boilerplate);
|
| }
|
| - return DeepCopyBoilerplate(isolate, JSObject::cast(*boilerplate));
|
| +
|
| + return Runtime::DeepCopyBoilerplate(isolate,
|
| + JSObject::cast(*boilerplate),
|
| + allocation_site_mode);
|
| }
|
|
|
|
|
| @@ -608,6 +635,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteralShallow) {
|
| CONVERT_SMI_ARG_CHECKED(flags, 3);
|
| bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0;
|
| bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0;
|
| + bool allocation_site_info_allowed =
|
| + (flags & ObjectLiteral::kAllocationSiteInfoAllowed) != 0
|
| + && FLAG_track_allocation_sites;
|
|
|
| // Check if boilerplate exists. If not, create it first.
|
| Handle<Object> boilerplate(literals->get(literals_index), isolate);
|
| @@ -621,16 +651,29 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteralShallow) {
|
| // Update the functions literal and return the boilerplate.
|
| literals->set(literals_index, *boilerplate);
|
| }
|
| - return isolate->heap()->CopyJSObject(JSObject::cast(*boilerplate));
|
| +
|
| + AllocationSiteMode mode = allocation_site_info_allowed
|
| + ? TRACK_ALLOCATION_SITE
|
| + : DONT_TRACK_ALLOCATION_SITE;
|
| + return isolate->heap()->CopyJSObject(JSObject::cast(*boilerplate),
|
| + mode);
|
| }
|
|
|
|
|
| RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteral) {
|
| HandleScope scope(isolate);
|
| - ASSERT(args.length() == 3);
|
| + ASSERT(args.length() == 4);
|
| CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
|
| CONVERT_SMI_ARG_CHECKED(literals_index, 1);
|
| CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2);
|
| + CONVERT_SMI_ARG_CHECKED(flags, 3);
|
| + bool allocation_sites_allowed =
|
| + (flags & ArrayLiteral::kAllocationSiteInfoAllowed) != 0;
|
| +
|
| + AllocationSiteMode allocation_site_mode = DONT_TRACK_ALLOCATION_SITE;
|
| + if (FLAG_track_allocation_sites && allocation_sites_allowed) {
|
| + allocation_site_mode = TRACK_ALLOCATION_SITE;
|
| + }
|
|
|
| // Check if boilerplate exists. If not, create it first.
|
| Handle<Object> boilerplate(literals->get(literals_index), isolate);
|
| @@ -642,16 +685,22 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteral) {
|
| // Update the functions literal and return the boilerplate.
|
| literals->set(literals_index, *boilerplate);
|
| }
|
| - return DeepCopyBoilerplate(isolate, JSObject::cast(*boilerplate));
|
| +
|
| + return Runtime::DeepCopyBoilerplate(isolate,
|
| + JSObject::cast(*boilerplate),
|
| + allocation_site_mode);
|
| }
|
|
|
|
|
| RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) {
|
| HandleScope scope(isolate);
|
| - ASSERT(args.length() == 3);
|
| + ASSERT(args.length() == 4);
|
| CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
|
| CONVERT_SMI_ARG_CHECKED(literals_index, 1);
|
| CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2);
|
| + CONVERT_SMI_ARG_CHECKED(flags, 3);
|
| + bool allocation_site_info_allowed = FLAG_track_allocation_sites &&
|
| + ((flags & ArrayLiteral::kAllocationSiteInfoAllowed) != 0);
|
|
|
| // Check if boilerplate exists. If not, create it first.
|
| Handle<Object> boilerplate(literals->get(literals_index), isolate);
|
| @@ -669,8 +718,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) {
|
| }
|
|
|
| JSObject* boilerplate_object = JSObject::cast(*boilerplate);
|
| - AllocationSiteMode mode = AllocationSiteInfo::GetMode(
|
| - boilerplate_object->GetElementsKind());
|
| + AllocationSiteMode mode = allocation_site_info_allowed
|
| + ? AllocationSiteInfo::GetMode(boilerplate_object->GetElementsKind())
|
| + : DONT_TRACK_ALLOCATION_SITE;
|
| return isolate->heap()->CopyJSObject(boilerplate_object, mode);
|
| }
|
|
|
|
|