| 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 | 253 |
| 254 void LTypeofIsAndBranch::PrintDataTo(StringStream* stream) { | 254 void LTypeofIsAndBranch::PrintDataTo(StringStream* stream) { |
| 255 stream->Add("if typeof "); | 255 stream->Add("if typeof "); |
| 256 value()->PrintTo(stream); | 256 value()->PrintTo(stream); |
| 257 stream->Add(" == \"%s\" then B%d else B%d", | 257 stream->Add(" == \"%s\" then B%d else B%d", |
| 258 *hydrogen()->type_literal()->ToCString(), | 258 *hydrogen()->type_literal()->ToCString(), |
| 259 true_block_id(), false_block_id()); | 259 true_block_id(), false_block_id()); |
| 260 } | 260 } |
| 261 | 261 |
| 262 | 262 |
| 263 void LStoreCodeEntry::PrintDataTo(StringStream* stream) { |
| 264 stream->Add(" = "); |
| 265 function()->PrintTo(stream); |
| 266 stream->Add(".code_entry = "); |
| 267 code_object()->PrintTo(stream); |
| 268 } |
| 269 |
| 270 |
| 263 void LInnerAllocatedObject::PrintDataTo(StringStream* stream) { | 271 void LInnerAllocatedObject::PrintDataTo(StringStream* stream) { |
| 264 stream->Add(" = "); | 272 stream->Add(" = "); |
| 265 base_object()->PrintTo(stream); | 273 base_object()->PrintTo(stream); |
| 266 stream->Add(" + %d", offset()); | 274 stream->Add(" + %d", offset()); |
| 267 } | 275 } |
| 268 | 276 |
| 269 | 277 |
| 270 void LCallConstantFunction::PrintDataTo(StringStream* stream) { | 278 void LCallConstantFunction::PrintDataTo(StringStream* stream) { |
| 271 stream->Add("#%d / ", arity()); | 279 stream->Add("#%d / ", arity()); |
| 272 } | 280 } |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 LOperand* right = NULL; | 719 LOperand* right = NULL; |
| 712 int constant_value = 0; | 720 int constant_value = 0; |
| 713 bool does_deopt = false; | 721 bool does_deopt = false; |
| 714 if (right_value->IsConstant()) { | 722 if (right_value->IsConstant()) { |
| 715 HConstant* constant = HConstant::cast(right_value); | 723 HConstant* constant = HConstant::cast(right_value); |
| 716 right = chunk_->DefineConstantOperand(constant); | 724 right = chunk_->DefineConstantOperand(constant); |
| 717 constant_value = constant->Integer32Value() & 0x1f; | 725 constant_value = constant->Integer32Value() & 0x1f; |
| 718 // Left shifts can deoptimize if we shift by > 0 and the result cannot be | 726 // Left shifts can deoptimize if we shift by > 0 and the result cannot be |
| 719 // truncated to smi. | 727 // truncated to smi. |
| 720 if (instr->representation().IsSmi() && constant_value > 0) { | 728 if (instr->representation().IsSmi() && constant_value > 0) { |
| 721 for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { | 729 does_deopt = !instr->CheckUsesForFlag(HValue::kTruncatingToSmi); |
| 722 if (!it.value()->CheckFlag(HValue::kTruncatingToSmi)) { | |
| 723 does_deopt = true; | |
| 724 break; | |
| 725 } | |
| 726 } | |
| 727 } | 730 } |
| 728 } else { | 731 } else { |
| 729 right = UseRegisterAtStart(right_value); | 732 right = UseRegisterAtStart(right_value); |
| 730 } | 733 } |
| 731 | 734 |
| 732 // Shift operations can only deoptimize if we do a logical shift | 735 // Shift operations can only deoptimize if we do a logical shift |
| 733 // by 0 and the result cannot be truncated to int32. | 736 // by 0 and the result cannot be truncated to int32. |
| 734 if (op == Token::SHR && constant_value == 0) { | 737 if (op == Token::SHR && constant_value == 0) { |
| 735 if (FLAG_opt_safe_uint32_operations) { | 738 if (FLAG_opt_safe_uint32_operations) { |
| 736 does_deopt = !instr->CheckFlag(HInstruction::kUint32); | 739 does_deopt = !instr->CheckFlag(HInstruction::kUint32); |
| 737 } else { | 740 } else { |
| 738 for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { | 741 does_deopt = !instr->CheckUsesForFlag(HValue::kTruncatingToInt32); |
| 739 if (!it.value()->CheckFlag(HValue::kTruncatingToInt32)) { | |
| 740 does_deopt = true; | |
| 741 break; | |
| 742 } | |
| 743 } | |
| 744 } | 742 } |
| 745 } | 743 } |
| 746 | 744 |
| 747 LInstruction* result = | 745 LInstruction* result = |
| 748 DefineAsRegister(new(zone()) LShiftI(op, left, right, does_deopt)); | 746 DefineAsRegister(new(zone()) LShiftI(op, left, right, does_deopt)); |
| 749 return does_deopt ? AssignEnvironment(result) : result; | 747 return does_deopt ? AssignEnvironment(result) : result; |
| 750 } | 748 } |
| 751 | 749 |
| 752 | 750 |
| 753 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, | 751 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1082 } | 1080 } |
| 1083 | 1081 |
| 1084 | 1082 |
| 1085 LInstruction* LChunkBuilder::DoPushArgument(HPushArgument* instr) { | 1083 LInstruction* LChunkBuilder::DoPushArgument(HPushArgument* instr) { |
| 1086 ++argument_count_; | 1084 ++argument_count_; |
| 1087 LOperand* argument = Use(instr->argument()); | 1085 LOperand* argument = Use(instr->argument()); |
| 1088 return new(zone()) LPushArgument(argument); | 1086 return new(zone()) LPushArgument(argument); |
| 1089 } | 1087 } |
| 1090 | 1088 |
| 1091 | 1089 |
| 1090 LInstruction* LChunkBuilder::DoStoreCodeEntry( |
| 1091 HStoreCodeEntry* store_code_entry) { |
| 1092 LOperand* function = UseRegister(store_code_entry->function()); |
| 1093 LOperand* code_object = UseTempRegister(store_code_entry->code_object()); |
| 1094 return new(zone()) LStoreCodeEntry(function, code_object); |
| 1095 } |
| 1096 |
| 1097 |
| 1092 LInstruction* LChunkBuilder::DoInnerAllocatedObject( | 1098 LInstruction* LChunkBuilder::DoInnerAllocatedObject( |
| 1093 HInnerAllocatedObject* inner_object) { | 1099 HInnerAllocatedObject* inner_object) { |
| 1094 LOperand* base_object = UseRegisterAtStart(inner_object->base_object()); | 1100 LOperand* base_object = UseRegisterAtStart(inner_object->base_object()); |
| 1095 LInnerAllocatedObject* result = | 1101 LInnerAllocatedObject* result = |
| 1096 new(zone()) LInnerAllocatedObject(base_object); | 1102 new(zone()) LInnerAllocatedObject(base_object); |
| 1097 return DefineAsRegister(result); | 1103 return DefineAsRegister(result); |
| 1098 } | 1104 } |
| 1099 | 1105 |
| 1100 | 1106 |
| 1101 LInstruction* LChunkBuilder::DoThisFunction(HThisFunction* instr) { | 1107 LInstruction* LChunkBuilder::DoThisFunction(HThisFunction* instr) { |
| (...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1918 } else { | 1924 } else { |
| 1919 ASSERT(to.IsInteger32()); | 1925 ASSERT(to.IsInteger32()); |
| 1920 LOperand* value = NULL; | 1926 LOperand* value = NULL; |
| 1921 LInstruction* res = NULL; | 1927 LInstruction* res = NULL; |
| 1922 if (instr->value()->type().IsSmi()) { | 1928 if (instr->value()->type().IsSmi()) { |
| 1923 value = UseRegisterAtStart(instr->value()); | 1929 value = UseRegisterAtStart(instr->value()); |
| 1924 res = DefineAsRegister(new(zone()) LSmiUntag(value, false)); | 1930 res = DefineAsRegister(new(zone()) LSmiUntag(value, false)); |
| 1925 } else { | 1931 } else { |
| 1926 value = UseRegister(instr->value()); | 1932 value = UseRegister(instr->value()); |
| 1927 LOperand* temp1 = TempRegister(); | 1933 LOperand* temp1 = TempRegister(); |
| 1928 LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister() | 1934 LOperand* temp2 = FixedTemp(d11); |
| 1929 : NULL; | |
| 1930 LOperand* temp3 = FixedTemp(d11); | |
| 1931 res = DefineSameAsFirst(new(zone()) LTaggedToI(value, | 1935 res = DefineSameAsFirst(new(zone()) LTaggedToI(value, |
| 1932 temp1, | 1936 temp1, |
| 1933 temp2, | 1937 temp2)); |
| 1934 temp3)); | |
| 1935 res = AssignEnvironment(res); | 1938 res = AssignEnvironment(res); |
| 1936 } | 1939 } |
| 1937 return res; | 1940 return res; |
| 1938 } | 1941 } |
| 1939 } else if (from.IsDouble()) { | 1942 } else if (from.IsDouble()) { |
| 1940 if (to.IsTagged()) { | 1943 if (to.IsTagged()) { |
| 1941 info()->MarkAsDeferredCalling(); | 1944 info()->MarkAsDeferredCalling(); |
| 1942 LOperand* value = UseRegister(instr->value()); | 1945 LOperand* value = UseRegister(instr->value()); |
| 1943 LOperand* temp1 = TempRegister(); | 1946 LOperand* temp1 = TempRegister(); |
| 1944 LOperand* temp2 = TempRegister(); | 1947 LOperand* temp2 = TempRegister(); |
| 1945 | 1948 |
| 1946 // Make sure that the temp and result_temp registers are | 1949 // Make sure that the temp and result_temp registers are |
| 1947 // different. | 1950 // different. |
| 1948 LUnallocated* result_temp = TempRegister(); | 1951 LUnallocated* result_temp = TempRegister(); |
| 1949 LNumberTagD* result = new(zone()) LNumberTagD(value, temp1, temp2); | 1952 LNumberTagD* result = new(zone()) LNumberTagD(value, temp1, temp2); |
| 1950 Define(result, result_temp); | 1953 Define(result, result_temp); |
| 1951 return AssignPointerMap(result); | 1954 return AssignPointerMap(result); |
| 1952 } else if (to.IsSmi()) { | 1955 } else if (to.IsSmi()) { |
| 1953 LOperand* value = UseRegister(instr->value()); | 1956 LOperand* value = UseRegister(instr->value()); |
| 1954 return AssignEnvironment(DefineAsRegister(new(zone()) LDoubleToSmi(value, | 1957 return AssignEnvironment( |
| 1955 TempRegister(), TempRegister()))); | 1958 DefineAsRegister(new(zone()) LDoubleToSmi(value))); |
| 1956 } else { | 1959 } else { |
| 1957 ASSERT(to.IsInteger32()); | 1960 ASSERT(to.IsInteger32()); |
| 1958 LOperand* value = UseRegister(instr->value()); | 1961 LOperand* value = UseRegister(instr->value()); |
| 1959 LOperand* temp1 = TempRegister(); | 1962 LDoubleToI* res = new(zone()) LDoubleToI(value); |
| 1960 LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister() : NULL; | |
| 1961 LDoubleToI* res = new(zone()) LDoubleToI(value, temp1, temp2); | |
| 1962 return AssignEnvironment(DefineAsRegister(res)); | 1963 return AssignEnvironment(DefineAsRegister(res)); |
| 1963 } | 1964 } |
| 1964 } else if (from.IsInteger32()) { | 1965 } else if (from.IsInteger32()) { |
| 1965 info()->MarkAsDeferredCalling(); | 1966 info()->MarkAsDeferredCalling(); |
| 1966 if (to.IsTagged()) { | 1967 if (to.IsTagged()) { |
| 1967 HValue* val = instr->value(); | 1968 HValue* val = instr->value(); |
| 1968 LOperand* value = UseRegisterAtStart(val); | 1969 LOperand* value = UseRegisterAtStart(val); |
| 1969 if (val->CheckFlag(HInstruction::kUint32)) { | 1970 if (val->CheckFlag(HInstruction::kUint32)) { |
| 1970 LNumberTagU* result = new(zone()) LNumberTagU(value); | 1971 LNumberTagU* result = new(zone()) LNumberTagU(value); |
| 1971 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); | 1972 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2443 LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { | 2444 LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { |
| 2444 // There are no real uses of the arguments object. | 2445 // There are no real uses of the arguments object. |
| 2445 // arguments.length and element access are supported directly on | 2446 // arguments.length and element access are supported directly on |
| 2446 // stack arguments, and any real arguments object use causes a bailout. | 2447 // stack arguments, and any real arguments object use causes a bailout. |
| 2447 // So this value is never used. | 2448 // So this value is never used. |
| 2448 return NULL; | 2449 return NULL; |
| 2449 } | 2450 } |
| 2450 | 2451 |
| 2451 | 2452 |
| 2452 LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) { | 2453 LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) { |
| 2454 instr->ReplayEnvironment(current_block_->last_environment()); |
| 2455 |
| 2453 // There are no real uses of a captured object. | 2456 // There are no real uses of a captured object. |
| 2454 return NULL; | 2457 return NULL; |
| 2455 } | 2458 } |
| 2456 | 2459 |
| 2457 | 2460 |
| 2458 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) { | 2461 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) { |
| 2459 info()->MarkAsRequiresFrame(); | 2462 info()->MarkAsRequiresFrame(); |
| 2460 LOperand* args = UseRegister(instr->arguments()); | 2463 LOperand* args = UseRegister(instr->arguments()); |
| 2461 LOperand* length; | 2464 LOperand* length; |
| 2462 LOperand* index; | 2465 LOperand* index; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2489 } | 2492 } |
| 2490 | 2493 |
| 2491 | 2494 |
| 2492 LInstruction* LChunkBuilder::DoIsConstructCallAndBranch( | 2495 LInstruction* LChunkBuilder::DoIsConstructCallAndBranch( |
| 2493 HIsConstructCallAndBranch* instr) { | 2496 HIsConstructCallAndBranch* instr) { |
| 2494 return new(zone()) LIsConstructCallAndBranch(TempRegister()); | 2497 return new(zone()) LIsConstructCallAndBranch(TempRegister()); |
| 2495 } | 2498 } |
| 2496 | 2499 |
| 2497 | 2500 |
| 2498 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { | 2501 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { |
| 2499 HEnvironment* env = current_block_->last_environment(); | 2502 instr->ReplayEnvironment(current_block_->last_environment()); |
| 2500 ASSERT(env != NULL); | |
| 2501 | |
| 2502 env->set_ast_id(instr->ast_id()); | |
| 2503 | |
| 2504 env->Drop(instr->pop_count()); | |
| 2505 for (int i = instr->values()->length() - 1; i >= 0; --i) { | |
| 2506 HValue* value = instr->values()->at(i); | |
| 2507 if (instr->HasAssignedIndexAt(i)) { | |
| 2508 env->Bind(instr->GetAssignedIndexAt(i), value); | |
| 2509 } else { | |
| 2510 env->Push(value); | |
| 2511 } | |
| 2512 } | |
| 2513 | 2503 |
| 2514 // If there is an instruction pending deoptimization environment create a | 2504 // If there is an instruction pending deoptimization environment create a |
| 2515 // lazy bailout instruction to capture the environment. | 2505 // lazy bailout instruction to capture the environment. |
| 2516 if (pending_deoptimization_ast_id_ == instr->ast_id()) { | 2506 if (pending_deoptimization_ast_id_ == instr->ast_id()) { |
| 2517 LInstruction* result = new(zone()) LLazyBailout; | 2507 LInstruction* result = new(zone()) LLazyBailout; |
| 2518 result = AssignEnvironment(result); | 2508 result = AssignEnvironment(result); |
| 2519 // Store the lazy deopt environment with the instruction if needed. Right | 2509 // Store the lazy deopt environment with the instruction if needed. Right |
| 2520 // now it is only used for LInstanceOfKnownGlobal. | 2510 // now it is only used for LInstanceOfKnownGlobal. |
| 2521 instruction_pending_deoptimization_environment_-> | 2511 instruction_pending_deoptimization_environment_-> |
| 2522 SetDeferredLazyDeoptimizationEnvironment(result->environment()); | 2512 SetDeferredLazyDeoptimizationEnvironment(result->environment()); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2599 | 2589 |
| 2600 | 2590 |
| 2601 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2591 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2602 LOperand* object = UseRegister(instr->object()); | 2592 LOperand* object = UseRegister(instr->object()); |
| 2603 LOperand* index = UseRegister(instr->index()); | 2593 LOperand* index = UseRegister(instr->index()); |
| 2604 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2594 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
| 2605 } | 2595 } |
| 2606 | 2596 |
| 2607 | 2597 |
| 2608 } } // namespace v8::internal | 2598 } } // namespace v8::internal |
| OLD | NEW |