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 #include "src/fast-accessor-assembler.h" | 5 #include "src/fast-accessor-assembler.h" |
6 | 6 |
7 #include "src/base/logging.h" | 7 #include "src/base/logging.h" |
8 #include "src/code-stub-assembler.h" | 8 #include "src/code-stub-assembler.h" |
9 #include "src/code-stubs.h" // For CallApiCallbackStub. | 9 #include "src/code-stubs.h" // For CallApiCallbackStub. |
10 #include "src/handles-inl.h" | 10 #include "src/handles-inl.h" |
11 #include "src/objects-inl.h" | 11 #include "src/objects-inl.h" |
12 #include "src/objects.h" // For FAA::LoadInternalField impl. | 12 #include "src/objects.h" // For FAA::LoadEmbedderField impl. |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 namespace internal { | 15 namespace internal { |
16 | 16 |
17 using compiler::Node; | 17 using compiler::Node; |
18 using compiler::CodeAssemblerLabel; | 18 using compiler::CodeAssemblerLabel; |
19 using compiler::CodeAssemblerVariable; | 19 using compiler::CodeAssemblerVariable; |
20 | 20 |
21 FastAccessorAssembler::FastAccessorAssembler(Isolate* isolate) | 21 FastAccessorAssembler::FastAccessorAssembler(Isolate* isolate) |
22 : zone_(isolate->allocator(), ZONE_NAME), | 22 : zone_(isolate->allocator(), ZONE_NAME), |
(...skipping 12 matching lines...) Expand all Loading... |
35 return FromRaw(assembler_->NumberConstant(const_value)); | 35 return FromRaw(assembler_->NumberConstant(const_value)); |
36 } | 36 } |
37 | 37 |
38 FastAccessorAssembler::ValueId FastAccessorAssembler::GetReceiver() { | 38 FastAccessorAssembler::ValueId FastAccessorAssembler::GetReceiver() { |
39 CHECK_EQ(kBuilding, state_); | 39 CHECK_EQ(kBuilding, state_); |
40 | 40 |
41 // For JS functions, the receiver is parameter 0. | 41 // For JS functions, the receiver is parameter 0. |
42 return FromRaw(assembler_->Parameter(0)); | 42 return FromRaw(assembler_->Parameter(0)); |
43 } | 43 } |
44 | 44 |
45 FastAccessorAssembler::ValueId FastAccessorAssembler::LoadInternalField( | 45 FastAccessorAssembler::ValueId FastAccessorAssembler::LoadEmbedderField( |
46 ValueId value_id, int field_no) { | 46 ValueId value_id, int field_no) { |
47 CHECK_EQ(kBuilding, state_); | 47 CHECK_EQ(kBuilding, state_); |
48 | 48 |
49 CodeAssemblerVariable result(assembler_.get(), | 49 CodeAssemblerVariable result(assembler_.get(), |
50 MachineRepresentation::kTagged); | 50 MachineRepresentation::kTagged); |
51 LabelId is_not_jsobject = MakeLabel(); | 51 LabelId is_not_jsobject = MakeLabel(); |
52 CodeAssemblerLabel merge(assembler_.get(), &result); | 52 CodeAssemblerLabel merge(assembler_.get(), &result); |
53 | 53 |
54 CheckIsJSObjectOrJump(value_id, is_not_jsobject); | 54 CheckIsJSObjectOrJump(value_id, is_not_jsobject); |
55 | 55 |
56 Node* internal_field = assembler_->LoadObjectField( | 56 Node* embedder_field = assembler_->LoadObjectField( |
57 FromId(value_id), JSObject::kHeaderSize + kPointerSize * field_no); | 57 FromId(value_id), JSObject::kHeaderSize + kPointerSize * field_no); |
58 | 58 |
59 result.Bind(internal_field); | 59 result.Bind(embedder_field); |
60 assembler_->Goto(&merge); | 60 assembler_->Goto(&merge); |
61 | 61 |
62 // Return null, mimicking the C++ counterpart. | 62 // Return null, mimicking the C++ counterpart. |
63 SetLabel(is_not_jsobject); | 63 SetLabel(is_not_jsobject); |
64 result.Bind(assembler_->NullConstant()); | 64 result.Bind(assembler_->NullConstant()); |
65 assembler_->Goto(&merge); | 65 assembler_->Goto(&merge); |
66 | 66 |
67 // Return. | 67 // Return. |
68 assembler_->Bind(&merge); | 68 assembler_->Bind(&merge); |
69 return FromRaw(result.value()); | 69 return FromRaw(result.value()); |
70 } | 70 } |
71 | 71 |
72 FastAccessorAssembler::ValueId | 72 FastAccessorAssembler::ValueId |
73 FastAccessorAssembler::LoadInternalFieldUnchecked(ValueId value_id, | 73 FastAccessorAssembler::LoadEmbedderFieldUnchecked(ValueId value_id, |
74 int field_no) { | 74 int field_no) { |
75 CHECK_EQ(kBuilding, state_); | 75 CHECK_EQ(kBuilding, state_); |
76 | 76 |
77 // Defensive debug checks. | 77 // Defensive debug checks. |
78 if (FLAG_debug_code) { | 78 if (FLAG_debug_code) { |
79 LabelId is_jsobject = MakeLabel(); | 79 LabelId is_jsobject = MakeLabel(); |
80 LabelId is_not_jsobject = MakeLabel(); | 80 LabelId is_not_jsobject = MakeLabel(); |
81 CheckIsJSObjectOrJump(value_id, is_not_jsobject); | 81 CheckIsJSObjectOrJump(value_id, is_not_jsobject); |
82 assembler_->Goto(FromId(is_jsobject)); | 82 assembler_->Goto(FromId(is_jsobject)); |
83 | 83 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 void FastAccessorAssembler::Clear() { | 261 void FastAccessorAssembler::Clear() { |
262 for (auto label : labels_) { | 262 for (auto label : labels_) { |
263 delete label; | 263 delete label; |
264 } | 264 } |
265 nodes_.clear(); | 265 nodes_.clear(); |
266 labels_.clear(); | 266 labels_.clear(); |
267 } | 267 } |
268 | 268 |
269 } // namespace internal | 269 } // namespace internal |
270 } // namespace v8 | 270 } // namespace v8 |
OLD | NEW |