Chromium Code Reviews| 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> name, | |
| 
 
Toon Verwaest
2015/09/30 13:02:33
What about calling this key?
 
Jakob Kummerow
2015/09/30 14:27:32
Done.
 
 | |
| 20 bool* success, | |
| 21 Configuration configuration) { | |
| 22 uint32_t index = 0; | |
| 23 bool is_index = false; | |
| 24 if (name->IsNumber()) { | |
| 
 
Toon Verwaest
2015/09/30 13:02:34
What about a slightly less branchy version:
uint3
 
Jakob Kummerow
2015/09/30 14:27:31
Nice simplification. Done.
 
 | |
| 25 if (name->ToArrayIndex(&index)) { | |
| 26 is_index = true; | |
| 27 } else { | |
| 28 name = isolate->factory()->NumberToString(name); | |
| 29 } | |
| 30 } else { | |
| 31 if (!Object::ToName(isolate, name).ToHandle(&name)) { | |
| 32 DCHECK(isolate->has_pending_exception()); | |
| 33 *success = false; | |
| 34 // Return an unusable dummy. | |
| 35 return LookupIterator(receiver, isolate->factory()->empty_string()); | |
| 36 } | |
| 37 DCHECK(name->IsName()); | |
| 38 name = Name::Flatten(Handle<Name>::cast(name)); | |
| 39 is_index = Handle<Name>::cast(name)->AsArrayIndex(&index); | |
| 40 } | |
| 41 *success = true; | |
| 42 if (is_index) { | |
| 43 return LookupIterator(isolate, receiver, index, configuration); | |
| 44 } else { | |
| 45 DCHECK(name->IsName()); | |
| 46 LookupIterator it(receiver, Handle<Name>::cast(name), configuration); | |
| 47 it.name_ = Handle<Name>::cast(name); | |
| 
 
Toon Verwaest
2015/09/30 13:02:33
You don't need to set the .name_ if you know it's
 
Jakob Kummerow
2015/09/30 14:27:32
Done.
(Not sure why that was there... probably an
 
 | |
| 48 return it; | |
| 49 } | |
| 50 } | |
| 51 | |
| 52 | |
| 16 void LookupIterator::Next() { | 53 void LookupIterator::Next() { | 
| 17 DCHECK_NE(JSPROXY, state_); | 54 DCHECK_NE(JSPROXY, state_); | 
| 18 DCHECK_NE(TRANSITION, state_); | 55 DCHECK_NE(TRANSITION, state_); | 
| 19 DisallowHeapAllocation no_gc; | 56 DisallowHeapAllocation no_gc; | 
| 20 has_property_ = false; | 57 has_property_ = false; | 
| 21 | 58 | 
| 22 JSReceiver* holder = *holder_; | 59 JSReceiver* holder = *holder_; | 
| 23 Map* map = *holder_map_; | 60 Map* map = *holder_map_; | 
| 24 | 61 | 
| 25 // Perform lookup on current holder. | 62 // Perform lookup on current holder. | 
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 556 case InterceptorState::kSkipNonMasking: | 593 case InterceptorState::kSkipNonMasking: | 
| 557 return true; | 594 return true; | 
| 558 case InterceptorState::kProcessNonMasking: | 595 case InterceptorState::kProcessNonMasking: | 
| 559 return false; | 596 return false; | 
| 560 } | 597 } | 
| 561 } | 598 } | 
| 562 return interceptor_state_ == InterceptorState::kProcessNonMasking; | 599 return interceptor_state_ == InterceptorState::kProcessNonMasking; | 
| 563 } | 600 } | 
| 564 } // namespace internal | 601 } // namespace internal | 
| 565 } // namespace v8 | 602 } // namespace v8 | 
| OLD | NEW |