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

Unified Diff: src/objects.cc

Issue 475423003: Implement Function.prototype.toMethod. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: CR feedback 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') | no next file with comments »
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..e79bc9d6d8c3f95153ce43d19c47a72c2ada4534 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -9299,6 +9299,30 @@ void JSFunction::MarkInOptimizationQueue() {
}
+Handle<JSFunction> JSFunction::CloneClosure(Handle<JSFunction> function) {
+ 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.
Toon Verwaest 2014/08/21 11:32:28 Now this comment is a bit off
+ // In rare cases when that is not true, we mutate the clone's __proto__.
+ Handle<Object> original_prototype(map->prototype(), isolate);
+ if (*original_prototype != clone->map()->prototype()) {
+ JSObject::SetPrototype(clone, original_prototype, false).Assert();
+ }
+
+ 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698