Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index e8c38385ea29e2330345bf8cabc115f6518432f0..a02f6a8315a85db4be67bb671343647f4e577820 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -9299,6 +9299,28 @@ void JSFunction::MarkInOptimizationQueue() { |
| } |
| +Handle<JSFunction> JSFunction::Copy(Handle<JSFunction> function) { |
|
Toon Verwaest
2014/08/21 09:02:20
This method doesn't exactly copy a function anymor
Dmitry Lomov (no reviews)
2014/08/21 11:09:11
Done.
|
| + Isolate* isolate = function->GetIsolate(); |
| + Handle<Map> map(function->map()); |
| + Handle<SharedFunctionInfo> shared(function->shared()); |
| + Handle<Context> context(function->context()); |
| + Handle<JSFunction> clone = |
| + isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context); |
| + |
| + if (shared->bound()) { |
| + clone->set_function_bindings(function->function_bindings()); |
| + } |
| + |
| + // In typical case, __proto__ of ``function`` is the default Function |
| + // prototype, which means that SetPrototype below is a no-op. |
| + // In rare cases when that is not true, we mutate the clone's __proto__. |
| + Handle<Object> original_prototype(map->prototype(), isolate); |
| + JSObject::SetPrototype(clone, original_prototype, false).Assert(); |
|
Toon Verwaest
2014/08/21 09:02:20
JSObject::SetPrototype isn't exactly a no-op right
Dmitry Lomov (no reviews)
2014/08/21 11:09:11
Done.
|
| + |
| + return clone; |
| +} |
| + |
| + |
| void SharedFunctionInfo::AddToOptimizedCodeMap( |
| Handle<SharedFunctionInfo> shared, |
| Handle<Context> native_context, |