Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Unified Diff: src/objects.cc

Issue 475423003: Implement Function.prototype.toMethod. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove stray change Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | src/runtime.h » ('j') | src/runtime.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « src/objects.h ('k') | src/runtime.h » ('j') | src/runtime.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698