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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
8 #include "src/field-index.h" | |
9 #include "src/hydrogen.h" | 8 #include "src/hydrogen.h" |
10 #include "src/lithium.h" | 9 #include "src/lithium.h" |
11 | 10 |
12 namespace v8 { | 11 namespace v8 { |
13 namespace internal { | 12 namespace internal { |
14 | 13 |
15 | 14 |
16 static LChunk* OptimizeGraph(HGraph* graph) { | 15 static LChunk* OptimizeGraph(HGraph* graph) { |
17 DisallowHeapAllocation no_allocation; | 16 DisallowHeapAllocation no_allocation; |
18 DisallowHandleAllocation no_handles; | 17 DisallowHandleAllocation no_handles; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 // This is initialized in BuildGraph() | 52 // This is initialized in BuildGraph() |
54 ASSERT(arguments_length_ != NULL); | 53 ASSERT(arguments_length_ != NULL); |
55 return arguments_length_; | 54 return arguments_length_; |
56 } | 55 } |
57 CompilationInfo* info() { return &info_; } | 56 CompilationInfo* info() { return &info_; } |
58 HydrogenCodeStub* stub() { return info_.code_stub(); } | 57 HydrogenCodeStub* stub() { return info_.code_stub(); } |
59 HContext* context() { return context_; } | 58 HContext* context() { return context_; } |
60 Isolate* isolate() { return info_.isolate(); } | 59 Isolate* isolate() { return info_.isolate(); } |
61 | 60 |
62 HLoadNamedField* BuildLoadNamedField(HValue* object, | 61 HLoadNamedField* BuildLoadNamedField(HValue* object, |
63 FieldIndex index); | 62 Representation representation, |
| 63 int offset, |
| 64 bool is_inobject); |
64 | 65 |
65 enum ArgumentClass { | 66 enum ArgumentClass { |
66 NONE, | 67 NONE, |
67 SINGLE, | 68 SINGLE, |
68 MULTIPLE | 69 MULTIPLE |
69 }; | 70 }; |
70 | 71 |
71 HValue* BuildArrayConstructor(ElementsKind kind, | 72 HValue* BuildArrayConstructor(ElementsKind kind, |
72 AllocationSiteOverrideMode override_mode, | 73 AllocationSiteOverrideMode override_mode, |
73 ArgumentClass argument_class); | 74 ArgumentClass argument_class); |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 return load; | 546 return load; |
546 } | 547 } |
547 | 548 |
548 | 549 |
549 Handle<Code> KeyedLoadFastElementStub::GenerateCode() { | 550 Handle<Code> KeyedLoadFastElementStub::GenerateCode() { |
550 return DoGenerateCode(this); | 551 return DoGenerateCode(this); |
551 } | 552 } |
552 | 553 |
553 | 554 |
554 HLoadNamedField* CodeStubGraphBuilderBase::BuildLoadNamedField( | 555 HLoadNamedField* CodeStubGraphBuilderBase::BuildLoadNamedField( |
555 HValue* object, FieldIndex index) { | 556 HValue* object, |
556 Representation representation = index.is_double() | 557 Representation representation, |
557 ? Representation::Double() | 558 int offset, |
558 : Representation::Tagged(); | 559 bool is_inobject) { |
559 int offset = index.offset(); | 560 HObjectAccess access = is_inobject |
560 HObjectAccess access = index.is_inobject() | |
561 ? HObjectAccess::ForObservableJSObjectOffset(offset, representation) | 561 ? HObjectAccess::ForObservableJSObjectOffset(offset, representation) |
562 : HObjectAccess::ForBackingStoreOffset(offset, representation); | 562 : HObjectAccess::ForBackingStoreOffset(offset, representation); |
563 if (index.is_double()) { | 563 if (representation.IsDouble()) { |
564 // Load the heap number. | 564 // Load the heap number. |
565 object = Add<HLoadNamedField>( | 565 object = Add<HLoadNamedField>( |
566 object, static_cast<HValue*>(NULL), | 566 object, static_cast<HValue*>(NULL), |
567 access.WithRepresentation(Representation::Tagged())); | 567 access.WithRepresentation(Representation::Tagged())); |
568 // Load the double value from it. | 568 // Load the double value from it. |
569 access = HObjectAccess::ForHeapNumberValue(); | 569 access = HObjectAccess::ForHeapNumberValue(); |
570 } | 570 } |
571 return Add<HLoadNamedField>(object, static_cast<HValue*>(NULL), access); | 571 return Add<HLoadNamedField>(object, static_cast<HValue*>(NULL), access); |
572 } | 572 } |
573 | 573 |
574 | 574 |
575 template<> | 575 template<> |
576 HValue* CodeStubGraphBuilder<LoadFieldStub>::BuildCodeStub() { | 576 HValue* CodeStubGraphBuilder<LoadFieldStub>::BuildCodeStub() { |
577 return BuildLoadNamedField(GetParameter(0), casted_stub()->index()); | 577 return BuildLoadNamedField(GetParameter(0), |
| 578 casted_stub()->representation(), |
| 579 casted_stub()->offset(), |
| 580 casted_stub()->is_inobject()); |
578 } | 581 } |
579 | 582 |
580 | 583 |
581 Handle<Code> LoadFieldStub::GenerateCode() { | 584 Handle<Code> LoadFieldStub::GenerateCode() { |
582 return DoGenerateCode(this); | 585 return DoGenerateCode(this); |
583 } | 586 } |
584 | 587 |
585 | 588 |
586 template<> | 589 template<> |
587 HValue* CodeStubGraphBuilder<StringLengthStub>::BuildCodeStub() { | 590 HValue* CodeStubGraphBuilder<StringLengthStub>::BuildCodeStub() { |
588 HValue* string = BuildLoadNamedField(GetParameter(0), | 591 HValue* string = BuildLoadNamedField( |
589 FieldIndex::ForInObjectOffset(JSValue::kValueOffset)); | 592 GetParameter(0), Representation::Tagged(), JSValue::kValueOffset, true); |
590 return BuildLoadNamedField(string, | 593 return BuildLoadNamedField( |
591 FieldIndex::ForInObjectOffset(String::kLengthOffset)); | 594 string, Representation::Tagged(), String::kLengthOffset, true); |
592 } | 595 } |
593 | 596 |
594 | 597 |
595 Handle<Code> StringLengthStub::GenerateCode() { | 598 Handle<Code> StringLengthStub::GenerateCode() { |
596 return DoGenerateCode(this); | 599 return DoGenerateCode(this); |
597 } | 600 } |
598 | 601 |
599 | 602 |
600 template <> | 603 template <> |
601 HValue* CodeStubGraphBuilder<KeyedStoreFastElementStub>::BuildCodeStub() { | 604 HValue* CodeStubGraphBuilder<KeyedStoreFastElementStub>::BuildCodeStub() { |
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1411 return BuildRegExpConstructResult(length, index, input); | 1414 return BuildRegExpConstructResult(length, index, input); |
1412 } | 1415 } |
1413 | 1416 |
1414 | 1417 |
1415 Handle<Code> RegExpConstructResultStub::GenerateCode() { | 1418 Handle<Code> RegExpConstructResultStub::GenerateCode() { |
1416 return DoGenerateCode(this); | 1419 return DoGenerateCode(this); |
1417 } | 1420 } |
1418 | 1421 |
1419 | 1422 |
1420 } } // namespace v8::internal | 1423 } } // namespace v8::internal |
OLD | NEW |