OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/lookup.h" | 5 #include "src/lookup.h" |
6 | 6 |
7 #include "src/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
8 #include "src/deoptimizer.h" | 8 #include "src/deoptimizer.h" |
9 #include "src/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
10 #include "src/lookup-inl.h" | 10 #include "src/lookup-inl.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 | 15 |
| 16 // static |
| 17 LookupIterator LookupIterator::PropertyOrElement(Isolate* isolate, |
| 18 Handle<Object> receiver, |
| 19 Handle<Object> key, |
| 20 bool* success, |
| 21 Configuration configuration) { |
| 22 uint32_t index = 0; |
| 23 if (key->ToArrayIndex(&index)) { |
| 24 *success = true; |
| 25 return LookupIterator(isolate, receiver, index, configuration); |
| 26 } |
| 27 |
| 28 Handle<Name> name; |
| 29 *success = Object::ToName(isolate, key).ToHandle(&name); |
| 30 if (!*success) { |
| 31 DCHECK(isolate->has_pending_exception()); |
| 32 // Return an unusable dummy. |
| 33 return LookupIterator(receiver, isolate->factory()->empty_string()); |
| 34 } |
| 35 |
| 36 if (name->AsArrayIndex(&index)) { |
| 37 LookupIterator it(isolate, receiver, index, configuration); |
| 38 // Here we try to avoid having to rebuild the string later |
| 39 // by storing it on the indexed LookupIterator. |
| 40 it.name_ = name; |
| 41 return it; |
| 42 } |
| 43 |
| 44 return LookupIterator(receiver, name, configuration); |
| 45 } |
| 46 |
| 47 |
16 void LookupIterator::Next() { | 48 void LookupIterator::Next() { |
17 DCHECK_NE(JSPROXY, state_); | 49 DCHECK_NE(JSPROXY, state_); |
18 DCHECK_NE(TRANSITION, state_); | 50 DCHECK_NE(TRANSITION, state_); |
19 DisallowHeapAllocation no_gc; | 51 DisallowHeapAllocation no_gc; |
20 has_property_ = false; | 52 has_property_ = false; |
21 | 53 |
22 JSReceiver* holder = *holder_; | 54 JSReceiver* holder = *holder_; |
23 Map* map = *holder_map_; | 55 Map* map = *holder_map_; |
24 | 56 |
25 // Perform lookup on current holder. | 57 // Perform lookup on current holder. |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 case InterceptorState::kSkipNonMasking: | 588 case InterceptorState::kSkipNonMasking: |
557 return true; | 589 return true; |
558 case InterceptorState::kProcessNonMasking: | 590 case InterceptorState::kProcessNonMasking: |
559 return false; | 591 return false; |
560 } | 592 } |
561 } | 593 } |
562 return interceptor_state_ == InterceptorState::kProcessNonMasking; | 594 return interceptor_state_ == InterceptorState::kProcessNonMasking; |
563 } | 595 } |
564 } // namespace internal | 596 } // namespace internal |
565 } // namespace v8 | 597 } // namespace v8 |
OLD | NEW |