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