OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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_S390 | 5 #if V8_TARGET_ARCH_S390 |
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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 Register object_reg, Register holder_reg, Register scratch1, | 399 Register object_reg, Register holder_reg, Register scratch1, |
400 Register scratch2, Handle<Name> name, Label* miss, PrototypeCheckType check, | 400 Register scratch2, Handle<Name> name, Label* miss, PrototypeCheckType check, |
401 ReturnHolder return_what) { | 401 ReturnHolder return_what) { |
402 Handle<Map> receiver_map = map(); | 402 Handle<Map> receiver_map = map(); |
403 | 403 |
404 // Make sure there's no overlap between holder and object registers. | 404 // Make sure there's no overlap between holder and object registers. |
405 DCHECK(!scratch1.is(object_reg) && !scratch1.is(holder_reg)); | 405 DCHECK(!scratch1.is(object_reg) && !scratch1.is(holder_reg)); |
406 DCHECK(!scratch2.is(object_reg) && !scratch2.is(holder_reg) && | 406 DCHECK(!scratch2.is(object_reg) && !scratch2.is(holder_reg) && |
407 !scratch2.is(scratch1)); | 407 !scratch2.is(scratch1)); |
408 | 408 |
409 if (FLAG_eliminate_prototype_chain_checks) { | 409 Handle<Cell> validity_cell = |
410 Handle<Cell> validity_cell = | 410 Map::GetOrCreatePrototypeChainValidityCell(receiver_map, isolate()); |
411 Map::GetOrCreatePrototypeChainValidityCell(receiver_map, isolate()); | 411 if (!validity_cell.is_null()) { |
412 if (!validity_cell.is_null()) { | 412 DCHECK_EQ(Smi::FromInt(Map::kPrototypeChainValid), validity_cell->value()); |
413 DCHECK_EQ(Smi::FromInt(Map::kPrototypeChainValid), | 413 __ mov(scratch1, Operand(validity_cell)); |
414 validity_cell->value()); | 414 __ LoadP(scratch1, FieldMemOperand(scratch1, Cell::kValueOffset)); |
415 __ mov(scratch1, Operand(validity_cell)); | 415 __ CmpSmiLiteral(scratch1, Smi::FromInt(Map::kPrototypeChainValid), r0); |
416 __ LoadP(scratch1, FieldMemOperand(scratch1, Cell::kValueOffset)); | 416 __ bne(miss); |
417 __ CmpSmiLiteral(scratch1, Smi::FromInt(Map::kPrototypeChainValid), r0); | 417 } |
418 __ bne(miss); | |
419 } | |
420 | 418 |
421 // The prototype chain of primitives (and their JSValue wrappers) depends | 419 // The prototype chain of primitives (and their JSValue wrappers) depends |
422 // on the native context, which can't be guarded by validity cells. | 420 // on the native context, which can't be guarded by validity cells. |
423 // |object_reg| holds the native context specific prototype in this case; | 421 // |object_reg| holds the native context specific prototype in this case; |
424 // we need to check its map. | 422 // we need to check its map. |
425 if (check == CHECK_ALL_MAPS) { | 423 if (check == CHECK_ALL_MAPS) { |
426 __ LoadP(scratch1, FieldMemOperand(object_reg, HeapObject::kMapOffset)); | 424 __ LoadP(scratch1, FieldMemOperand(object_reg, HeapObject::kMapOffset)); |
427 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map); | 425 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map); |
428 __ CmpWeakValue(scratch1, cell, scratch2); | 426 __ CmpWeakValue(scratch1, cell, scratch2); |
429 __ b(ne, miss); | 427 __ b(ne, miss); |
430 } | |
431 } | 428 } |
432 | 429 |
433 // Keep track of the current object in register reg. | 430 // Keep track of the current object in register reg. |
434 Register reg = object_reg; | 431 Register reg = object_reg; |
435 int depth = 0; | 432 int depth = 0; |
436 | 433 |
437 Handle<JSObject> current = Handle<JSObject>::null(); | 434 Handle<JSObject> current = Handle<JSObject>::null(); |
438 if (receiver_map->IsJSGlobalObjectMap()) { | 435 if (receiver_map->IsJSGlobalObjectMap()) { |
439 current = isolate()->global_object(); | 436 current = isolate()->global_object(); |
440 } | 437 } |
(...skipping 14 matching lines...) Expand all Loading... |
455 // fast and global objects or do negative lookup for normal objects. | 452 // fast and global objects or do negative lookup for normal objects. |
456 while (!current_map.is_identical_to(holder_map)) { | 453 while (!current_map.is_identical_to(holder_map)) { |
457 ++depth; | 454 ++depth; |
458 | 455 |
459 // Only global objects and objects that do not require access | 456 // Only global objects and objects that do not require access |
460 // checks are allowed in stubs. | 457 // checks are allowed in stubs. |
461 DCHECK(current_map->IsJSGlobalProxyMap() || | 458 DCHECK(current_map->IsJSGlobalProxyMap() || |
462 !current_map->is_access_check_needed()); | 459 !current_map->is_access_check_needed()); |
463 | 460 |
464 prototype = handle(JSObject::cast(current_map->prototype())); | 461 prototype = handle(JSObject::cast(current_map->prototype())); |
465 if (current_map->is_dictionary_map() && | 462 if (current_map->IsJSGlobalObjectMap()) { |
466 !current_map->IsJSGlobalObjectMap()) { | 463 GenerateCheckPropertyCell(masm(), Handle<JSGlobalObject>::cast(current), |
| 464 name, scratch2, miss); |
| 465 } else if (current_map->is_dictionary_map()) { |
467 DCHECK(!current_map->IsJSGlobalProxyMap()); // Proxy maps are fast. | 466 DCHECK(!current_map->IsJSGlobalProxyMap()); // Proxy maps are fast. |
468 if (!name->IsUniqueName()) { | 467 if (!name->IsUniqueName()) { |
469 DCHECK(name->IsString()); | 468 DCHECK(name->IsString()); |
470 name = factory()->InternalizeString(Handle<String>::cast(name)); | 469 name = factory()->InternalizeString(Handle<String>::cast(name)); |
471 } | 470 } |
472 DCHECK(current.is_null() || | 471 DCHECK(current.is_null() || |
473 current->property_dictionary()->FindEntry(name) == | 472 current->property_dictionary()->FindEntry(name) == |
474 NameDictionary::kNotFound); | 473 NameDictionary::kNotFound); |
475 | 474 |
476 if (FLAG_eliminate_prototype_chain_checks && depth > 1) { | 475 if (depth > 1) { |
477 // TODO(jkummerow): Cache and re-use weak cell. | 476 // TODO(jkummerow): Cache and re-use weak cell. |
478 __ LoadWeakValue(reg, isolate()->factory()->NewWeakCell(current), miss); | 477 __ LoadWeakValue(reg, isolate()->factory()->NewWeakCell(current), miss); |
479 } | 478 } |
480 GenerateDictionaryNegativeLookup(masm(), miss, reg, name, scratch1, | 479 GenerateDictionaryNegativeLookup(masm(), miss, reg, name, scratch1, |
481 scratch2); | 480 scratch2); |
482 if (!FLAG_eliminate_prototype_chain_checks) { | |
483 __ LoadP(scratch1, FieldMemOperand(reg, HeapObject::kMapOffset)); | |
484 __ LoadP(holder_reg, FieldMemOperand(scratch1, Map::kPrototypeOffset)); | |
485 } | |
486 } else { | |
487 Register map_reg = scratch1; | |
488 if (!FLAG_eliminate_prototype_chain_checks) { | |
489 __ LoadP(map_reg, FieldMemOperand(reg, HeapObject::kMapOffset)); | |
490 } | |
491 if (current_map->IsJSGlobalObjectMap()) { | |
492 GenerateCheckPropertyCell(masm(), Handle<JSGlobalObject>::cast(current), | |
493 name, scratch2, miss); | |
494 } else if (!FLAG_eliminate_prototype_chain_checks && | |
495 (depth != 1 || check == CHECK_ALL_MAPS)) { | |
496 Handle<WeakCell> cell = Map::WeakCellForMap(current_map); | |
497 __ CmpWeakValue(map_reg, cell, scratch2); | |
498 __ bne(miss); | |
499 } | |
500 if (!FLAG_eliminate_prototype_chain_checks) { | |
501 __ LoadP(holder_reg, FieldMemOperand(map_reg, Map::kPrototypeOffset)); | |
502 } | |
503 } | 481 } |
504 | 482 |
505 reg = holder_reg; // From now on the object will be in holder_reg. | 483 reg = holder_reg; // From now on the object will be in holder_reg. |
506 // Go to the next object in the prototype chain. | 484 // Go to the next object in the prototype chain. |
507 current = prototype; | 485 current = prototype; |
508 current_map = handle(current->map()); | 486 current_map = handle(current->map()); |
509 } | 487 } |
510 | 488 |
511 DCHECK(!current_map->IsJSGlobalProxyMap()); | 489 DCHECK(!current_map->IsJSGlobalProxyMap()); |
512 | 490 |
513 // Log the check depth. | 491 // Log the check depth. |
514 LOG(isolate(), IntEvent("check-maps-depth", depth + 1)); | 492 LOG(isolate(), IntEvent("check-maps-depth", depth + 1)); |
515 | 493 |
516 if (!FLAG_eliminate_prototype_chain_checks && | |
517 (depth != 0 || check == CHECK_ALL_MAPS)) { | |
518 // Check the holder map. | |
519 __ LoadP(scratch1, FieldMemOperand(reg, HeapObject::kMapOffset)); | |
520 Handle<WeakCell> cell = Map::WeakCellForMap(current_map); | |
521 __ CmpWeakValue(scratch1, cell, scratch2); | |
522 __ bne(miss); | |
523 } | |
524 | |
525 bool return_holder = return_what == RETURN_HOLDER; | 494 bool return_holder = return_what == RETURN_HOLDER; |
526 if (FLAG_eliminate_prototype_chain_checks && return_holder && depth != 0) { | 495 if (return_holder && depth != 0) { |
527 __ LoadWeakValue(reg, isolate()->factory()->NewWeakCell(current), miss); | 496 __ LoadWeakValue(reg, isolate()->factory()->NewWeakCell(current), miss); |
528 } | 497 } |
529 | 498 |
530 // Return the register containing the holder. | 499 // Return the register containing the holder. |
531 return return_holder ? reg : no_reg; | 500 return return_holder ? reg : no_reg; |
532 } | 501 } |
533 | 502 |
534 void NamedLoadHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) { | 503 void NamedLoadHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) { |
535 if (!miss->is_unused()) { | 504 if (!miss->is_unused()) { |
536 Label success; | 505 Label success; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 | 661 |
693 // Return the generated code. | 662 // Return the generated code. |
694 return GetCode(kind(), name); | 663 return GetCode(kind(), name); |
695 } | 664 } |
696 | 665 |
697 #undef __ | 666 #undef __ |
698 } // namespace internal | 667 } // namespace internal |
699 } // namespace v8 | 668 } // namespace v8 |
700 | 669 |
701 #endif // V8_TARGET_ARCH_ARM | 670 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |