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-stubs.h" // For CallApiCallbackStub. | 8 #include "src/code-stubs.h" // For CallApiCallbackStub. |
9 #include "src/compiler/code-stub-assembler.h" | 9 #include "src/compiler/code-stub-assembler.h" |
10 #include "src/handles-inl.h" | 10 #include "src/handles-inl.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 Node* instance_type = assembler_->WordAnd( | 49 Node* instance_type = assembler_->WordAnd( |
50 assembler_->LoadObjectField(object_map, | 50 assembler_->LoadObjectField(object_map, |
51 Internals::kMapInstanceTypeAndBitFieldOffset, | 51 Internals::kMapInstanceTypeAndBitFieldOffset, |
52 MachineType::Uint16()), | 52 MachineType::Uint16()), |
53 assembler_->IntPtrConstant(0xff)); | 53 assembler_->IntPtrConstant(0xff)); |
54 | 54 |
55 // Check whether we have a proper JSObject. | 55 // Check whether we have a proper JSObject. |
56 CodeStubAssembler::Variable result(assembler_.get(), | 56 CodeStubAssembler::Variable result(assembler_.get(), |
57 MachineRepresentation::kTagged); | 57 MachineRepresentation::kTagged); |
58 CodeStubAssembler::Label is_jsobject(assembler_.get()); | 58 CodeStubAssembler::Label is_jsobject(assembler_.get()); |
| 59 CodeStubAssembler::Label maybe_api_object(assembler_.get()); |
59 CodeStubAssembler::Label is_not_jsobject(assembler_.get()); | 60 CodeStubAssembler::Label is_not_jsobject(assembler_.get()); |
60 CodeStubAssembler::Label merge(assembler_.get(), &result); | 61 CodeStubAssembler::Label merge(assembler_.get(), &result); |
61 assembler_->Branch( | 62 assembler_->Branch( |
62 assembler_->WordEqual( | 63 assembler_->WordEqual( |
63 instance_type, assembler_->IntPtrConstant(Internals::kJSObjectType)), | 64 instance_type, assembler_->IntPtrConstant(Internals::kJSObjectType)), |
64 &is_jsobject, &is_not_jsobject); | 65 &is_jsobject, &maybe_api_object); |
65 | 66 |
66 // JSObject? Then load the internal field field_no. | 67 // JSObject? Then load the internal field field_no. |
67 assembler_->Bind(&is_jsobject); | 68 assembler_->Bind(&is_jsobject); |
68 Node* internal_field = assembler_->LoadObjectField( | 69 Node* internal_field = assembler_->LoadObjectField( |
69 FromId(value), JSObject::kHeaderSize + kPointerSize * field_no, | 70 FromId(value), JSObject::kHeaderSize + kPointerSize * field_no, |
70 MachineType::Pointer()); | 71 MachineType::Pointer()); |
71 result.Bind(internal_field); | 72 result.Bind(internal_field); |
72 assembler_->Goto(&merge); | 73 assembler_->Goto(&merge); |
73 | 74 |
| 75 assembler_->Bind(&maybe_api_object); |
| 76 assembler_->Branch( |
| 77 assembler_->WordEqual(instance_type, assembler_->IntPtrConstant( |
| 78 Internals::kJSApiObjectType)), |
| 79 &is_jsobject, &is_not_jsobject); |
| 80 |
74 // No JSObject? Return undefined. | 81 // No JSObject? Return undefined. |
75 // TODO(vogelheim): Check whether this is the appropriate action, or whether | 82 // TODO(vogelheim): Check whether this is the appropriate action, or whether |
76 // the method should take a label instead. | 83 // the method should take a label instead. |
77 assembler_->Bind(&is_not_jsobject); | 84 assembler_->Bind(&is_not_jsobject); |
78 Node* fail_value = assembler_->UndefinedConstant(); | 85 Node* fail_value = assembler_->UndefinedConstant(); |
79 result.Bind(fail_value); | 86 result.Bind(fail_value); |
80 assembler_->Goto(&merge); | 87 assembler_->Goto(&merge); |
81 | 88 |
82 // Return. | 89 // Return. |
83 assembler_->Bind(&merge); | 90 assembler_->Bind(&merge); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 void FastAccessorAssembler::Clear() { | 229 void FastAccessorAssembler::Clear() { |
223 for (auto label : labels_) { | 230 for (auto label : labels_) { |
224 delete label; | 231 delete label; |
225 } | 232 } |
226 nodes_.clear(); | 233 nodes_.clear(); |
227 labels_.clear(); | 234 labels_.clear(); |
228 } | 235 } |
229 | 236 |
230 } // namespace internal | 237 } // namespace internal |
231 } // namespace v8 | 238 } // namespace v8 |
OLD | NEW |