OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 } | 1187 } |
1188 is_optimized.Else(); | 1188 is_optimized.Else(); |
1189 { | 1189 { |
1190 AddIncrementCounter(counters->fast_new_closure_try_optimized()); | 1190 AddIncrementCounter(counters->fast_new_closure_try_optimized()); |
1191 // optimized_map points to fixed array of 3-element entries | 1191 // optimized_map points to fixed array of 3-element entries |
1192 // (native context, optimized code, literals). | 1192 // (native context, optimized code, literals). |
1193 // Map must never be empty, so check the first elements. | 1193 // Map must never be empty, so check the first elements. |
1194 Label install_optimized; | 1194 Label install_optimized; |
1195 HValue* first_context_slot = Add<HLoadNamedField>(optimized_map, | 1195 HValue* first_context_slot = Add<HLoadNamedField>(optimized_map, |
1196 HObjectAccess::ForFirstContextSlot()); | 1196 HObjectAccess::ForFirstContextSlot()); |
| 1197 HValue* first_osr_ast_slot = Add<HLoadNamedField>(optimized_map, |
| 1198 HObjectAccess::ForFirstOsrAstIdSlot()); |
| 1199 HValue* osr_ast_id_none = Add<HConstant>(BailoutId::None().ToInt()); |
1197 IfBuilder already_in(this); | 1200 IfBuilder already_in(this); |
1198 already_in.If<HCompareObjectEqAndBranch>(native_context, | 1201 already_in.If<HCompareObjectEqAndBranch>(native_context, |
1199 first_context_slot); | 1202 first_context_slot); |
| 1203 already_in.AndIf<HCompareObjectEqAndBranch>(first_osr_ast_slot, |
| 1204 osr_ast_id_none); |
1200 already_in.Then(); | 1205 already_in.Then(); |
1201 { | 1206 { |
1202 HValue* code_object = Add<HLoadNamedField>(optimized_map, | 1207 HValue* code_object = Add<HLoadNamedField>(optimized_map, |
1203 HObjectAccess::ForFirstCodeSlot()); | 1208 HObjectAccess::ForFirstCodeSlot()); |
1204 BuildInstallOptimizedCode(js_function, native_context, code_object); | 1209 BuildInstallOptimizedCode(js_function, native_context, code_object); |
1205 } | 1210 } |
1206 already_in.Else(); | 1211 already_in.Else(); |
1207 { | 1212 { |
1208 HValue* shared_function_entry_length = | 1213 HValue* shared_function_entry_length = |
1209 Add<HConstant>(SharedFunctionInfo::kEntryLength); | 1214 Add<HConstant>(SharedFunctionInfo::kEntryLength); |
1210 LoopBuilder loop_builder(this, | 1215 LoopBuilder loop_builder(this, |
1211 context(), | 1216 context(), |
1212 LoopBuilder::kPostDecrement, | 1217 LoopBuilder::kPostDecrement, |
1213 shared_function_entry_length); | 1218 shared_function_entry_length); |
1214 HValue* array_length = Add<HLoadNamedField>(optimized_map, | 1219 HValue* array_length = Add<HLoadNamedField>(optimized_map, |
1215 HObjectAccess::ForFixedArrayLength()); | 1220 HObjectAccess::ForFixedArrayLength()); |
1216 HValue* key = loop_builder.BeginBody(array_length, | 1221 HValue* slot_iterator = loop_builder.BeginBody(array_length, |
1217 graph()->GetConstant0(), | 1222 graph()->GetConstant0(), |
1218 Token::GT); | 1223 Token::GT); |
1219 { | 1224 { |
1220 // Iterate through the rest of map backwards. | 1225 // Iterate through the rest of map backwards. |
1221 // Do not double check first entry. | 1226 // Do not double check first entry. |
1222 HValue* second_entry_index = | 1227 HValue* second_entry_index = |
1223 Add<HConstant>(SharedFunctionInfo::kSecondEntryIndex); | 1228 Add<HConstant>(SharedFunctionInfo::kSecondEntryIndex); |
1224 IfBuilder restore_check(this); | 1229 IfBuilder restore_check(this); |
1225 restore_check.If<HCompareNumericAndBranch>(key, second_entry_index, | 1230 restore_check.If<HCompareNumericAndBranch>( |
1226 Token::EQ); | 1231 slot_iterator, second_entry_index, Token::EQ); |
1227 restore_check.Then(); | 1232 restore_check.Then(); |
1228 { | 1233 { |
1229 // Store the unoptimized code | 1234 // Store the unoptimized code |
1230 BuildInstallCode(js_function, shared_info); | 1235 BuildInstallCode(js_function, shared_info); |
1231 loop_builder.Break(); | 1236 loop_builder.Break(); |
1232 } | 1237 } |
1233 restore_check.Else(); | 1238 restore_check.Else(); |
1234 { | 1239 { |
1235 HValue* keyed_minus = AddUncasted<HSub>( | 1240 STATIC_ASSERT(SharedFunctionInfo::kContextOffset == 0); |
1236 key, shared_function_entry_length); | 1241 STATIC_ASSERT(SharedFunctionInfo::kEntryLength - |
1237 HInstruction* keyed_lookup = Add<HLoadKeyed>(optimized_map, | 1242 SharedFunctionInfo::kOsrAstIdOffset == 1); |
1238 keyed_minus, static_cast<HValue*>(NULL), FAST_ELEMENTS); | 1243 HValue* native_context_slot = AddUncasted<HSub>( |
| 1244 slot_iterator, shared_function_entry_length); |
| 1245 HValue* osr_ast_id_slot = AddUncasted<HSub>( |
| 1246 slot_iterator, graph()->GetConstant1()); |
| 1247 HInstruction* native_context_entry = Add<HLoadKeyed>(optimized_map, |
| 1248 native_context_slot, static_cast<HValue*>(NULL), FAST_ELEMENTS); |
| 1249 HInstruction* osr_ast_id_entry = Add<HLoadKeyed>(optimized_map, |
| 1250 osr_ast_id_slot, static_cast<HValue*>(NULL), FAST_ELEMENTS); |
1239 IfBuilder done_check(this); | 1251 IfBuilder done_check(this); |
1240 done_check.If<HCompareObjectEqAndBranch>(native_context, | 1252 done_check.If<HCompareObjectEqAndBranch>(native_context, |
1241 keyed_lookup); | 1253 native_context_entry); |
| 1254 done_check.AndIf<HCompareObjectEqAndBranch>(osr_ast_id_entry, |
| 1255 osr_ast_id_none); |
1242 done_check.Then(); | 1256 done_check.Then(); |
1243 { | 1257 { |
1244 // Hit: fetch the optimized code. | 1258 // Hit: fetch the optimized code. |
1245 HValue* keyed_plus = AddUncasted<HAdd>( | 1259 HValue* code_slot = AddUncasted<HAdd>( |
1246 keyed_minus, graph()->GetConstant1()); | 1260 native_context_slot, graph()->GetConstant1()); |
1247 HValue* code_object = Add<HLoadKeyed>(optimized_map, | 1261 HValue* code_object = Add<HLoadKeyed>(optimized_map, |
1248 keyed_plus, static_cast<HValue*>(NULL), FAST_ELEMENTS); | 1262 code_slot, static_cast<HValue*>(NULL), FAST_ELEMENTS); |
1249 BuildInstallOptimizedCode(js_function, native_context, code_object); | 1263 BuildInstallOptimizedCode(js_function, native_context, code_object); |
1250 | 1264 |
1251 // Fall out of the loop | 1265 // Fall out of the loop |
1252 loop_builder.Break(); | 1266 loop_builder.Break(); |
1253 } | 1267 } |
1254 done_check.Else(); | 1268 done_check.Else(); |
1255 done_check.End(); | 1269 done_check.End(); |
1256 } | 1270 } |
1257 restore_check.End(); | 1271 restore_check.End(); |
1258 } | 1272 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1332 return BuildUncheckedDictionaryElementLoad(receiver, key); | 1346 return BuildUncheckedDictionaryElementLoad(receiver, key); |
1333 } | 1347 } |
1334 | 1348 |
1335 | 1349 |
1336 Handle<Code> KeyedLoadDictionaryElementStub::GenerateCode(Isolate* isolate) { | 1350 Handle<Code> KeyedLoadDictionaryElementStub::GenerateCode(Isolate* isolate) { |
1337 return DoGenerateCode(isolate, this); | 1351 return DoGenerateCode(isolate, this); |
1338 } | 1352 } |
1339 | 1353 |
1340 | 1354 |
1341 } } // namespace v8::internal | 1355 } } // namespace v8::internal |
OLD | NEW |