| 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/ic/handler-compiler.h" | 5 #include "src/ic/handler-compiler.h" |
| 6 | 6 |
| 7 #include "src/field-type.h" | 7 #include "src/field-type.h" |
| 8 #include "src/ic/call-optimization.h" | 8 #include "src/ic/call-optimization.h" |
| 9 #include "src/ic/ic-inl.h" | 9 #include "src/ic/ic-inl.h" |
| 10 #include "src/ic/ic.h" | 10 #include "src/ic/ic.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 Code::Flags flags = Code::ComputeHandlerFlags(kind, cache_holder); | 21 Code::Flags flags = Code::ComputeHandlerFlags(kind, cache_holder); |
| 22 Code* code = stub_holder->LookupInCodeCache(*name, flags); | 22 Code* code = stub_holder->LookupInCodeCache(*name, flags); |
| 23 if (code == nullptr) return Handle<Code>(); | 23 if (code == nullptr) return Handle<Code>(); |
| 24 return handle(code); | 24 return handle(code); |
| 25 } | 25 } |
| 26 | 26 |
| 27 | 27 |
| 28 Handle<Code> NamedLoadHandlerCompiler::ComputeLoadNonexistent( | 28 Handle<Code> NamedLoadHandlerCompiler::ComputeLoadNonexistent( |
| 29 Handle<Name> name, Handle<Map> receiver_map) { | 29 Handle<Name> name, Handle<Map> receiver_map) { |
| 30 Isolate* isolate = name->GetIsolate(); | 30 Isolate* isolate = name->GetIsolate(); |
| 31 if (receiver_map->prototype()->IsNull()) { | 31 if (receiver_map->prototype()->IsNull(isolate)) { |
| 32 // TODO(jkummerow/verwaest): If there is no prototype and the property | 32 // TODO(jkummerow/verwaest): If there is no prototype and the property |
| 33 // is nonexistent, introduce a builtin to handle this (fast properties | 33 // is nonexistent, introduce a builtin to handle this (fast properties |
| 34 // -> return undefined, dictionary properties -> do negative lookup). | 34 // -> return undefined, dictionary properties -> do negative lookup). |
| 35 return Handle<Code>(); | 35 return Handle<Code>(); |
| 36 } | 36 } |
| 37 CacheHolderFlag flag; | 37 CacheHolderFlag flag; |
| 38 Handle<Map> stub_holder_map = | 38 Handle<Map> stub_holder_map = |
| 39 IC::GetHandlerCacheHolder(receiver_map, false, isolate, &flag); | 39 IC::GetHandlerCacheHolder(receiver_map, false, isolate, &flag); |
| 40 | 40 |
| 41 // If no dictionary mode objects are present in the prototype chain, the load | 41 // If no dictionary mode objects are present in the prototype chain, the load |
| 42 // nonexistent IC stub can be shared for all names for a given map and we use | 42 // nonexistent IC stub can be shared for all names for a given map and we use |
| 43 // the empty string for the map cache in that case. If there are dictionary | 43 // the empty string for the map cache in that case. If there are dictionary |
| 44 // mode objects involved, we need to do negative lookups in the stub and | 44 // mode objects involved, we need to do negative lookups in the stub and |
| 45 // therefore the stub will be specific to the name. | 45 // therefore the stub will be specific to the name. |
| 46 Handle<Name> cache_name = | 46 Handle<Name> cache_name = |
| 47 receiver_map->is_dictionary_map() | 47 receiver_map->is_dictionary_map() |
| 48 ? name | 48 ? name |
| 49 : Handle<Name>::cast(isolate->factory()->nonexistent_symbol()); | 49 : Handle<Name>::cast(isolate->factory()->nonexistent_symbol()); |
| 50 Handle<Map> current_map = stub_holder_map; | 50 Handle<Map> current_map = stub_holder_map; |
| 51 Handle<JSObject> last(JSObject::cast(receiver_map->prototype())); | 51 Handle<JSObject> last(JSObject::cast(receiver_map->prototype())); |
| 52 while (true) { | 52 while (true) { |
| 53 if (current_map->is_dictionary_map()) cache_name = name; | 53 if (current_map->is_dictionary_map()) cache_name = name; |
| 54 if (current_map->prototype()->IsNull()) break; | 54 if (current_map->prototype()->IsNull(isolate)) break; |
| 55 if (name->IsPrivate()) { | 55 if (name->IsPrivate()) { |
| 56 // TODO(verwaest): Use nonexistent_private_symbol. | 56 // TODO(verwaest): Use nonexistent_private_symbol. |
| 57 cache_name = name; | 57 cache_name = name; |
| 58 if (!current_map->has_hidden_prototype()) break; | 58 if (!current_map->has_hidden_prototype()) break; |
| 59 } | 59 } |
| 60 | 60 |
| 61 last = handle(JSObject::cast(current_map->prototype())); | 61 last = handle(JSObject::cast(current_map->prototype())); |
| 62 current_map = handle(last->map()); | 62 current_map = handle(last->map()); |
| 63 } | 63 } |
| 64 // Compile the stub that is either shared for all names or | 64 // Compile the stub that is either shared for all names or |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 LoadICState state = LoadICState(kNoExtraICState); | 607 LoadICState state = LoadICState(kNoExtraICState); |
| 608 cached_stub = LoadDictionaryElementStub(isolate(), state).GetCode(); | 608 cached_stub = LoadDictionaryElementStub(isolate(), state).GetCode(); |
| 609 } | 609 } |
| 610 } | 610 } |
| 611 | 611 |
| 612 handlers->Add(cached_stub); | 612 handlers->Add(cached_stub); |
| 613 } | 613 } |
| 614 } | 614 } |
| 615 } // namespace internal | 615 } // namespace internal |
| 616 } // namespace v8 | 616 } // namespace v8 |
| OLD | NEW |