OLD | NEW |
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 #if V8_TARGET_ARCH_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
6 | 6 |
7 #include "src/ic/handler-compiler.h" | 7 #include "src/ic/handler-compiler.h" |
8 | 8 |
9 #include "src/api-arguments.h" | 9 #include "src/api-arguments.h" |
10 #include "src/field-type.h" | 10 #include "src/field-type.h" |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 Register object_reg, Register holder_reg, Register scratch1, | 432 Register object_reg, Register holder_reg, Register scratch1, |
433 Register scratch2, Handle<Name> name, Label* miss, PrototypeCheckType check, | 433 Register scratch2, Handle<Name> name, Label* miss, PrototypeCheckType check, |
434 ReturnHolder return_what) { | 434 ReturnHolder return_what) { |
435 Handle<Map> receiver_map = map(); | 435 Handle<Map> receiver_map = map(); |
436 | 436 |
437 // Make sure there's no overlap between holder and object registers. | 437 // Make sure there's no overlap between holder and object registers. |
438 DCHECK(!scratch1.is(object_reg) && !scratch1.is(holder_reg)); | 438 DCHECK(!scratch1.is(object_reg) && !scratch1.is(holder_reg)); |
439 DCHECK(!scratch2.is(object_reg) && !scratch2.is(holder_reg) && | 439 DCHECK(!scratch2.is(object_reg) && !scratch2.is(holder_reg) && |
440 !scratch2.is(scratch1)); | 440 !scratch2.is(scratch1)); |
441 | 441 |
442 if (FLAG_eliminate_prototype_chain_checks) { | 442 Handle<Cell> validity_cell = |
443 Handle<Cell> validity_cell = | 443 Map::GetOrCreatePrototypeChainValidityCell(receiver_map, isolate()); |
444 Map::GetOrCreatePrototypeChainValidityCell(receiver_map, isolate()); | 444 if (!validity_cell.is_null()) { |
445 if (!validity_cell.is_null()) { | 445 DCHECK_EQ(Smi::FromInt(Map::kPrototypeChainValid), validity_cell->value()); |
446 DCHECK_EQ(Smi::FromInt(Map::kPrototypeChainValid), | 446 // Operand::ForCell(...) points to the cell's payload! |
447 validity_cell->value()); | 447 __ cmp(Operand::ForCell(validity_cell), |
448 // Operand::ForCell(...) points to the cell's payload! | 448 Immediate(Smi::FromInt(Map::kPrototypeChainValid))); |
449 __ cmp(Operand::ForCell(validity_cell), | 449 __ j(not_equal, miss); |
450 Immediate(Smi::FromInt(Map::kPrototypeChainValid))); | 450 } |
451 __ j(not_equal, miss); | |
452 } | |
453 | 451 |
454 // The prototype chain of primitives (and their JSValue wrappers) depends | 452 // The prototype chain of primitives (and their JSValue wrappers) depends |
455 // on the native context, which can't be guarded by validity cells. | 453 // on the native context, which can't be guarded by validity cells. |
456 // |object_reg| holds the native context specific prototype in this case; | 454 // |object_reg| holds the native context specific prototype in this case; |
457 // we need to check its map. | 455 // we need to check its map. |
458 if (check == CHECK_ALL_MAPS) { | 456 if (check == CHECK_ALL_MAPS) { |
459 __ mov(scratch1, FieldOperand(object_reg, HeapObject::kMapOffset)); | 457 __ mov(scratch1, FieldOperand(object_reg, HeapObject::kMapOffset)); |
460 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map); | 458 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map); |
461 __ CmpWeakValue(scratch1, cell, scratch2); | 459 __ CmpWeakValue(scratch1, cell, scratch2); |
462 __ j(not_equal, miss); | 460 __ j(not_equal, miss); |
463 } | |
464 } | 461 } |
465 | 462 |
466 // Keep track of the current object in register reg. | 463 // Keep track of the current object in register reg. |
467 Register reg = object_reg; | 464 Register reg = object_reg; |
468 int depth = 0; | 465 int depth = 0; |
469 | 466 |
470 Handle<JSObject> current = Handle<JSObject>::null(); | 467 Handle<JSObject> current = Handle<JSObject>::null(); |
471 if (receiver_map->IsJSGlobalObjectMap()) { | 468 if (receiver_map->IsJSGlobalObjectMap()) { |
472 current = isolate()->global_object(); | 469 current = isolate()->global_object(); |
473 } | 470 } |
(...skipping 15 matching lines...) Expand all Loading... |
489 // fast and global objects or do negative lookup for normal objects. | 486 // fast and global objects or do negative lookup for normal objects. |
490 while (!current_map.is_identical_to(holder_map)) { | 487 while (!current_map.is_identical_to(holder_map)) { |
491 ++depth; | 488 ++depth; |
492 | 489 |
493 // Only global objects and objects that do not require access | 490 // Only global objects and objects that do not require access |
494 // checks are allowed in stubs. | 491 // checks are allowed in stubs. |
495 DCHECK(current_map->IsJSGlobalProxyMap() || | 492 DCHECK(current_map->IsJSGlobalProxyMap() || |
496 !current_map->is_access_check_needed()); | 493 !current_map->is_access_check_needed()); |
497 | 494 |
498 prototype = handle(JSObject::cast(current_map->prototype())); | 495 prototype = handle(JSObject::cast(current_map->prototype())); |
499 if (current_map->is_dictionary_map() && | 496 if (current_map->IsJSGlobalObjectMap()) { |
500 !current_map->IsJSGlobalObjectMap()) { | 497 GenerateCheckPropertyCell(masm(), Handle<JSGlobalObject>::cast(current), |
| 498 name, scratch2, miss); |
| 499 } else if (current_map->is_dictionary_map()) { |
501 DCHECK(!current_map->IsJSGlobalProxyMap()); // Proxy maps are fast. | 500 DCHECK(!current_map->IsJSGlobalProxyMap()); // Proxy maps are fast. |
502 if (!name->IsUniqueName()) { | 501 if (!name->IsUniqueName()) { |
503 DCHECK(name->IsString()); | 502 DCHECK(name->IsString()); |
504 name = factory()->InternalizeString(Handle<String>::cast(name)); | 503 name = factory()->InternalizeString(Handle<String>::cast(name)); |
505 } | 504 } |
506 DCHECK(current.is_null() || | 505 DCHECK(current.is_null() || |
507 current->property_dictionary()->FindEntry(name) == | 506 current->property_dictionary()->FindEntry(name) == |
508 NameDictionary::kNotFound); | 507 NameDictionary::kNotFound); |
509 | 508 |
510 if (FLAG_eliminate_prototype_chain_checks && depth > 1) { | 509 if (depth > 1) { |
511 // TODO(jkummerow): Cache and re-use weak cell. | 510 // TODO(jkummerow): Cache and re-use weak cell. |
512 __ LoadWeakValue(reg, isolate()->factory()->NewWeakCell(current), miss); | 511 __ LoadWeakValue(reg, isolate()->factory()->NewWeakCell(current), miss); |
513 } | 512 } |
514 GenerateDictionaryNegativeLookup(masm(), miss, reg, name, scratch1, | 513 GenerateDictionaryNegativeLookup(masm(), miss, reg, name, scratch1, |
515 scratch2); | 514 scratch2); |
516 | |
517 if (!FLAG_eliminate_prototype_chain_checks) { | |
518 __ mov(scratch1, FieldOperand(reg, HeapObject::kMapOffset)); | |
519 __ mov(holder_reg, FieldOperand(scratch1, Map::kPrototypeOffset)); | |
520 } | |
521 } else { | |
522 Register map_reg = scratch1; | |
523 if (!FLAG_eliminate_prototype_chain_checks) { | |
524 __ mov(map_reg, FieldOperand(reg, HeapObject::kMapOffset)); | |
525 } | |
526 if (current_map->IsJSGlobalObjectMap()) { | |
527 GenerateCheckPropertyCell(masm(), Handle<JSGlobalObject>::cast(current), | |
528 name, scratch2, miss); | |
529 } else if (!FLAG_eliminate_prototype_chain_checks && | |
530 (depth != 1 || check == CHECK_ALL_MAPS)) { | |
531 Handle<WeakCell> cell = Map::WeakCellForMap(current_map); | |
532 __ CmpWeakValue(map_reg, cell, scratch2); | |
533 __ j(not_equal, miss); | |
534 } | |
535 if (!FLAG_eliminate_prototype_chain_checks) { | |
536 __ mov(holder_reg, FieldOperand(map_reg, Map::kPrototypeOffset)); | |
537 } | |
538 } | 515 } |
539 | 516 |
540 reg = holder_reg; // From now on the object will be in holder_reg. | 517 reg = holder_reg; // From now on the object will be in holder_reg. |
541 // Go to the next object in the prototype chain. | 518 // Go to the next object in the prototype chain. |
542 current = prototype; | 519 current = prototype; |
543 current_map = handle(current->map()); | 520 current_map = handle(current->map()); |
544 } | 521 } |
545 | 522 |
546 DCHECK(!current_map->IsJSGlobalProxyMap()); | 523 DCHECK(!current_map->IsJSGlobalProxyMap()); |
547 | 524 |
548 // Log the check depth. | 525 // Log the check depth. |
549 LOG(isolate(), IntEvent("check-maps-depth", depth + 1)); | 526 LOG(isolate(), IntEvent("check-maps-depth", depth + 1)); |
550 | 527 |
551 if (!FLAG_eliminate_prototype_chain_checks && | |
552 (depth != 0 || check == CHECK_ALL_MAPS)) { | |
553 // Check the holder map. | |
554 __ mov(scratch1, FieldOperand(reg, HeapObject::kMapOffset)); | |
555 Handle<WeakCell> cell = Map::WeakCellForMap(current_map); | |
556 __ CmpWeakValue(scratch1, cell, scratch2); | |
557 __ j(not_equal, miss); | |
558 } | |
559 | |
560 bool return_holder = return_what == RETURN_HOLDER; | 528 bool return_holder = return_what == RETURN_HOLDER; |
561 if (FLAG_eliminate_prototype_chain_checks && return_holder && depth != 0) { | 529 if (return_holder && depth != 0) { |
562 __ LoadWeakValue(reg, isolate()->factory()->NewWeakCell(current), miss); | 530 __ LoadWeakValue(reg, isolate()->factory()->NewWeakCell(current), miss); |
563 } | 531 } |
564 | 532 |
565 // Return the register containing the holder. | 533 // Return the register containing the holder. |
566 return return_holder ? reg : no_reg; | 534 return return_holder ? reg : no_reg; |
567 } | 535 } |
568 | 536 |
569 | 537 |
570 void NamedLoadHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) { | 538 void NamedLoadHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) { |
571 if (!miss->is_unused()) { | 539 if (!miss->is_unused()) { |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 // Return the generated code. | 719 // Return the generated code. |
752 return GetCode(kind(), name); | 720 return GetCode(kind(), name); |
753 } | 721 } |
754 | 722 |
755 | 723 |
756 #undef __ | 724 #undef __ |
757 } // namespace internal | 725 } // namespace internal |
758 } // namespace v8 | 726 } // namespace v8 |
759 | 727 |
760 #endif // V8_TARGET_ARCH_IA32 | 728 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |