OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/code-stubs.h" | 5 #include "src/code-stubs.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 Node* receiver = assembler->Parameter(Descriptor::kReceiver); | 491 Node* receiver = assembler->Parameter(Descriptor::kReceiver); |
492 Node* name = assembler->Parameter(Descriptor::kName); | 492 Node* name = assembler->Parameter(Descriptor::kName); |
493 Node* slot = assembler->Parameter(Descriptor::kSlot); | 493 Node* slot = assembler->Parameter(Descriptor::kSlot); |
494 Node* vector = assembler->Parameter(Descriptor::kVector); | 494 Node* vector = assembler->Parameter(Descriptor::kVector); |
495 Node* context = assembler->Parameter(Descriptor::kContext); | 495 Node* context = assembler->Parameter(Descriptor::kContext); |
496 | 496 |
497 CodeStubAssembler::LoadICParameters p(context, receiver, name, slot, vector); | 497 CodeStubAssembler::LoadICParameters p(context, receiver, name, slot, vector); |
498 assembler->KeyedLoadIC(&p); | 498 assembler->KeyedLoadIC(&p); |
499 } | 499 } |
500 | 500 |
| 501 void StoreTransitionStub::GenerateAssembly(CodeStubAssembler* assembler) const { |
| 502 typedef CodeStubAssembler::Label Label; |
| 503 typedef compiler::Node Node; |
| 504 |
| 505 Node* receiver = assembler->Parameter(Descriptor::kReceiver); |
| 506 Node* name = assembler->Parameter(Descriptor::kName); |
| 507 Node* value = assembler->Parameter(Descriptor::kValue); |
| 508 Node* map = assembler->Parameter(Descriptor::kMap); |
| 509 Node* slot = assembler->Parameter(Descriptor::kSlot); |
| 510 Node* vector = assembler->Parameter(Descriptor::kVector); |
| 511 Node* context = assembler->Parameter(Descriptor::kContext); |
| 512 |
| 513 StoreMode store_mode = this->store_mode(); |
| 514 Node* prepared_value = value; |
| 515 |
| 516 Label miss(assembler); |
| 517 bool needs_miss_case = false; |
| 518 |
| 519 if (store_mode != StoreTransitionStub::StoreMapOnly) { |
| 520 Representation representation = this->representation(); |
| 521 FieldIndex index = this->index(); |
| 522 assembler->Comment( |
| 523 "Prepare value for write: representation: %s, index.is_inobject: %d, " |
| 524 "index.offset: %d", |
| 525 representation.Mnemonic(), index.is_inobject(), index.offset()); |
| 526 prepared_value = |
| 527 assembler->PrepareValueForWrite(prepared_value, representation, &miss); |
| 528 // Only store to tagged field never bails out. |
| 529 needs_miss_case |= !representation.IsTagged(); |
| 530 } |
| 531 |
| 532 switch (store_mode) { |
| 533 case StoreTransitionStub::ExtendStorageAndStoreMapAndValue: |
| 534 assembler->Comment("Extend storage"); |
| 535 assembler->ExtendPropertiesBackingStore(receiver); |
| 536 // Fall through. |
| 537 case StoreTransitionStub::StoreMapAndValue: |
| 538 assembler->Comment("Store value"); |
| 539 // Store the new value into the "extended" object. |
| 540 assembler->StoreNamedField(receiver, index(), representation(), |
| 541 prepared_value, true); |
| 542 // Fall through. |
| 543 case StoreTransitionStub::StoreMapOnly: |
| 544 assembler->Comment("Store map"); |
| 545 // And finally update the map. |
| 546 assembler->StoreObjectField(receiver, JSObject::kMapOffset, map); |
| 547 break; |
| 548 } |
| 549 assembler->Return(value); |
| 550 |
| 551 if (needs_miss_case) { |
| 552 assembler->Bind(&miss); |
| 553 { |
| 554 assembler->Comment("Miss"); |
| 555 assembler->TailCallRuntime(Runtime::kStoreIC_Miss, context, receiver, |
| 556 name, value, slot, vector); |
| 557 } |
| 558 } |
| 559 } |
| 560 |
| 561 void ElementsTransitionAndStoreStub::GenerateAssembly( |
| 562 CodeStubAssembler* assembler) const { |
| 563 typedef CodeStubAssembler::Label Label; |
| 564 typedef compiler::Node Node; |
| 565 |
| 566 Node* receiver = assembler->Parameter(Descriptor::kReceiver); |
| 567 Node* key = assembler->Parameter(Descriptor::kName); |
| 568 Node* value = assembler->Parameter(Descriptor::kValue); |
| 569 Node* map = assembler->Parameter(Descriptor::kMap); |
| 570 Node* slot = assembler->Parameter(Descriptor::kSlot); |
| 571 Node* vector = assembler->Parameter(Descriptor::kVector); |
| 572 Node* context = assembler->Parameter(Descriptor::kContext); |
| 573 |
| 574 assembler->Comment( |
| 575 "ElementsTransitionAndStoreStub: from_kind=%s, to_kind=%s," |
| 576 " is_jsarray=%d, store_mode=%d", |
| 577 ElementsKindToString(from_kind()), ElementsKindToString(to_kind()), |
| 578 is_jsarray(), store_mode()); |
| 579 |
| 580 Label miss(assembler); |
| 581 |
| 582 if (FLAG_trace_elements_transitions) { |
| 583 // Tracing elements transitions is the job of the runtime. |
| 584 assembler->Goto(&miss); |
| 585 } else { |
| 586 assembler->TransitionElementsKind(receiver, map, from_kind(), to_kind(), |
| 587 is_jsarray(), &miss); |
| 588 assembler->EmitElementStore(receiver, key, value, is_jsarray(), to_kind(), |
| 589 store_mode(), &miss); |
| 590 assembler->Return(value); |
| 591 } |
| 592 |
| 593 assembler->Bind(&miss); |
| 594 { |
| 595 assembler->Comment("Miss"); |
| 596 assembler->TailCallRuntime(Runtime::kElementsTransitionAndStoreIC_Miss, |
| 597 context, receiver, key, value, map, slot, |
| 598 vector); |
| 599 } |
| 600 } |
| 601 |
501 void AllocateHeapNumberStub::GenerateAssembly( | 602 void AllocateHeapNumberStub::GenerateAssembly( |
502 CodeStubAssembler* assembler) const { | 603 CodeStubAssembler* assembler) const { |
503 typedef compiler::Node Node; | 604 typedef compiler::Node Node; |
504 | 605 |
505 Node* result = assembler->AllocateHeapNumber(); | 606 Node* result = assembler->AllocateHeapNumber(); |
506 assembler->Return(result); | 607 assembler->Return(result); |
507 } | 608 } |
508 | 609 |
509 #define SIMD128_GEN_ASM(TYPE, Type, type, lane_count, lane_type) \ | 610 #define SIMD128_GEN_ASM(TYPE, Type, type, lane_count, lane_type) \ |
510 void Allocate##Type##Stub::GenerateAssembly(CodeStubAssembler* assembler) \ | 611 void Allocate##Type##Stub::GenerateAssembly(CodeStubAssembler* assembler) \ |
(...skipping 4604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5115 CallInterfaceDescriptor HandlerStub::GetCallInterfaceDescriptor() const { | 5216 CallInterfaceDescriptor HandlerStub::GetCallInterfaceDescriptor() const { |
5116 if (kind() == Code::LOAD_IC || kind() == Code::KEYED_LOAD_IC) { | 5217 if (kind() == Code::LOAD_IC || kind() == Code::KEYED_LOAD_IC) { |
5117 return LoadWithVectorDescriptor(isolate()); | 5218 return LoadWithVectorDescriptor(isolate()); |
5118 } else { | 5219 } else { |
5119 DCHECK(kind() == Code::STORE_IC || kind() == Code::KEYED_STORE_IC); | 5220 DCHECK(kind() == Code::STORE_IC || kind() == Code::KEYED_STORE_IC); |
5120 return StoreWithVectorDescriptor(isolate()); | 5221 return StoreWithVectorDescriptor(isolate()); |
5121 } | 5222 } |
5122 } | 5223 } |
5123 | 5224 |
5124 | 5225 |
5125 void ElementsTransitionAndStoreStub::InitializeDescriptor( | |
5126 CodeStubDescriptor* descriptor) { | |
5127 descriptor->Initialize( | |
5128 FUNCTION_ADDR(Runtime_ElementsTransitionAndStoreIC_Miss)); | |
5129 } | |
5130 | |
5131 void StoreTransitionStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | |
5132 descriptor->Initialize( | |
5133 FUNCTION_ADDR(Runtime_TransitionStoreIC_MissFromStubFailure)); | |
5134 } | |
5135 | |
5136 void NumberToStringStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | 5226 void NumberToStringStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
5137 descriptor->Initialize( | 5227 descriptor->Initialize( |
5138 Runtime::FunctionForId(Runtime::kNumberToString)->entry); | 5228 Runtime::FunctionForId(Runtime::kNumberToString)->entry); |
5139 descriptor->SetMissHandler(Runtime::kNumberToString); | 5229 descriptor->SetMissHandler(Runtime::kNumberToString); |
5140 } | 5230 } |
5141 | 5231 |
5142 | 5232 |
5143 void FastCloneShallowArrayStub::InitializeDescriptor( | 5233 void FastCloneShallowArrayStub::InitializeDescriptor( |
5144 CodeStubDescriptor* descriptor) { | 5234 CodeStubDescriptor* descriptor) { |
5145 FastCloneShallowArrayDescriptor call_descriptor(isolate()); | 5235 FastCloneShallowArrayDescriptor call_descriptor(isolate()); |
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6034 | 6124 |
6035 if (type == MachineType::Pointer()) { | 6125 if (type == MachineType::Pointer()) { |
6036 return Representation::External(); | 6126 return Representation::External(); |
6037 } | 6127 } |
6038 | 6128 |
6039 return Representation::Tagged(); | 6129 return Representation::Tagged(); |
6040 } | 6130 } |
6041 | 6131 |
6042 } // namespace internal | 6132 } // namespace internal |
6043 } // namespace v8 | 6133 } // namespace v8 |
OLD | NEW |