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_PPC | 5 #if V8_TARGET_ARCH_PPC |
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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 Register object_reg, Register holder_reg, Register scratch1, | 425 Register object_reg, Register holder_reg, Register scratch1, |
426 Register scratch2, Handle<Name> name, Label* miss, PrototypeCheckType check, | 426 Register scratch2, Handle<Name> name, Label* miss, PrototypeCheckType check, |
427 ReturnHolder return_what) { | 427 ReturnHolder return_what) { |
428 Handle<Map> receiver_map = map(); | 428 Handle<Map> receiver_map = map(); |
429 | 429 |
430 // Make sure there's no overlap between holder and object registers. | 430 // Make sure there's no overlap between holder and object registers. |
431 DCHECK(!scratch1.is(object_reg) && !scratch1.is(holder_reg)); | 431 DCHECK(!scratch1.is(object_reg) && !scratch1.is(holder_reg)); |
432 DCHECK(!scratch2.is(object_reg) && !scratch2.is(holder_reg) && | 432 DCHECK(!scratch2.is(object_reg) && !scratch2.is(holder_reg) && |
433 !scratch2.is(scratch1)); | 433 !scratch2.is(scratch1)); |
434 | 434 |
435 if (FLAG_eliminate_prototype_chain_checks) { | 435 Handle<Cell> validity_cell = |
436 Handle<Cell> validity_cell = | 436 Map::GetOrCreatePrototypeChainValidityCell(receiver_map, isolate()); |
437 Map::GetOrCreatePrototypeChainValidityCell(receiver_map, isolate()); | 437 if (!validity_cell.is_null()) { |
438 if (!validity_cell.is_null()) { | 438 DCHECK_EQ(Smi::FromInt(Map::kPrototypeChainValid), validity_cell->value()); |
439 DCHECK_EQ(Smi::FromInt(Map::kPrototypeChainValid), | 439 __ mov(scratch1, Operand(validity_cell)); |
440 validity_cell->value()); | 440 __ LoadP(scratch1, FieldMemOperand(scratch1, Cell::kValueOffset)); |
441 __ mov(scratch1, Operand(validity_cell)); | 441 __ CmpSmiLiteral(scratch1, Smi::FromInt(Map::kPrototypeChainValid), r0); |
442 __ LoadP(scratch1, FieldMemOperand(scratch1, Cell::kValueOffset)); | 442 __ bne(miss); |
443 __ CmpSmiLiteral(scratch1, Smi::FromInt(Map::kPrototypeChainValid), r0); | 443 } |
444 __ bne(miss); | |
445 } | |
446 | 444 |
447 // The prototype chain of primitives (and their JSValue wrappers) depends | 445 // The prototype chain of primitives (and their JSValue wrappers) depends |
448 // on the native context, which can't be guarded by validity cells. | 446 // on the native context, which can't be guarded by validity cells. |
449 // |object_reg| holds the native context specific prototype in this case; | 447 // |object_reg| holds the native context specific prototype in this case; |
450 // we need to check its map. | 448 // we need to check its map. |
451 if (check == CHECK_ALL_MAPS) { | 449 if (check == CHECK_ALL_MAPS) { |
452 __ LoadP(scratch1, FieldMemOperand(object_reg, HeapObject::kMapOffset)); | 450 __ LoadP(scratch1, FieldMemOperand(object_reg, HeapObject::kMapOffset)); |
453 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map); | 451 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map); |
454 __ CmpWeakValue(scratch1, cell, scratch2); | 452 __ CmpWeakValue(scratch1, cell, scratch2); |
455 __ b(ne, miss); | 453 __ b(ne, miss); |
456 } | |
457 } | 454 } |
458 | 455 |
459 // Keep track of the current object in register reg. | 456 // Keep track of the current object in register reg. |
460 Register reg = object_reg; | 457 Register reg = object_reg; |
461 int depth = 0; | 458 int depth = 0; |
462 | 459 |
463 Handle<JSObject> current = Handle<JSObject>::null(); | 460 Handle<JSObject> current = Handle<JSObject>::null(); |
464 if (receiver_map->IsJSGlobalObjectMap()) { | 461 if (receiver_map->IsJSGlobalObjectMap()) { |
465 current = isolate()->global_object(); | 462 current = isolate()->global_object(); |
466 } | 463 } |
(...skipping 14 matching lines...) Expand all Loading... |
481 // fast and global objects or do negative lookup for normal objects. | 478 // fast and global objects or do negative lookup for normal objects. |
482 while (!current_map.is_identical_to(holder_map)) { | 479 while (!current_map.is_identical_to(holder_map)) { |
483 ++depth; | 480 ++depth; |
484 | 481 |
485 // Only global objects and objects that do not require access | 482 // Only global objects and objects that do not require access |
486 // checks are allowed in stubs. | 483 // checks are allowed in stubs. |
487 DCHECK(current_map->IsJSGlobalProxyMap() || | 484 DCHECK(current_map->IsJSGlobalProxyMap() || |
488 !current_map->is_access_check_needed()); | 485 !current_map->is_access_check_needed()); |
489 | 486 |
490 prototype = handle(JSObject::cast(current_map->prototype())); | 487 prototype = handle(JSObject::cast(current_map->prototype())); |
491 if (current_map->is_dictionary_map() && | 488 if (current_map->IsJSGlobalObjectMap()) { |
492 !current_map->IsJSGlobalObjectMap()) { | 489 GenerateCheckPropertyCell(masm(), Handle<JSGlobalObject>::cast(current), |
| 490 name, scratch2, miss); |
| 491 } else if (current_map->is_dictionary_map()) { |
493 DCHECK(!current_map->IsJSGlobalProxyMap()); // Proxy maps are fast. | 492 DCHECK(!current_map->IsJSGlobalProxyMap()); // Proxy maps are fast. |
494 if (!name->IsUniqueName()) { | 493 if (!name->IsUniqueName()) { |
495 DCHECK(name->IsString()); | 494 DCHECK(name->IsString()); |
496 name = factory()->InternalizeString(Handle<String>::cast(name)); | 495 name = factory()->InternalizeString(Handle<String>::cast(name)); |
497 } | 496 } |
498 DCHECK(current.is_null() || | 497 DCHECK(current.is_null() || |
499 current->property_dictionary()->FindEntry(name) == | 498 current->property_dictionary()->FindEntry(name) == |
500 NameDictionary::kNotFound); | 499 NameDictionary::kNotFound); |
501 | 500 |
502 if (FLAG_eliminate_prototype_chain_checks && depth > 1) { | 501 if (depth > 1) { |
503 // TODO(jkummerow): Cache and re-use weak cell. | 502 // TODO(jkummerow): Cache and re-use weak cell. |
504 __ LoadWeakValue(reg, isolate()->factory()->NewWeakCell(current), miss); | 503 __ LoadWeakValue(reg, isolate()->factory()->NewWeakCell(current), miss); |
505 } | 504 } |
506 GenerateDictionaryNegativeLookup(masm(), miss, reg, name, scratch1, | 505 GenerateDictionaryNegativeLookup(masm(), miss, reg, name, scratch1, |
507 scratch2); | 506 scratch2); |
508 if (!FLAG_eliminate_prototype_chain_checks) { | |
509 __ LoadP(scratch1, FieldMemOperand(reg, HeapObject::kMapOffset)); | |
510 __ LoadP(holder_reg, FieldMemOperand(scratch1, Map::kPrototypeOffset)); | |
511 } | |
512 } else { | |
513 Register map_reg = scratch1; | |
514 if (!FLAG_eliminate_prototype_chain_checks) { | |
515 __ LoadP(map_reg, FieldMemOperand(reg, HeapObject::kMapOffset)); | |
516 } | |
517 if (current_map->IsJSGlobalObjectMap()) { | |
518 GenerateCheckPropertyCell(masm(), Handle<JSGlobalObject>::cast(current), | |
519 name, scratch2, miss); | |
520 } else if (!FLAG_eliminate_prototype_chain_checks && | |
521 (depth != 1 || check == CHECK_ALL_MAPS)) { | |
522 Handle<WeakCell> cell = Map::WeakCellForMap(current_map); | |
523 __ CmpWeakValue(map_reg, cell, scratch2); | |
524 __ bne(miss); | |
525 } | |
526 if (!FLAG_eliminate_prototype_chain_checks) { | |
527 __ LoadP(holder_reg, FieldMemOperand(map_reg, Map::kPrototypeOffset)); | |
528 } | |
529 } | 507 } |
530 | 508 |
531 reg = holder_reg; // From now on the object will be in holder_reg. | 509 reg = holder_reg; // From now on the object will be in holder_reg. |
532 // Go to the next object in the prototype chain. | 510 // Go to the next object in the prototype chain. |
533 current = prototype; | 511 current = prototype; |
534 current_map = handle(current->map()); | 512 current_map = handle(current->map()); |
535 } | 513 } |
536 | 514 |
537 DCHECK(!current_map->IsJSGlobalProxyMap()); | 515 DCHECK(!current_map->IsJSGlobalProxyMap()); |
538 | 516 |
539 // Log the check depth. | 517 // Log the check depth. |
540 LOG(isolate(), IntEvent("check-maps-depth", depth + 1)); | 518 LOG(isolate(), IntEvent("check-maps-depth", depth + 1)); |
541 | 519 |
542 if (!FLAG_eliminate_prototype_chain_checks && | |
543 (depth != 0 || check == CHECK_ALL_MAPS)) { | |
544 // Check the holder map. | |
545 __ LoadP(scratch1, FieldMemOperand(reg, HeapObject::kMapOffset)); | |
546 Handle<WeakCell> cell = Map::WeakCellForMap(current_map); | |
547 __ CmpWeakValue(scratch1, cell, scratch2); | |
548 __ bne(miss); | |
549 } | |
550 | |
551 bool return_holder = return_what == RETURN_HOLDER; | 520 bool return_holder = return_what == RETURN_HOLDER; |
552 if (FLAG_eliminate_prototype_chain_checks && return_holder && depth != 0) { | 521 if (return_holder && depth != 0) { |
553 __ LoadWeakValue(reg, isolate()->factory()->NewWeakCell(current), miss); | 522 __ LoadWeakValue(reg, isolate()->factory()->NewWeakCell(current), miss); |
554 } | 523 } |
555 | 524 |
556 // Return the register containing the holder. | 525 // Return the register containing the holder. |
557 return return_holder ? reg : no_reg; | 526 return return_holder ? reg : no_reg; |
558 } | 527 } |
559 | 528 |
560 | 529 |
561 void NamedLoadHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) { | 530 void NamedLoadHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) { |
562 if (!miss->is_unused()) { | 531 if (!miss->is_unused()) { |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 // Return the generated code. | 698 // Return the generated code. |
730 return GetCode(kind(), name); | 699 return GetCode(kind(), name); |
731 } | 700 } |
732 | 701 |
733 | 702 |
734 #undef __ | 703 #undef __ |
735 } // namespace internal | 704 } // namespace internal |
736 } // namespace v8 | 705 } // namespace v8 |
737 | 706 |
738 #endif // V8_TARGET_ARCH_ARM | 707 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |