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 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 LEnvironment* LChunkBuilder::CreateEnvironment( | 926 LEnvironment* LChunkBuilder::CreateEnvironment( |
927 HEnvironment* hydrogen_env, | 927 HEnvironment* hydrogen_env, |
928 int* argument_index_accumulator) { | 928 int* argument_index_accumulator) { |
929 if (hydrogen_env == NULL) return NULL; | 929 if (hydrogen_env == NULL) return NULL; |
930 | 930 |
931 LEnvironment* outer = | 931 LEnvironment* outer = |
932 CreateEnvironment(hydrogen_env->outer(), argument_index_accumulator); | 932 CreateEnvironment(hydrogen_env->outer(), argument_index_accumulator); |
933 BailoutId ast_id = hydrogen_env->ast_id(); | 933 BailoutId ast_id = hydrogen_env->ast_id(); |
934 ASSERT(!ast_id.IsNone() || | 934 ASSERT(!ast_id.IsNone() || |
935 hydrogen_env->frame_type() != JS_FUNCTION); | 935 hydrogen_env->frame_type() != JS_FUNCTION); |
936 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); | 936 int value_count = hydrogen_env->length(); |
937 LEnvironment* result = new(zone()) LEnvironment( | 937 LEnvironment* result = new(zone()) LEnvironment( |
938 hydrogen_env->closure(), | 938 hydrogen_env->closure(), |
939 hydrogen_env->frame_type(), | 939 hydrogen_env->frame_type(), |
940 ast_id, | 940 ast_id, |
941 hydrogen_env->parameter_count(), | 941 hydrogen_env->parameter_count(), |
942 argument_count_, | 942 argument_count_, |
943 value_count, | 943 value_count, |
944 outer, | 944 outer, |
945 hydrogen_env->entry(), | 945 hydrogen_env->entry(), |
946 zone()); | 946 zone()); |
947 bool needs_arguments_object_materialization = false; | |
948 int argument_index = *argument_index_accumulator; | 947 int argument_index = *argument_index_accumulator; |
949 for (int i = 0; i < hydrogen_env->length(); ++i) { | 948 for (int i = 0; i < value_count; ++i) { |
950 if (hydrogen_env->is_special_index(i)) continue; | 949 if (hydrogen_env->is_special_index(i)) continue; |
951 | 950 |
952 HValue* value = hydrogen_env->values()->at(i); | 951 HValue* value = hydrogen_env->values()->at(i); |
953 LOperand* op = NULL; | 952 LOperand* op = NULL; |
954 if (value->IsArgumentsObject()) { | 953 if (value->IsArgumentsObject()) { |
955 needs_arguments_object_materialization = true; | |
956 op = NULL; | 954 op = NULL; |
957 } else if (value->IsPushArgument()) { | 955 } else if (value->IsPushArgument()) { |
958 op = new(zone()) LArgument(argument_index++); | 956 op = new(zone()) LArgument(argument_index++); |
959 } else { | 957 } else { |
960 op = UseAny(value); | 958 op = UseAny(value); |
961 } | 959 } |
962 result->AddValue(op, | 960 result->AddValue(op, |
963 value->representation(), | 961 value->representation(), |
964 value->CheckFlag(HInstruction::kUint32)); | 962 value->CheckFlag(HInstruction::kUint32)); |
965 } | 963 } |
966 | 964 |
967 if (needs_arguments_object_materialization) { | |
968 HArgumentsObject* arguments = hydrogen_env->entry() == NULL | |
969 ? graph()->GetArgumentsObject() | |
970 : hydrogen_env->entry()->arguments_object(); | |
971 ASSERT(arguments->IsLinked()); | |
972 for (int i = 1; i < arguments->arguments_count(); ++i) { | |
973 HValue* value = arguments->arguments_values()->at(i); | |
974 ASSERT(!value->IsArgumentsObject() && !value->IsPushArgument()); | |
975 LOperand* op = UseAny(value); | |
976 result->AddValue(op, | |
977 value->representation(), | |
978 value->CheckFlag(HInstruction::kUint32)); | |
979 } | |
980 } | |
981 | |
982 if (hydrogen_env->frame_type() == JS_FUNCTION) { | 965 if (hydrogen_env->frame_type() == JS_FUNCTION) { |
983 *argument_index_accumulator = argument_index; | 966 *argument_index_accumulator = argument_index; |
984 } | 967 } |
985 | 968 |
986 return result; | 969 return result; |
987 } | 970 } |
988 | 971 |
989 | 972 |
990 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { | 973 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { |
991 return new(zone()) LGoto(instr->FirstSuccessor()->block_id()); | 974 return new(zone()) LGoto(instr->FirstSuccessor()->block_id()); |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1352 if (instr->HasNoUses()) return NULL; | 1335 if (instr->HasNoUses()) return NULL; |
1353 LOperand* value = UseRegisterAtStart(instr->value()); | 1336 LOperand* value = UseRegisterAtStart(instr->value()); |
1354 return DefineAsRegister(new(zone()) LBitNotI(value)); | 1337 return DefineAsRegister(new(zone()) LBitNotI(value)); |
1355 } | 1338 } |
1356 | 1339 |
1357 | 1340 |
1358 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { | 1341 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { |
1359 if (instr->representation().IsDouble()) { | 1342 if (instr->representation().IsDouble()) { |
1360 return DoArithmeticD(Token::DIV, instr); | 1343 return DoArithmeticD(Token::DIV, instr); |
1361 } else if (instr->representation().IsInteger32()) { | 1344 } else if (instr->representation().IsInteger32()) { |
1362 LOperand* dividend = UseRegister(instr->left()); | 1345 // TODO(1042) The fixed register allocation |
1363 LOperand* divisor = UseRegister(instr->right()); | 1346 // is needed because we call TypeRecordingBinaryOpStub from |
1364 LDivI* div = new(zone()) LDivI(dividend, divisor); | 1347 // the generated code, which requires registers a0 |
1365 return AssignEnvironment(DefineAsRegister(div)); | 1348 // and a1 to be used. We should remove that |
| 1349 // when we provide a native implementation. |
| 1350 LOperand* dividend = UseFixed(instr->left(), a0); |
| 1351 LOperand* divisor = UseFixed(instr->right(), a1); |
| 1352 return AssignEnvironment(AssignPointerMap( |
| 1353 DefineFixed(new(zone()) LDivI(dividend, divisor), v0))); |
1366 } else { | 1354 } else { |
1367 return DoArithmeticT(Token::DIV, instr); | 1355 return DoArithmeticT(Token::DIV, instr); |
1368 } | 1356 } |
1369 } | 1357 } |
1370 | 1358 |
1371 | 1359 |
1372 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { | 1360 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { |
1373 UNIMPLEMENTED(); | 1361 UNIMPLEMENTED(); |
1374 return NULL; | 1362 return NULL; |
1375 } | 1363 } |
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2521 | 2509 |
2522 | 2510 |
2523 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2511 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2524 LOperand* object = UseRegister(instr->object()); | 2512 LOperand* object = UseRegister(instr->object()); |
2525 LOperand* index = UseRegister(instr->index()); | 2513 LOperand* index = UseRegister(instr->index()); |
2526 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2514 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
2527 } | 2515 } |
2528 | 2516 |
2529 | 2517 |
2530 } } // namespace v8::internal | 2518 } } // namespace v8::internal |
OLD | NEW |