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.h" // For FAA::LoadInternalField impl. | 11 #include "src/objects.h" // For FAA::LoadInternalField impl. |
12 | 12 |
13 using v8::internal::CodeStubAssembler; | |
14 using v8::internal::compiler::Node; | 13 using v8::internal::compiler::Node; |
15 | 14 |
16 namespace v8 { | 15 namespace v8 { |
17 namespace internal { | 16 namespace internal { |
18 | 17 |
19 FastAccessorAssembler::FastAccessorAssembler(Isolate* isolate) | 18 FastAccessorAssembler::FastAccessorAssembler(Isolate* isolate) |
20 : zone_(isolate->allocator(), ZONE_NAME), | 19 : zone_(isolate->allocator(), ZONE_NAME), |
21 isolate_(isolate), | 20 isolate_(isolate), |
22 assembler_(new CodeStubAssembler(isolate, zone(), 1, | 21 assembler_state_(isolate, zone(), 1, Code::ComputeFlags(Code::STUB), |
23 Code::ComputeFlags(Code::STUB), | 22 "FastAccessorAssembler"), |
24 "FastAccessorAssembler")), | 23 assembler_(new CodeStubAssembler(&assembler_state_)), |
25 state_(kBuilding) {} | 24 state_(kBuilding) {} |
26 | 25 |
27 FastAccessorAssembler::~FastAccessorAssembler() { Clear(); } | 26 FastAccessorAssembler::~FastAccessorAssembler() { Clear(); } |
28 | 27 |
29 FastAccessorAssembler::ValueId FastAccessorAssembler::IntegerConstant( | 28 FastAccessorAssembler::ValueId FastAccessorAssembler::IntegerConstant( |
30 int const_value) { | 29 int const_value) { |
31 CHECK_EQ(kBuilding, state_); | 30 CHECK_EQ(kBuilding, state_); |
32 return FromRaw(assembler_->NumberConstant(const_value)); | 31 return FromRaw(assembler_->NumberConstant(const_value)); |
33 } | 32 } |
34 | 33 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 Internals::kJSApiObjectType)), | 240 Internals::kJSApiObjectType)), |
242 FromId(label_id)); | 241 FromId(label_id)); |
243 | 242 |
244 // Continue. | 243 // Continue. |
245 assembler_->Goto(&is_jsobject); | 244 assembler_->Goto(&is_jsobject); |
246 assembler_->Bind(&is_jsobject); | 245 assembler_->Bind(&is_jsobject); |
247 } | 246 } |
248 | 247 |
249 MaybeHandle<Code> FastAccessorAssembler::Build() { | 248 MaybeHandle<Code> FastAccessorAssembler::Build() { |
250 CHECK_EQ(kBuilding, state_); | 249 CHECK_EQ(kBuilding, state_); |
251 Handle<Code> code = assembler_->GenerateCode(); | 250 Handle<Code> code = compiler::CodeAssembler::GenerateCode(&assembler_state_); |
252 state_ = !code.is_null() ? kBuilt : kError; | 251 state_ = !code.is_null() ? kBuilt : kError; |
253 Clear(); | 252 Clear(); |
254 return code; | 253 return code; |
255 } | 254 } |
256 | 255 |
257 FastAccessorAssembler::ValueId FastAccessorAssembler::FromRaw(Node* node) { | 256 FastAccessorAssembler::ValueId FastAccessorAssembler::FromRaw(Node* node) { |
258 nodes_.push_back(node); | 257 nodes_.push_back(node); |
259 ValueId value = {nodes_.size() - 1}; | 258 ValueId value = {nodes_.size() - 1}; |
260 return value; | 259 return value; |
261 } | 260 } |
(...skipping 20 matching lines...) Expand all Loading... |
282 void FastAccessorAssembler::Clear() { | 281 void FastAccessorAssembler::Clear() { |
283 for (auto label : labels_) { | 282 for (auto label : labels_) { |
284 delete label; | 283 delete label; |
285 } | 284 } |
286 nodes_.clear(); | 285 nodes_.clear(); |
287 labels_.clear(); | 286 labels_.clear(); |
288 } | 287 } |
289 | 288 |
290 } // namespace internal | 289 } // namespace internal |
291 } // namespace v8 | 290 } // namespace v8 |
OLD | NEW |