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(), | |
1200 Representation::Smi()); | |
Toon Verwaest
2013/12/11 12:40:29
Any reason why you manually set the representation
Yang
2013/12/11 13:11:15
Yep, this was not necessary.
| |
1197 IfBuilder already_in(this); | 1201 IfBuilder already_in(this); |
1198 already_in.If<HCompareObjectEqAndBranch>(native_context, | 1202 already_in.If<HCompareObjectEqAndBranch>(native_context, |
1199 first_context_slot); | 1203 first_context_slot); |
1204 already_in.AndIf<HCompareObjectEqAndBranch>(first_osr_ast_slot, | |
1205 osr_ast_id_none); | |
1200 already_in.Then(); | 1206 already_in.Then(); |
1201 { | 1207 { |
1202 HValue* code_object = Add<HLoadNamedField>(optimized_map, | 1208 HValue* code_object = Add<HLoadNamedField>(optimized_map, |
1203 HObjectAccess::ForFirstCodeSlot()); | 1209 HObjectAccess::ForFirstCodeSlot()); |
1204 BuildInstallOptimizedCode(js_function, native_context, code_object); | 1210 BuildInstallOptimizedCode(js_function, native_context, code_object); |
1205 } | 1211 } |
1206 already_in.Else(); | 1212 already_in.Else(); |
1207 { | 1213 { |
1208 HValue* shared_function_entry_length = | 1214 HValue* shared_function_entry_length = |
1209 Add<HConstant>(SharedFunctionInfo::kEntryLength); | 1215 Add<HConstant>(SharedFunctionInfo::kEntryLength); |
1210 LoopBuilder loop_builder(this, | 1216 LoopBuilder loop_builder(this, |
1211 context(), | 1217 context(), |
1212 LoopBuilder::kPostDecrement, | 1218 LoopBuilder::kPostDecrement, |
1213 shared_function_entry_length); | 1219 shared_function_entry_length); |
1214 HValue* array_length = Add<HLoadNamedField>(optimized_map, | 1220 HValue* array_length = Add<HLoadNamedField>(optimized_map, |
1215 HObjectAccess::ForFixedArrayLength()); | 1221 HObjectAccess::ForFixedArrayLength()); |
1216 HValue* key = loop_builder.BeginBody(array_length, | 1222 HValue* slot_iterator = loop_builder.BeginBody(array_length, |
1217 graph()->GetConstant0(), | 1223 graph()->GetConstant0(), |
1218 Token::GT); | 1224 Token::GT); |
1219 { | 1225 { |
1220 // Iterate through the rest of map backwards. | 1226 // Iterate through the rest of map backwards. |
1221 // Do not double check first entry. | 1227 // Do not double check first entry. |
1222 HValue* second_entry_index = | 1228 HValue* second_entry_index = |
1223 Add<HConstant>(SharedFunctionInfo::kSecondEntryIndex); | 1229 Add<HConstant>(SharedFunctionInfo::kSecondEntryIndex); |
1224 IfBuilder restore_check(this); | 1230 IfBuilder restore_check(this); |
1225 restore_check.If<HCompareNumericAndBranch>(key, second_entry_index, | 1231 restore_check.If<HCompareNumericAndBranch>( |
1226 Token::EQ); | 1232 slot_iterator, second_entry_index, Token::EQ); |
1227 restore_check.Then(); | 1233 restore_check.Then(); |
1228 { | 1234 { |
1229 // Store the unoptimized code | 1235 // Store the unoptimized code |
1230 BuildInstallCode(js_function, shared_info); | 1236 BuildInstallCode(js_function, shared_info); |
1231 loop_builder.Break(); | 1237 loop_builder.Break(); |
1232 } | 1238 } |
1233 restore_check.Else(); | 1239 restore_check.Else(); |
1234 { | 1240 { |
1235 HValue* keyed_minus = AddUncasted<HSub>( | 1241 HValue* native_context_slot = AddUncasted<HSub>( |
1236 key, shared_function_entry_length); | 1242 slot_iterator, shared_function_entry_length); |
1237 HInstruction* keyed_lookup = Add<HLoadKeyed>(optimized_map, | 1243 HValue* osr_ast_id_slot = AddUncasted<HSub>( |
1238 keyed_minus, static_cast<HValue*>(NULL), FAST_ELEMENTS); | 1244 slot_iterator, graph()->GetConstant1()); |
Toon Verwaest
2013/12/11 12:40:29
Can you add STATIC_ASSERTs here that native_contex
Yang
2013/12/11 13:11:15
Done.
| |
1245 HInstruction* native_context_entry = Add<HLoadKeyed>(optimized_map, | |
1246 native_context_slot, static_cast<HValue*>(NULL), FAST_ELEMENTS); | |
1247 HInstruction* osr_ast_id_entry = Add<HLoadKeyed>(optimized_map, | |
1248 osr_ast_id_slot, static_cast<HValue*>(NULL), FAST_ELEMENTS); | |
1239 IfBuilder done_check(this); | 1249 IfBuilder done_check(this); |
1240 done_check.If<HCompareObjectEqAndBranch>(native_context, | 1250 done_check.If<HCompareObjectEqAndBranch>(native_context, |
1241 keyed_lookup); | 1251 native_context_entry); |
1252 done_check.AndIf<HCompareObjectEqAndBranch>(osr_ast_id_entry, | |
1253 osr_ast_id_none); | |
1242 done_check.Then(); | 1254 done_check.Then(); |
1243 { | 1255 { |
1244 // Hit: fetch the optimized code. | 1256 // Hit: fetch the optimized code. |
1245 HValue* keyed_plus = AddUncasted<HAdd>( | 1257 HValue* code_slot = AddUncasted<HAdd>( |
1246 keyed_minus, graph()->GetConstant1()); | 1258 native_context_slot, graph()->GetConstant1()); |
1247 HValue* code_object = Add<HLoadKeyed>(optimized_map, | 1259 HValue* code_object = Add<HLoadKeyed>(optimized_map, |
1248 keyed_plus, static_cast<HValue*>(NULL), FAST_ELEMENTS); | 1260 code_slot, static_cast<HValue*>(NULL), FAST_ELEMENTS); |
1249 BuildInstallOptimizedCode(js_function, native_context, code_object); | 1261 BuildInstallOptimizedCode(js_function, native_context, code_object); |
1250 | 1262 |
1251 // Fall out of the loop | 1263 // Fall out of the loop |
1252 loop_builder.Break(); | 1264 loop_builder.Break(); |
1253 } | 1265 } |
1254 done_check.Else(); | 1266 done_check.Else(); |
1255 done_check.End(); | 1267 done_check.End(); |
1256 } | 1268 } |
1257 restore_check.End(); | 1269 restore_check.End(); |
1258 } | 1270 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1332 return BuildUncheckedDictionaryElementLoad(receiver, key); | 1344 return BuildUncheckedDictionaryElementLoad(receiver, key); |
1333 } | 1345 } |
1334 | 1346 |
1335 | 1347 |
1336 Handle<Code> KeyedLoadDictionaryElementStub::GenerateCode(Isolate* isolate) { | 1348 Handle<Code> KeyedLoadDictionaryElementStub::GenerateCode(Isolate* isolate) { |
1337 return DoGenerateCode(isolate, this); | 1349 return DoGenerateCode(isolate, this); |
1338 } | 1350 } |
1339 | 1351 |
1340 | 1352 |
1341 } } // namespace v8::internal | 1353 } } // namespace v8::internal |
OLD | NEW |