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

Side by Side Diff: src/runtime/runtime-function.cc

Issue 1379323002: [runtime] Share constructor/non-constructor bound function maps. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « src/contexts.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/arguments.h" 8 #include "src/arguments.h"
9 #include "src/compiler.h" 9 #include "src/compiler.h"
10 #include "src/deoptimizer.h" 10 #include "src/deoptimizer.h"
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 new_bindings->set_binding(out_index, *arguments[j + 1]); 402 new_bindings->set_binding(out_index, *arguments[j + 1]);
403 } 403 }
404 new_bindings->set_map_no_write_barrier(isolate->heap()->fixed_array_map()); 404 new_bindings->set_map_no_write_barrier(isolate->heap()->fixed_array_map());
405 bound_function->set_function_bindings(*new_bindings); 405 bound_function->set_function_bindings(*new_bindings);
406 406
407 // Update length. Have to remove the prototype first so that map migration 407 // Update length. Have to remove the prototype first so that map migration
408 // is happy about the number of fields. 408 // is happy about the number of fields.
409 RUNTIME_ASSERT(bound_function->RemovePrototype()); 409 RUNTIME_ASSERT(bound_function->RemovePrototype());
410 410
411 // The new function should have the same [[Prototype]] as the bindee. 411 // The new function should have the same [[Prototype]] as the bindee.
412 Handle<Map> bound_function_map( 412 Handle<Map> bound_function_map =
413 isolate->native_context()->bound_function_map()); 413 bindee->IsConstructor()
414 ? isolate->bound_function_with_constructor_map()
415 : isolate->bound_function_without_constructor_map();
414 PrototypeIterator iter(isolate, bindee); 416 PrototypeIterator iter(isolate, bindee);
415 Handle<Object> proto = PrototypeIterator::GetCurrent(iter); 417 Handle<Object> proto = PrototypeIterator::GetCurrent(iter);
416 if (bound_function_map->prototype() != *proto) { 418 if (bound_function_map->prototype() != *proto) {
417 bound_function_map = Map::TransitionToPrototype(bound_function_map, proto, 419 bound_function_map = Map::TransitionToPrototype(bound_function_map, proto,
418 REGULAR_PROTOTYPE); 420 REGULAR_PROTOTYPE);
419 } 421 }
420 if (bound_function_map->is_constructor() != bindee->IsConstructor()) {
421 bound_function_map = Map::Copy(bound_function_map, "IsConstructor");
422 bound_function_map->set_is_constructor(bindee->IsConstructor());
423 }
424 JSObject::MigrateToMap(bound_function, bound_function_map); 422 JSObject::MigrateToMap(bound_function, bound_function_map);
423 DCHECK_EQ(bindee->IsConstructor(), bound_function->IsConstructor());
425 424
426 Handle<String> length_string = isolate->factory()->length_string(); 425 Handle<String> length_string = isolate->factory()->length_string();
427 // These attributes must be kept in sync with how the bootstrapper 426 // These attributes must be kept in sync with how the bootstrapper
428 // configures the bound_function_map retrieved above. 427 // configures the bound_function_map retrieved above.
429 // We use ...IgnoreAttributes() here because of length's read-onliness. 428 // We use ...IgnoreAttributes() here because of length's read-onliness.
430 PropertyAttributes attr = 429 PropertyAttributes attr =
431 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY); 430 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY);
432 RETURN_FAILURE_ON_EXCEPTION( 431 RETURN_FAILURE_ON_EXCEPTION(
433 isolate, JSObject::SetOwnPropertyIgnoreAttributes( 432 isolate, JSObject::SetOwnPropertyIgnoreAttributes(
434 bound_function, length_string, new_length, attr)); 433 bound_function, length_string, new_length, attr));
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 598
600 599
601 RUNTIME_FUNCTION(Runtime_ThrowStrongModeTooFewArguments) { 600 RUNTIME_FUNCTION(Runtime_ThrowStrongModeTooFewArguments) {
602 HandleScope scope(isolate); 601 HandleScope scope(isolate);
603 DCHECK(args.length() == 0); 602 DCHECK(args.length() == 0);
604 THROW_NEW_ERROR_RETURN_FAILURE(isolate, 603 THROW_NEW_ERROR_RETURN_FAILURE(isolate,
605 NewTypeError(MessageTemplate::kStrongArity)); 604 NewTypeError(MessageTemplate::kStrongArity));
606 } 605 }
607 } // namespace internal 606 } // namespace internal
608 } // namespace v8 607 } // namespace v8
OLDNEW
« no previous file with comments | « src/contexts.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698