| Index: src/heap/heap.cc
|
| diff --git a/src/heap/heap.cc b/src/heap/heap.cc
|
| index a4a970534e34e85133d672e0c2c9a412f06c4702..ae5613eaf76ede98e18740c130695266f574f55f 100644
|
| --- a/src/heap/heap.cc
|
| +++ b/src/heap/heap.cc
|
| @@ -3589,7 +3589,7 @@ AllocationResult Heap::AllocateJSObject(JSFunction* constructor,
|
| AllocationResult Heap::CopyJSObject(JSObject* source, AllocationSite* site) {
|
| // Never used to copy functions. If functions need to be copied we
|
| // have to be careful to clear the literals array.
|
| - SLOW_DCHECK(!source->IsJSFunction());
|
| + // SLOW_DCHECK(!source->IsJSFunction());
|
|
|
| // Make the clone.
|
| Map* map = source->map();
|
| @@ -3664,6 +3664,28 @@ AllocationResult Heap::CopyJSObject(JSObject* source, AllocationSite* site) {
|
| }
|
| JSObject::cast(clone)->set_properties(prop, wb_mode);
|
| }
|
| +
|
| + if (source->IsJSFunction()) {
|
| + SLOW_DCHECK(clone->IsJSFunction());
|
| + JSFunction* source_fun = JSFunction::cast(source);
|
| + JSFunction* clone_fun = JSFunction::cast(clone);
|
| + SharedFunctionInfo* info = source_fun->shared();
|
| + if (!info->bound()) {
|
| + int num_literals = info->num_literals();
|
| + HeapObject* obj;
|
| + {
|
| + AllocationResult allocation = AllocateFixedArrayWithFiller(
|
| + num_literals, NOT_TENURED, undefined_value());
|
| + if (!allocation.To(&obj)) return allocation;
|
| + }
|
| + FixedArray* new_literals = FixedArray::cast(obj);
|
| + if (num_literals > 0) {
|
| + new_literals->set(JSFunction::kLiteralNativeContextIndex,
|
| + JSFunction::NativeContextFromLiterals(source_fun->literals()));
|
| + }
|
| + clone_fun->set_literals(new_literals);
|
| + }
|
| + }
|
| // Return the new clone.
|
| return clone;
|
| }
|
|
|