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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/ic/handler-compiler.h" | 7 #include "src/ic/handler-compiler.h" |
8 #include "src/ic/ic-inl.h" | 8 #include "src/ic/ic-inl.h" |
9 #include "src/ic/ic-compiler.h" | 9 #include "src/ic/ic-compiler.h" |
10 | 10 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 85 |
86 Handle<Code> PropertyICCompiler::ComputeKeyedLoadMonomorphic( | 86 Handle<Code> PropertyICCompiler::ComputeKeyedLoadMonomorphic( |
87 Handle<Map> receiver_map) { | 87 Handle<Map> receiver_map) { |
88 Isolate* isolate = receiver_map->GetIsolate(); | 88 Isolate* isolate = receiver_map->GetIsolate(); |
89 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC); | 89 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC); |
90 Handle<Name> name = isolate->factory()->KeyedLoadMonomorphic_string(); | 90 Handle<Name> name = isolate->factory()->KeyedLoadMonomorphic_string(); |
91 | 91 |
92 Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate); | 92 Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate); |
93 if (probe->IsCode()) return Handle<Code>::cast(probe); | 93 if (probe->IsCode()) return Handle<Code>::cast(probe); |
94 | 94 |
| 95 Handle<Code> stub = ComputeKeyedLoadMonomorphicHandler(receiver_map); |
| 96 PropertyICCompiler compiler(isolate, Code::KEYED_LOAD_IC); |
| 97 Handle<Code> code = |
| 98 compiler.CompileMonomorphic(HeapType::Class(receiver_map, isolate), stub, |
| 99 isolate->factory()->empty_string(), ELEMENT); |
| 100 |
| 101 Map::UpdateCodeCache(receiver_map, name, code); |
| 102 return code; |
| 103 } |
| 104 |
| 105 |
| 106 Handle<Code> PropertyICCompiler::ComputeKeyedLoadMonomorphicHandler( |
| 107 Handle<Map> receiver_map) { |
| 108 Isolate* isolate = receiver_map->GetIsolate(); |
95 ElementsKind elements_kind = receiver_map->elements_kind(); | 109 ElementsKind elements_kind = receiver_map->elements_kind(); |
96 Handle<Code> stub; | 110 Handle<Code> stub; |
97 if (receiver_map->has_indexed_interceptor()) { | 111 if (receiver_map->has_indexed_interceptor()) { |
98 stub = LoadIndexedInterceptorStub(isolate).GetCode(); | 112 stub = LoadIndexedInterceptorStub(isolate).GetCode(); |
99 } else if (receiver_map->IsStringMap()) { | 113 } else if (receiver_map->IsStringMap()) { |
100 // We have a string. | 114 // We have a string. |
101 stub = LoadIndexedStringStub(isolate).GetCode(); | 115 stub = LoadIndexedStringStub(isolate).GetCode(); |
102 } else if (receiver_map->has_sloppy_arguments_elements()) { | 116 } else if (receiver_map->has_sloppy_arguments_elements()) { |
103 stub = KeyedLoadSloppyArgumentsStub(isolate).GetCode(); | 117 stub = KeyedLoadSloppyArgumentsStub(isolate).GetCode(); |
104 } else if (receiver_map->has_fast_elements() || | 118 } else if (receiver_map->has_fast_elements() || |
105 receiver_map->has_external_array_elements() || | 119 receiver_map->has_external_array_elements() || |
106 receiver_map->has_fixed_typed_array_elements()) { | 120 receiver_map->has_fixed_typed_array_elements()) { |
107 stub = LoadFastElementStub(isolate, | 121 stub = LoadFastElementStub(isolate, |
108 receiver_map->instance_type() == JS_ARRAY_TYPE, | 122 receiver_map->instance_type() == JS_ARRAY_TYPE, |
109 elements_kind).GetCode(); | 123 elements_kind).GetCode(); |
110 } else { | 124 } else { |
111 stub = LoadDictionaryElementStub(isolate).GetCode(); | 125 stub = LoadDictionaryElementStub(isolate).GetCode(); |
112 } | 126 } |
113 PropertyICCompiler compiler(isolate, Code::KEYED_LOAD_IC); | 127 return stub; |
114 Handle<Code> code = | |
115 compiler.CompileMonomorphic(HeapType::Class(receiver_map, isolate), stub, | |
116 isolate->factory()->empty_string(), ELEMENT); | |
117 | |
118 Map::UpdateCodeCache(receiver_map, name, code); | |
119 return code; | |
120 } | 128 } |
121 | 129 |
122 | 130 |
123 Handle<Code> PropertyICCompiler::ComputeKeyedStoreMonomorphic( | 131 Handle<Code> PropertyICCompiler::ComputeKeyedStoreMonomorphic( |
124 Handle<Map> receiver_map, StrictMode strict_mode, | 132 Handle<Map> receiver_map, StrictMode strict_mode, |
125 KeyedAccessStoreMode store_mode) { | 133 KeyedAccessStoreMode store_mode) { |
126 Isolate* isolate = receiver_map->GetIsolate(); | 134 Isolate* isolate = receiver_map->GetIsolate(); |
127 ExtraICState extra_state = | 135 ExtraICState extra_state = |
128 KeyedStoreIC::ComputeExtraICState(strict_mode, store_mode); | 136 KeyedStoreIC::ComputeExtraICState(strict_mode, store_mode); |
129 Code::Flags flags = | 137 Code::Flags flags = |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 | 449 |
442 TailCallBuiltin(masm(), Builtins::kKeyedStoreIC_Miss); | 450 TailCallBuiltin(masm(), Builtins::kKeyedStoreIC_Miss); |
443 | 451 |
444 return GetCode(kind(), Code::NORMAL, factory()->empty_string()); | 452 return GetCode(kind(), Code::NORMAL, factory()->empty_string()); |
445 } | 453 } |
446 | 454 |
447 | 455 |
448 #undef __ | 456 #undef __ |
449 } | 457 } |
450 } // namespace v8::internal | 458 } // namespace v8::internal |
OLD | NEW |