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

Unified Diff: src/runtime/runtime-function.cc

Issue 1217603005: [es6] Function bind should preserve [[Prototype]] (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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 | « no previous file | test/mjsunit/function-bind.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-function.cc
diff --git a/src/runtime/runtime-function.cc b/src/runtime/runtime-function.cc
index d644d37e42b2fff45685eb2c7604c5c68c801a3d..e7cffc1768a4a232d1c55fbe8fe13603bdded7f8 100644
--- a/src/runtime/runtime-function.cc
+++ b/src/runtime/runtime-function.cc
@@ -443,9 +443,14 @@ RUNTIME_FUNCTION(Runtime_FunctionBindArguments) {
// Update length. Have to remove the prototype first so that map migration
// is happy about the number of fields.
RUNTIME_ASSERT(bound_function->RemovePrototype());
- Handle<Map> bound_function_map(
- isolate->native_context()->bound_function_map());
+
+ // The new function should have the same [[Prototype]] as the bindee.
+ Handle<Map> bound_function_map = Map::Copy(
adamk 2015/07/01 19:31:55 Forcing map creation here seems possibly bad. If y
arv (Not doing code reviews) 2015/07/01 19:51:21 Done.
+ handle(isolate->native_context()->bound_function_map()), "FunctionBind");
+ PrototypeIterator iter(isolate, bindee);
+ Map::SetPrototype(bound_function_map, PrototypeIterator::GetCurrent(iter));
JSObject::MigrateToMap(bound_function, bound_function_map);
+
Handle<String> length_string = isolate->factory()->length_string();
PropertyAttributes attr =
static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY);
« no previous file with comments | « no previous file | test/mjsunit/function-bind.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698