| Index: src/runtime.cc
|
| diff --git a/src/runtime.cc b/src/runtime.cc
|
| index b5a108159ad81bac2a1ef8a7e28a287751e712c0..ba0bbc3963dafd02b1ce32c59c33220d77687043 100644
|
| --- a/src/runtime.cc
|
| +++ b/src/runtime.cc
|
| @@ -554,24 +554,63 @@ static Handle<AllocationSite> GetLiteralAllocationSite(
|
| }
|
|
|
|
|
| +static MaybeObject* CreateArrayLiteralImpl(Isolate* isolate,
|
| + Handle<FixedArray> literals,
|
| + int literals_index,
|
| + Handle<FixedArray> elements,
|
| + int flags) {
|
| + Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals,
|
| + literals_index, elements);
|
| + RETURN_IF_EMPTY_HANDLE(isolate, site);
|
| +
|
| + Handle<JSObject> boilerplate(JSObject::cast(site->transition_info()));
|
| + if ((flags & ArrayLiteral::kShallowElements) != 0) {
|
| + if (boilerplate->elements()->map() ==
|
| + isolate->heap()->fixed_cow_array_map()) {
|
| + isolate->counters()->cow_arrays_created_runtime()->Increment();
|
| + }
|
| +
|
| + if ((flags & ArrayLiteral::kDisableMementos) == 0 &&
|
| + AllocationSite::GetMode(boilerplate->GetElementsKind()) ==
|
| + TRACK_ALLOCATION_SITE) {
|
| + return isolate->heap()->CopyJSObject(*boilerplate, *site);
|
| + }
|
| +
|
| + return isolate->heap()->CopyJSObject(*boilerplate);
|
| + } else {
|
| + AllocationSiteUsageContext usage_context(isolate, site,
|
| + (flags & ArrayLiteral::kDisableMementos) == 0);
|
| + usage_context.EnterNewScope();
|
| + Handle<JSObject> copy = JSObject::DeepCopy(boilerplate, &usage_context);
|
| + usage_context.ExitScope(site, boilerplate);
|
| + RETURN_IF_EMPTY_HANDLE(isolate, copy);
|
| + return *copy;
|
| + }
|
| +}
|
| +
|
| +
|
| 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);
|
|
|
| - Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals,
|
| - literals_index, elements);
|
| - RETURN_IF_EMPTY_HANDLE(isolate, site);
|
| + return CreateArrayLiteralImpl(isolate, literals, literals_index, elements,
|
| + flags);
|
| +}
|
|
|
| - Handle<JSObject> boilerplate(JSObject::cast(site->transition_info()));
|
| - AllocationSiteUsageContext usage_context(isolate, site, true);
|
| - usage_context.EnterNewScope();
|
| - Handle<JSObject> copy = JSObject::DeepCopy(boilerplate, &usage_context);
|
| - usage_context.ExitScope(site, boilerplate);
|
| - RETURN_IF_EMPTY_HANDLE(isolate, copy);
|
| - return *copy;
|
| +
|
| +RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralStubBailout) {
|
| + HandleScope scope(isolate);
|
| + ASSERT(args.length() == 3);
|
| + CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
|
| + CONVERT_SMI_ARG_CHECKED(literals_index, 1);
|
| + CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2);
|
| +
|
| + return CreateArrayLiteralImpl(isolate, literals, literals_index, elements,
|
| + ArrayLiteral::kShallowElements);
|
| }
|
|
|
|
|
|
|