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

Side by Side Diff: src/ic/ia32/handler-compiler-ia32.cc

Issue 908213002: Use Cells to check prototype chain validity (disabled by default). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebased onto dropped prototype_object Created 5 years, 8 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
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/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_IA32 7 #if V8_TARGET_ARCH_IA32
8 8
9 #include "src/ic/call-optimization.h" 9 #include "src/ic/call-optimization.h"
10 #include "src/ic/handler-compiler.h" 10 #include "src/ic/handler-compiler.h"
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 } 407 }
408 __ j(equal, &do_store, Label::kNear); 408 __ j(equal, &do_store, Label::kNear);
409 } 409 }
410 __ bind(&do_store); 410 __ bind(&do_store);
411 } 411 }
412 } 412 }
413 413
414 414
415 Register PropertyHandlerCompiler::CheckPrototypes( 415 Register PropertyHandlerCompiler::CheckPrototypes(
416 Register object_reg, Register holder_reg, Register scratch1, 416 Register object_reg, Register holder_reg, Register scratch1,
417 Register scratch2, Handle<Name> name, Label* miss, 417 Register scratch2, Handle<Name> name, Label* miss, PrototypeCheckType check,
418 PrototypeCheckType check) { 418 ReturnHolder return_what) {
419 Handle<Map> receiver_map = map(); 419 Handle<Map> receiver_map = map();
420 420
421 // Make sure there's no overlap between holder and object registers. 421 // Make sure there's no overlap between holder and object registers.
422 DCHECK(!scratch1.is(object_reg) && !scratch1.is(holder_reg)); 422 DCHECK(!scratch1.is(object_reg) && !scratch1.is(holder_reg));
423 DCHECK(!scratch2.is(object_reg) && !scratch2.is(holder_reg) && 423 DCHECK(!scratch2.is(object_reg) && !scratch2.is(holder_reg) &&
424 !scratch2.is(scratch1)); 424 !scratch2.is(scratch1));
425 425
426 if (FLAG_eliminate_prototype_chain_checks) {
427 Handle<Cell> validity_cell =
428 Map::GetOrCreatePrototypeChainValidityCell(receiver_map, isolate());
429 if (!validity_cell.is_null()) {
430 DCHECK(validity_cell->value() == Smi::FromInt(Map::kPrototypeChainValid));
431 // Operand::ForCell(...) points to the cell's payload!
432 __ cmp(Operand::ForCell(validity_cell),
433 Immediate(Smi::FromInt(Map::kPrototypeChainValid)));
434 __ j(not_equal, miss);
435 }
436
437 // The prototype chain of primitives (and their JSValue wrappers) depends
438 // on the native context, which can't be guarded by validity cells.
439 // |object_reg| holds the native context specific prototype in this case;
440 // we need to check its map.
441 if (check == CHECK_ALL_MAPS) {
442 __ mov(scratch1, FieldOperand(object_reg, HeapObject::kMapOffset));
443 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map);
444 __ CmpWeakValue(scratch1, cell, scratch2);
445 __ j(not_equal, miss);
446 }
447 }
448
426 // Keep track of the current object in register reg. 449 // Keep track of the current object in register reg.
427 Register reg = object_reg; 450 Register reg = object_reg;
428 int depth = 0; 451 int depth = 0;
429 452
430 Handle<JSObject> current = Handle<JSObject>::null(); 453 Handle<JSObject> current = Handle<JSObject>::null();
431 if (receiver_map->IsJSGlobalObjectMap()) { 454 if (receiver_map->IsJSGlobalObjectMap()) {
432 current = isolate()->global_object(); 455 current = isolate()->global_object();
433 } 456 }
434 457
435 // Check access rights to the global object. This has to happen after 458 // Check access rights to the global object. This has to happen after
(...skipping 24 matching lines...) Expand all
460 !current_map->IsJSGlobalObjectMap()) { 483 !current_map->IsJSGlobalObjectMap()) {
461 DCHECK(!current_map->IsJSGlobalProxyMap()); // Proxy maps are fast. 484 DCHECK(!current_map->IsJSGlobalProxyMap()); // Proxy maps are fast.
462 if (!name->IsUniqueName()) { 485 if (!name->IsUniqueName()) {
463 DCHECK(name->IsString()); 486 DCHECK(name->IsString());
464 name = factory()->InternalizeString(Handle<String>::cast(name)); 487 name = factory()->InternalizeString(Handle<String>::cast(name));
465 } 488 }
466 DCHECK(current.is_null() || 489 DCHECK(current.is_null() ||
467 current->property_dictionary()->FindEntry(name) == 490 current->property_dictionary()->FindEntry(name) ==
468 NameDictionary::kNotFound); 491 NameDictionary::kNotFound);
469 492
493 if (FLAG_eliminate_prototype_chain_checks && depth > 1) {
494 // TODO(jkummerow): Cache and re-use weak cell.
495 __ LoadWeakValue(reg, isolate()->factory()->NewWeakCell(current), miss);
496 }
470 GenerateDictionaryNegativeLookup(masm(), miss, reg, name, scratch1, 497 GenerateDictionaryNegativeLookup(masm(), miss, reg, name, scratch1,
471 scratch2); 498 scratch2);
472 499
473 __ mov(scratch1, FieldOperand(reg, HeapObject::kMapOffset)); 500 if (!FLAG_eliminate_prototype_chain_checks) {
474 reg = holder_reg; // From now on the object will be in holder_reg. 501 __ mov(scratch1, FieldOperand(reg, HeapObject::kMapOffset));
475 __ mov(reg, FieldOperand(scratch1, Map::kPrototypeOffset)); 502 __ mov(holder_reg, FieldOperand(scratch1, Map::kPrototypeOffset));
503 }
476 } else { 504 } else {
477 Register map_reg = scratch1; 505 Register map_reg = scratch1;
478 __ mov(map_reg, FieldOperand(reg, HeapObject::kMapOffset)); 506 if (!FLAG_eliminate_prototype_chain_checks) {
507 __ mov(map_reg, FieldOperand(reg, HeapObject::kMapOffset));
508 }
479 if (current_map->IsJSGlobalObjectMap()) { 509 if (current_map->IsJSGlobalObjectMap()) {
480 GenerateCheckPropertyCell(masm(), Handle<JSGlobalObject>::cast(current), 510 GenerateCheckPropertyCell(masm(), Handle<JSGlobalObject>::cast(current),
481 name, scratch2, miss); 511 name, scratch2, miss);
482 } else if (depth != 1 || check == CHECK_ALL_MAPS) { 512 } else if (!FLAG_eliminate_prototype_chain_checks &&
513 (depth != 1 || check == CHECK_ALL_MAPS)) {
483 Handle<WeakCell> cell = Map::WeakCellForMap(current_map); 514 Handle<WeakCell> cell = Map::WeakCellForMap(current_map);
484 __ CmpWeakValue(map_reg, cell, scratch2); 515 __ CmpWeakValue(map_reg, cell, scratch2);
485 __ j(not_equal, miss); 516 __ j(not_equal, miss);
486 } 517 }
487 518 if (!FLAG_eliminate_prototype_chain_checks) {
488 reg = holder_reg; // From now on the object will be in holder_reg. 519 __ mov(holder_reg, FieldOperand(map_reg, Map::kPrototypeOffset));
489 __ mov(reg, FieldOperand(map_reg, Map::kPrototypeOffset)); 520 }
490 } 521 }
491 522
523 reg = holder_reg; // From now on the object will be in holder_reg.
492 // Go to the next object in the prototype chain. 524 // Go to the next object in the prototype chain.
493 current = prototype; 525 current = prototype;
494 current_map = handle(current->map()); 526 current_map = handle(current->map());
495 } 527 }
496 528
497 DCHECK(!current_map->IsJSGlobalProxyMap()); 529 DCHECK(!current_map->IsJSGlobalProxyMap());
498 530
499 // Log the check depth. 531 // Log the check depth.
500 LOG(isolate(), IntEvent("check-maps-depth", depth + 1)); 532 LOG(isolate(), IntEvent("check-maps-depth", depth + 1));
501 533
502 if (depth != 0 || check == CHECK_ALL_MAPS) { 534 if (!FLAG_eliminate_prototype_chain_checks &&
535 (depth != 0 || check == CHECK_ALL_MAPS)) {
503 // Check the holder map. 536 // Check the holder map.
504 __ mov(scratch1, FieldOperand(reg, HeapObject::kMapOffset)); 537 __ mov(scratch1, FieldOperand(reg, HeapObject::kMapOffset));
505 Handle<WeakCell> cell = Map::WeakCellForMap(current_map); 538 Handle<WeakCell> cell = Map::WeakCellForMap(current_map);
506 __ CmpWeakValue(scratch1, cell, scratch2); 539 __ CmpWeakValue(scratch1, cell, scratch2);
507 __ j(not_equal, miss); 540 __ j(not_equal, miss);
508 } 541 }
509 542
543 bool return_holder = return_what == RETURN_HOLDER;
544 if (FLAG_eliminate_prototype_chain_checks && return_holder && depth != 0) {
545 __ LoadWeakValue(reg, isolate()->factory()->NewWeakCell(current), miss);
546 }
547
510 // Return the register containing the holder. 548 // Return the register containing the holder.
511 return reg; 549 return return_holder ? reg : no_reg;
512 } 550 }
513 551
514 552
515 void NamedLoadHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) { 553 void NamedLoadHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
516 if (!miss->is_unused()) { 554 if (!miss->is_unused()) {
517 Label success; 555 Label success;
518 __ jmp(&success); 556 __ jmp(&success);
519 __ bind(miss); 557 __ bind(miss);
520 if (IC::ICUseVector(kind())) { 558 if (IC::ICUseVector(kind())) {
521 DCHECK(kind() == Code::LOAD_IC); 559 DCHECK(kind() == Code::LOAD_IC);
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 return StoreDescriptor::ValueRegister(); 769 return StoreDescriptor::ValueRegister();
732 } 770 }
733 771
734 772
735 Handle<Code> NamedLoadHandlerCompiler::CompileLoadGlobal( 773 Handle<Code> NamedLoadHandlerCompiler::CompileLoadGlobal(
736 Handle<PropertyCell> cell, Handle<Name> name, bool is_configurable) { 774 Handle<PropertyCell> cell, Handle<Name> name, bool is_configurable) {
737 Label miss; 775 Label miss;
738 if (IC::ICUseVector(kind())) { 776 if (IC::ICUseVector(kind())) {
739 PushVectorAndSlot(); 777 PushVectorAndSlot();
740 } 778 }
741 FrontendHeader(receiver(), name, &miss); 779 FrontendHeader(receiver(), name, &miss, DONT_RETURN_ANYTHING);
742 // Get the value from the cell. 780 // Get the value from the cell.
743 Register result = StoreDescriptor::ValueRegister(); 781 Register result = StoreDescriptor::ValueRegister();
744 Handle<WeakCell> weak_cell = factory()->NewWeakCell(cell); 782 Handle<WeakCell> weak_cell = factory()->NewWeakCell(cell);
745 __ LoadWeakValue(result, weak_cell, &miss); 783 __ LoadWeakValue(result, weak_cell, &miss);
746 __ mov(result, FieldOperand(result, PropertyCell::kValueOffset)); 784 __ mov(result, FieldOperand(result, PropertyCell::kValueOffset));
747 785
748 // Check for deleted property if property can actually be deleted. 786 // Check for deleted property if property can actually be deleted.
749 if (is_configurable) { 787 if (is_configurable) {
750 __ cmp(result, factory()->the_hole_value()); 788 __ cmp(result, factory()->the_hole_value());
751 __ j(equal, &miss); 789 __ j(equal, &miss);
(...skipping 15 matching lines...) Expand all
767 // Return the generated code. 805 // Return the generated code.
768 return GetCode(kind(), Code::NORMAL, name); 806 return GetCode(kind(), Code::NORMAL, name);
769 } 807 }
770 808
771 809
772 #undef __ 810 #undef __
773 } 811 }
774 } // namespace v8::internal 812 } // namespace v8::internal
775 813
776 #endif // V8_TARGET_ARCH_IA32 814 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698