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 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 for (int i = 1; i < current->OperandCount(); ++i) { | 870 for (int i = 1; i < current->OperandCount(); ++i) { |
871 LInstruction* dummy = | 871 LInstruction* dummy = |
872 new(zone()) LDummyUse(UseAny(current->OperandAt(i))); | 872 new(zone()) LDummyUse(UseAny(current->OperandAt(i))); |
873 dummy->set_hydrogen_value(current); | 873 dummy->set_hydrogen_value(current); |
874 chunk_->AddInstruction(dummy, current_block_); | 874 chunk_->AddInstruction(dummy, current_block_); |
875 } | 875 } |
876 } else { | 876 } else { |
877 instr = current->CompileToLithium(this); | 877 instr = current->CompileToLithium(this); |
878 } | 878 } |
879 | 879 |
| 880 argument_count_ += current->argument_delta(); |
| 881 ASSERT(argument_count_ >= 0); |
| 882 |
880 if (instr != NULL) { | 883 if (instr != NULL) { |
881 // Associate the hydrogen instruction first, since we may need it for | 884 // Associate the hydrogen instruction first, since we may need it for |
882 // the ClobbersRegisters() or ClobbersDoubleRegisters() calls below. | 885 // the ClobbersRegisters() or ClobbersDoubleRegisters() calls below. |
883 instr->set_hydrogen_value(current); | 886 instr->set_hydrogen_value(current); |
884 | 887 |
885 #if DEBUG | 888 #if DEBUG |
886 // Make sure that the lithium instruction has either no fixed register | 889 // Make sure that the lithium instruction has either no fixed register |
887 // constraints in temps or the result OR no uses that are only used at | 890 // constraints in temps or the result OR no uses that are only used at |
888 // start. If this invariant doesn't hold, the register allocator can decide | 891 // start. If this invariant doesn't hold, the register allocator can decide |
889 // to insert a split of a range immediately before the instruction due to an | 892 // to insert a split of a range immediately before the instruction due to an |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1100 LOperand* elements = UseFixed(instr->elements(), r3); | 1103 LOperand* elements = UseFixed(instr->elements(), r3); |
1101 LApplyArguments* result = new(zone()) LApplyArguments(function, | 1104 LApplyArguments* result = new(zone()) LApplyArguments(function, |
1102 receiver, | 1105 receiver, |
1103 length, | 1106 length, |
1104 elements); | 1107 elements); |
1105 return MarkAsCall(DefineFixed(result, r0), instr, CAN_DEOPTIMIZE_EAGERLY); | 1108 return MarkAsCall(DefineFixed(result, r0), instr, CAN_DEOPTIMIZE_EAGERLY); |
1106 } | 1109 } |
1107 | 1110 |
1108 | 1111 |
1109 LInstruction* LChunkBuilder::DoPushArgument(HPushArgument* instr) { | 1112 LInstruction* LChunkBuilder::DoPushArgument(HPushArgument* instr) { |
1110 ++argument_count_; | |
1111 LOperand* argument = Use(instr->argument()); | 1113 LOperand* argument = Use(instr->argument()); |
1112 return new(zone()) LPushArgument(argument); | 1114 return new(zone()) LPushArgument(argument); |
1113 } | 1115 } |
1114 | 1116 |
1115 | 1117 |
1116 LInstruction* LChunkBuilder::DoStoreCodeEntry( | 1118 LInstruction* LChunkBuilder::DoStoreCodeEntry( |
1117 HStoreCodeEntry* store_code_entry) { | 1119 HStoreCodeEntry* store_code_entry) { |
1118 LOperand* function = UseRegister(store_code_entry->function()); | 1120 LOperand* function = UseRegister(store_code_entry->function()); |
1119 LOperand* code_object = UseTempRegister(store_code_entry->code_object()); | 1121 LOperand* code_object = UseTempRegister(store_code_entry->code_object()); |
1120 return new(zone()) LStoreCodeEntry(function, code_object); | 1122 return new(zone()) LStoreCodeEntry(function, code_object); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1167 | 1169 |
1168 | 1170 |
1169 LInstruction* LChunkBuilder::DoGlobalReceiver(HGlobalReceiver* instr) { | 1171 LInstruction* LChunkBuilder::DoGlobalReceiver(HGlobalReceiver* instr) { |
1170 LOperand* global_object = UseRegisterAtStart(instr->value()); | 1172 LOperand* global_object = UseRegisterAtStart(instr->value()); |
1171 return DefineAsRegister(new(zone()) LGlobalReceiver(global_object)); | 1173 return DefineAsRegister(new(zone()) LGlobalReceiver(global_object)); |
1172 } | 1174 } |
1173 | 1175 |
1174 | 1176 |
1175 LInstruction* LChunkBuilder::DoCallConstantFunction( | 1177 LInstruction* LChunkBuilder::DoCallConstantFunction( |
1176 HCallConstantFunction* instr) { | 1178 HCallConstantFunction* instr) { |
1177 argument_count_ -= instr->argument_count(); | |
1178 return MarkAsCall(DefineFixed(new(zone()) LCallConstantFunction, r0), instr); | 1179 return MarkAsCall(DefineFixed(new(zone()) LCallConstantFunction, r0), instr); |
1179 } | 1180 } |
1180 | 1181 |
1181 | 1182 |
1182 LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) { | 1183 LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) { |
1183 LOperand* context = UseFixed(instr->context(), cp); | 1184 LOperand* context = UseFixed(instr->context(), cp); |
1184 LOperand* function = UseFixed(instr->function(), r1); | 1185 LOperand* function = UseFixed(instr->function(), r1); |
1185 argument_count_ -= instr->argument_count(); | |
1186 LInvokeFunction* result = new(zone()) LInvokeFunction(context, function); | 1186 LInvokeFunction* result = new(zone()) LInvokeFunction(context, function); |
1187 return MarkAsCall(DefineFixed(result, r0), instr, CANNOT_DEOPTIMIZE_EAGERLY); | 1187 return MarkAsCall(DefineFixed(result, r0), instr, CANNOT_DEOPTIMIZE_EAGERLY); |
1188 } | 1188 } |
1189 | 1189 |
1190 | 1190 |
1191 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) { | 1191 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) { |
1192 switch (instr->op()) { | 1192 switch (instr->op()) { |
1193 case kMathFloor: return DoMathFloor(instr); | 1193 case kMathFloor: return DoMathFloor(instr); |
1194 case kMathRound: return DoMathRound(instr); | 1194 case kMathRound: return DoMathRound(instr); |
1195 case kMathAbs: return DoMathAbs(instr); | 1195 case kMathAbs: return DoMathAbs(instr); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 LOperand* input = UseFixedDouble(instr->value(), d2); | 1284 LOperand* input = UseFixedDouble(instr->value(), d2); |
1285 LOperand* temp = FixedTemp(d3); | 1285 LOperand* temp = FixedTemp(d3); |
1286 LMathPowHalf* result = new(zone()) LMathPowHalf(input, temp); | 1286 LMathPowHalf* result = new(zone()) LMathPowHalf(input, temp); |
1287 return DefineFixedDouble(result, d2); | 1287 return DefineFixedDouble(result, d2); |
1288 } | 1288 } |
1289 | 1289 |
1290 | 1290 |
1291 LInstruction* LChunkBuilder::DoCallKeyed(HCallKeyed* instr) { | 1291 LInstruction* LChunkBuilder::DoCallKeyed(HCallKeyed* instr) { |
1292 ASSERT(instr->key()->representation().IsTagged()); | 1292 ASSERT(instr->key()->representation().IsTagged()); |
1293 LOperand* context = UseFixed(instr->context(), cp); | 1293 LOperand* context = UseFixed(instr->context(), cp); |
1294 argument_count_ -= instr->argument_count(); | |
1295 LOperand* key = UseFixed(instr->key(), r2); | 1294 LOperand* key = UseFixed(instr->key(), r2); |
1296 return MarkAsCall( | 1295 return MarkAsCall( |
1297 DefineFixed(new(zone()) LCallKeyed(context, key), r0), instr); | 1296 DefineFixed(new(zone()) LCallKeyed(context, key), r0), instr); |
1298 } | 1297 } |
1299 | 1298 |
1300 | 1299 |
1301 LInstruction* LChunkBuilder::DoCallNamed(HCallNamed* instr) { | 1300 LInstruction* LChunkBuilder::DoCallNamed(HCallNamed* instr) { |
1302 LOperand* context = UseFixed(instr->context(), cp); | 1301 LOperand* context = UseFixed(instr->context(), cp); |
1303 argument_count_ -= instr->argument_count(); | |
1304 return MarkAsCall(DefineFixed(new(zone()) LCallNamed(context), r0), instr); | 1302 return MarkAsCall(DefineFixed(new(zone()) LCallNamed(context), r0), instr); |
1305 } | 1303 } |
1306 | 1304 |
1307 | 1305 |
1308 LInstruction* LChunkBuilder::DoCallGlobal(HCallGlobal* instr) { | 1306 LInstruction* LChunkBuilder::DoCallGlobal(HCallGlobal* instr) { |
1309 LOperand* context = UseFixed(instr->context(), cp); | 1307 LOperand* context = UseFixed(instr->context(), cp); |
1310 argument_count_ -= instr->argument_count(); | |
1311 return MarkAsCall(DefineFixed(new(zone()) LCallGlobal(context), r0), instr); | 1308 return MarkAsCall(DefineFixed(new(zone()) LCallGlobal(context), r0), instr); |
1312 } | 1309 } |
1313 | 1310 |
1314 | 1311 |
1315 LInstruction* LChunkBuilder::DoCallKnownGlobal(HCallKnownGlobal* instr) { | 1312 LInstruction* LChunkBuilder::DoCallKnownGlobal(HCallKnownGlobal* instr) { |
1316 argument_count_ -= instr->argument_count(); | |
1317 return MarkAsCall(DefineFixed(new(zone()) LCallKnownGlobal, r0), instr); | 1313 return MarkAsCall(DefineFixed(new(zone()) LCallKnownGlobal, r0), instr); |
1318 } | 1314 } |
1319 | 1315 |
1320 | 1316 |
1321 LInstruction* LChunkBuilder::DoCallNew(HCallNew* instr) { | 1317 LInstruction* LChunkBuilder::DoCallNew(HCallNew* instr) { |
1322 LOperand* context = UseFixed(instr->context(), cp); | 1318 LOperand* context = UseFixed(instr->context(), cp); |
1323 LOperand* constructor = UseFixed(instr->constructor(), r1); | 1319 LOperand* constructor = UseFixed(instr->constructor(), r1); |
1324 argument_count_ -= instr->argument_count(); | |
1325 LCallNew* result = new(zone()) LCallNew(context, constructor); | 1320 LCallNew* result = new(zone()) LCallNew(context, constructor); |
1326 return MarkAsCall(DefineFixed(result, r0), instr); | 1321 return MarkAsCall(DefineFixed(result, r0), instr); |
1327 } | 1322 } |
1328 | 1323 |
1329 | 1324 |
1330 LInstruction* LChunkBuilder::DoCallNewArray(HCallNewArray* instr) { | 1325 LInstruction* LChunkBuilder::DoCallNewArray(HCallNewArray* instr) { |
1331 LOperand* context = UseFixed(instr->context(), cp); | 1326 LOperand* context = UseFixed(instr->context(), cp); |
1332 LOperand* constructor = UseFixed(instr->constructor(), r1); | 1327 LOperand* constructor = UseFixed(instr->constructor(), r1); |
1333 argument_count_ -= instr->argument_count(); | |
1334 LCallNewArray* result = new(zone()) LCallNewArray(context, constructor); | 1328 LCallNewArray* result = new(zone()) LCallNewArray(context, constructor); |
1335 return MarkAsCall(DefineFixed(result, r0), instr); | 1329 return MarkAsCall(DefineFixed(result, r0), instr); |
1336 } | 1330 } |
1337 | 1331 |
1338 | 1332 |
1339 LInstruction* LChunkBuilder::DoCallFunction(HCallFunction* instr) { | 1333 LInstruction* LChunkBuilder::DoCallFunction(HCallFunction* instr) { |
1340 LOperand* context = UseFixed(instr->context(), cp); | 1334 LOperand* context = UseFixed(instr->context(), cp); |
1341 LOperand* function = UseFixed(instr->function(), r1); | 1335 LOperand* function = UseFixed(instr->function(), r1); |
1342 argument_count_ -= instr->argument_count(); | |
1343 return MarkAsCall( | 1336 return MarkAsCall( |
1344 DefineFixed(new(zone()) LCallFunction(context, function), r0), instr); | 1337 DefineFixed(new(zone()) LCallFunction(context, function), r0), instr); |
1345 } | 1338 } |
1346 | 1339 |
1347 | 1340 |
1348 LInstruction* LChunkBuilder::DoCallRuntime(HCallRuntime* instr) { | 1341 LInstruction* LChunkBuilder::DoCallRuntime(HCallRuntime* instr) { |
1349 argument_count_ -= instr->argument_count(); | |
1350 LOperand* context = UseFixed(instr->context(), cp); | 1342 LOperand* context = UseFixed(instr->context(), cp); |
1351 return MarkAsCall(DefineFixed(new(zone()) LCallRuntime(context), r0), instr); | 1343 return MarkAsCall(DefineFixed(new(zone()) LCallRuntime(context), r0), instr); |
1352 } | 1344 } |
1353 | 1345 |
1354 | 1346 |
1355 LInstruction* LChunkBuilder::DoRor(HRor* instr) { | 1347 LInstruction* LChunkBuilder::DoRor(HRor* instr) { |
1356 return DoShift(Token::ROR, instr); | 1348 return DoShift(Token::ROR, instr); |
1357 } | 1349 } |
1358 | 1350 |
1359 | 1351 |
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2510 Abort(kTooManySpillSlotsNeededForOSR); | 2502 Abort(kTooManySpillSlotsNeededForOSR); |
2511 spill_index = 0; | 2503 spill_index = 0; |
2512 } | 2504 } |
2513 } | 2505 } |
2514 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); | 2506 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); |
2515 } | 2507 } |
2516 | 2508 |
2517 | 2509 |
2518 LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) { | 2510 LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) { |
2519 LOperand* context = UseFixed(instr->context(), cp); | 2511 LOperand* context = UseFixed(instr->context(), cp); |
2520 argument_count_ -= instr->argument_count(); | |
2521 return MarkAsCall(DefineFixed(new(zone()) LCallStub(context), r0), instr); | 2512 return MarkAsCall(DefineFixed(new(zone()) LCallStub(context), r0), instr); |
2522 } | 2513 } |
2523 | 2514 |
2524 | 2515 |
2525 LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { | 2516 LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { |
2526 // There are no real uses of the arguments object. | 2517 // There are no real uses of the arguments object. |
2527 // arguments.length and element access are supported directly on | 2518 // arguments.length and element access are supported directly on |
2528 // stack arguments, and any real arguments object use causes a bailout. | 2519 // stack arguments, and any real arguments object use causes a bailout. |
2529 // So this value is never used. | 2520 // So this value is never used. |
2530 return NULL; | 2521 return NULL; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2635 | 2626 |
2636 | 2627 |
2637 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { | 2628 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { |
2638 LInstruction* pop = NULL; | 2629 LInstruction* pop = NULL; |
2639 | 2630 |
2640 HEnvironment* env = current_block_->last_environment(); | 2631 HEnvironment* env = current_block_->last_environment(); |
2641 | 2632 |
2642 if (env->entry()->arguments_pushed()) { | 2633 if (env->entry()->arguments_pushed()) { |
2643 int argument_count = env->arguments_environment()->parameter_count(); | 2634 int argument_count = env->arguments_environment()->parameter_count(); |
2644 pop = new(zone()) LDrop(argument_count); | 2635 pop = new(zone()) LDrop(argument_count); |
2645 argument_count_ -= argument_count; | 2636 ASSERT(instr->argument_delta() == -argument_count); |
2646 } | 2637 } |
2647 | 2638 |
2648 HEnvironment* outer = current_block_->last_environment()-> | 2639 HEnvironment* outer = current_block_->last_environment()-> |
2649 DiscardInlined(false); | 2640 DiscardInlined(false); |
2650 current_block_->UpdateEnvironment(outer); | 2641 current_block_->UpdateEnvironment(outer); |
2651 | 2642 |
2652 return pop; | 2643 return pop; |
2653 } | 2644 } |
2654 | 2645 |
2655 | 2646 |
(...skipping 19 matching lines...) Expand all Loading... |
2675 | 2666 |
2676 | 2667 |
2677 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2668 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2678 LOperand* object = UseRegister(instr->object()); | 2669 LOperand* object = UseRegister(instr->object()); |
2679 LOperand* index = UseRegister(instr->index()); | 2670 LOperand* index = UseRegister(instr->index()); |
2680 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2671 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
2681 } | 2672 } |
2682 | 2673 |
2683 | 2674 |
2684 } } // namespace v8::internal | 2675 } } // namespace v8::internal |
OLD | NEW |