| 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 25 matching lines...) Expand all Loading... |
| 36 namespace v8 { | 36 namespace v8 { |
| 37 namespace internal { | 37 namespace internal { |
| 38 | 38 |
| 39 #define DEFINE_COMPILE(type) \ | 39 #define DEFINE_COMPILE(type) \ |
| 40 void L##type::CompileToNative(LCodeGen* generator) { \ | 40 void L##type::CompileToNative(LCodeGen* generator) { \ |
| 41 generator->Do##type(this); \ | 41 generator->Do##type(this); \ |
| 42 } | 42 } |
| 43 LITHIUM_CONCRETE_INSTRUCTION_LIST(DEFINE_COMPILE) | 43 LITHIUM_CONCRETE_INSTRUCTION_LIST(DEFINE_COMPILE) |
| 44 #undef DEFINE_COMPILE | 44 #undef DEFINE_COMPILE |
| 45 | 45 |
| 46 LOsrEntry::LOsrEntry() { | |
| 47 for (int i = 0; i < Register::NumAllocatableRegisters(); ++i) { | |
| 48 register_spills_[i] = NULL; | |
| 49 } | |
| 50 for (int i = 0; i < DoubleRegister::NumAllocatableRegisters(); ++i) { | |
| 51 double_register_spills_[i] = NULL; | |
| 52 } | |
| 53 } | |
| 54 | |
| 55 | |
| 56 void LOsrEntry::MarkSpilledRegister(int allocation_index, | |
| 57 LOperand* spill_operand) { | |
| 58 ASSERT(spill_operand->IsStackSlot()); | |
| 59 ASSERT(register_spills_[allocation_index] == NULL); | |
| 60 register_spills_[allocation_index] = spill_operand; | |
| 61 } | |
| 62 | |
| 63 | |
| 64 void LOsrEntry::MarkSpilledDoubleRegister(int allocation_index, | |
| 65 LOperand* spill_operand) { | |
| 66 ASSERT(spill_operand->IsDoubleStackSlot()); | |
| 67 ASSERT(double_register_spills_[allocation_index] == NULL); | |
| 68 double_register_spills_[allocation_index] = spill_operand; | |
| 69 } | |
| 70 | |
| 71 | 46 |
| 72 #ifdef DEBUG | 47 #ifdef DEBUG |
| 73 void LInstruction::VerifyCall() { | 48 void LInstruction::VerifyCall() { |
| 74 // Call instructions can use only fixed registers as temporaries and | 49 // Call instructions can use only fixed registers as temporaries and |
| 75 // outputs because all registers are blocked by the calling convention. | 50 // outputs because all registers are blocked by the calling convention. |
| 76 // Inputs operands must use a fixed register or use-at-start policy or | 51 // Inputs operands must use a fixed register or use-at-start policy or |
| 77 // a non-register policy. | 52 // a non-register policy. |
| 78 ASSERT(Output() == NULL || | 53 ASSERT(Output() == NULL || |
| 79 LUnallocated::cast(Output())->HasFixedPolicy() || | 54 LUnallocated::cast(Output())->HasFixedPolicy() || |
| 80 !LUnallocated::cast(Output())->HasRegisterPolicy()); | 55 !LUnallocated::cast(Output())->HasRegisterPolicy()); |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 | 424 |
| 450 void LTransitionElementsKind::PrintDataTo(StringStream* stream) { | 425 void LTransitionElementsKind::PrintDataTo(StringStream* stream) { |
| 451 object()->PrintTo(stream); | 426 object()->PrintTo(stream); |
| 452 stream->Add(" %p -> %p", *original_map(), *transitioned_map()); | 427 stream->Add(" %p -> %p", *original_map(), *transitioned_map()); |
| 453 } | 428 } |
| 454 | 429 |
| 455 | 430 |
| 456 LPlatformChunk* LChunkBuilder::Build() { | 431 LPlatformChunk* LChunkBuilder::Build() { |
| 457 ASSERT(is_unused()); | 432 ASSERT(is_unused()); |
| 458 chunk_ = new(zone()) LPlatformChunk(info(), graph()); | 433 chunk_ = new(zone()) LPlatformChunk(info(), graph()); |
| 459 HPhase phase("L_Building chunk", chunk_); | 434 LPhase phase("L_Building chunk", chunk_); |
| 460 status_ = BUILDING; | 435 status_ = BUILDING; |
| 461 const ZoneList<HBasicBlock*>* blocks = graph()->blocks(); | 436 const ZoneList<HBasicBlock*>* blocks = graph()->blocks(); |
| 462 for (int i = 0; i < blocks->length(); i++) { | 437 for (int i = 0; i < blocks->length(); i++) { |
| 463 HBasicBlock* next = NULL; | 438 HBasicBlock* next = NULL; |
| 464 if (i < blocks->length() - 1) next = blocks->at(i + 1); | 439 if (i < blocks->length() - 1) next = blocks->at(i + 1); |
| 465 DoBasicBlock(blocks->at(i), next); | 440 DoBasicBlock(blocks->at(i), next); |
| 466 if (is_aborted()) return NULL; | 441 if (is_aborted()) return NULL; |
| 467 } | 442 } |
| 468 status_ = DONE; | 443 status_ = DONE; |
| 469 return chunk_; | 444 return chunk_; |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 ASSERT(value->IsConstant()); | 982 ASSERT(value->IsConstant()); |
| 1008 ASSERT(!value->representation().IsDouble()); | 983 ASSERT(!value->representation().IsDouble()); |
| 1009 HBasicBlock* successor = HConstant::cast(value)->BooleanValue() | 984 HBasicBlock* successor = HConstant::cast(value)->BooleanValue() |
| 1010 ? instr->FirstSuccessor() | 985 ? instr->FirstSuccessor() |
| 1011 : instr->SecondSuccessor(); | 986 : instr->SecondSuccessor(); |
| 1012 return new(zone()) LGoto(successor->block_id()); | 987 return new(zone()) LGoto(successor->block_id()); |
| 1013 } | 988 } |
| 1014 | 989 |
| 1015 LBranch* result = new(zone()) LBranch(UseRegister(value)); | 990 LBranch* result = new(zone()) LBranch(UseRegister(value)); |
| 1016 // Tagged values that are not known smis or booleans require a | 991 // Tagged values that are not known smis or booleans require a |
| 1017 // deoptimization environment. | 992 // deoptimization environment. If the instruction is generic no |
| 993 // environment is needed since all cases are handled. |
| 994 ToBooleanStub::Types expected = instr->expected_input_types(); |
| 1018 Representation rep = value->representation(); | 995 Representation rep = value->representation(); |
| 1019 HType type = value->type(); | 996 HType type = value->type(); |
| 1020 if (rep.IsTagged() && !type.IsSmi() && !type.IsBoolean()) { | 997 if (rep.IsTagged() && !type.IsSmi() && !type.IsBoolean() && |
| 998 !expected.IsGeneric()) { |
| 1021 return AssignEnvironment(result); | 999 return AssignEnvironment(result); |
| 1022 } | 1000 } |
| 1023 return result; | 1001 return result; |
| 1024 } | 1002 } |
| 1025 | 1003 |
| 1026 | 1004 |
| 1027 LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) { | 1005 LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) { |
| 1028 ASSERT(instr->value()->representation().IsTagged()); | 1006 ASSERT(instr->value()->representation().IsTagged()); |
| 1029 LOperand* value = UseRegisterAtStart(instr->value()); | 1007 LOperand* value = UseRegisterAtStart(instr->value()); |
| 1030 return new(zone()) LCmpMapAndBranch(value); | 1008 return new(zone()) LCmpMapAndBranch(value); |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1280 | 1258 |
| 1281 LInstruction* LChunkBuilder::DoCallNew(HCallNew* instr) { | 1259 LInstruction* LChunkBuilder::DoCallNew(HCallNew* instr) { |
| 1282 LOperand* constructor = UseFixed(instr->constructor(), rdi); | 1260 LOperand* constructor = UseFixed(instr->constructor(), rdi); |
| 1283 argument_count_ -= instr->argument_count(); | 1261 argument_count_ -= instr->argument_count(); |
| 1284 LCallNew* result = new(zone()) LCallNew(constructor); | 1262 LCallNew* result = new(zone()) LCallNew(constructor); |
| 1285 return MarkAsCall(DefineFixed(result, rax), instr); | 1263 return MarkAsCall(DefineFixed(result, rax), instr); |
| 1286 } | 1264 } |
| 1287 | 1265 |
| 1288 | 1266 |
| 1289 LInstruction* LChunkBuilder::DoCallNewArray(HCallNewArray* instr) { | 1267 LInstruction* LChunkBuilder::DoCallNewArray(HCallNewArray* instr) { |
| 1290 ASSERT(FLAG_optimize_constructed_arrays); | |
| 1291 LOperand* constructor = UseFixed(instr->constructor(), rdi); | 1268 LOperand* constructor = UseFixed(instr->constructor(), rdi); |
| 1292 argument_count_ -= instr->argument_count(); | 1269 argument_count_ -= instr->argument_count(); |
| 1293 LCallNewArray* result = new(zone()) LCallNewArray(constructor); | 1270 LCallNewArray* result = new(zone()) LCallNewArray(constructor); |
| 1294 return MarkAsCall(DefineFixed(result, rax), instr); | 1271 return MarkAsCall(DefineFixed(result, rax), instr); |
| 1295 } | 1272 } |
| 1296 | 1273 |
| 1297 | 1274 |
| 1298 LInstruction* LChunkBuilder::DoCallFunction(HCallFunction* instr) { | 1275 LInstruction* LChunkBuilder::DoCallFunction(HCallFunction* instr) { |
| 1299 LOperand* function = UseFixed(instr->function(), rdi); | 1276 LOperand* function = UseFixed(instr->function(), rdi); |
| 1300 argument_count_ -= instr->argument_count(); | 1277 argument_count_ -= instr->argument_count(); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1449 if (instr->HasPowerOf2Divisor()) { | 1426 if (instr->HasPowerOf2Divisor()) { |
| 1450 ASSERT(!right->CanBeZero()); | 1427 ASSERT(!right->CanBeZero()); |
| 1451 LModI* mod = new(zone()) LModI(UseRegisterAtStart(left), | 1428 LModI* mod = new(zone()) LModI(UseRegisterAtStart(left), |
| 1452 UseOrConstant(right), | 1429 UseOrConstant(right), |
| 1453 NULL); | 1430 NULL); |
| 1454 LInstruction* result = DefineSameAsFirst(mod); | 1431 LInstruction* result = DefineSameAsFirst(mod); |
| 1455 return (left->CanBeNegative() && | 1432 return (left->CanBeNegative() && |
| 1456 instr->CheckFlag(HValue::kBailoutOnMinusZero)) | 1433 instr->CheckFlag(HValue::kBailoutOnMinusZero)) |
| 1457 ? AssignEnvironment(result) | 1434 ? AssignEnvironment(result) |
| 1458 : result; | 1435 : result; |
| 1459 } else if (instr->has_fixed_right_arg()) { | 1436 } else if (instr->fixed_right_arg().has_value) { |
| 1460 LModI* mod = new(zone()) LModI(UseRegister(left), | 1437 LModI* mod = new(zone()) LModI(UseRegister(left), |
| 1461 UseRegisterAtStart(right), | 1438 UseRegisterAtStart(right), |
| 1462 NULL); | 1439 NULL); |
| 1463 return AssignEnvironment(DefineSameAsFirst(mod)); | 1440 return AssignEnvironment(DefineSameAsFirst(mod)); |
| 1464 } else { | 1441 } else { |
| 1465 // The temporary operand is necessary to ensure that right is not | 1442 // The temporary operand is necessary to ensure that right is not |
| 1466 // allocated into edx. | 1443 // allocated into edx. |
| 1467 LModI* mod = new(zone()) LModI(UseFixed(left, rax), | 1444 LModI* mod = new(zone()) LModI(UseFixed(left, rax), |
| 1468 UseRegister(right), | 1445 UseRegister(right), |
| 1469 FixedTemp(rdx)); | 1446 FixedTemp(rdx)); |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1929 LOperand* value = Use(instr->value()); | 1906 LOperand* value = Use(instr->value()); |
| 1930 return DefineAsRegister(new(zone()) LInteger32ToDouble(value)); | 1907 return DefineAsRegister(new(zone()) LInteger32ToDouble(value)); |
| 1931 } | 1908 } |
| 1932 } | 1909 } |
| 1933 } | 1910 } |
| 1934 UNREACHABLE(); | 1911 UNREACHABLE(); |
| 1935 return NULL; | 1912 return NULL; |
| 1936 } | 1913 } |
| 1937 | 1914 |
| 1938 | 1915 |
| 1939 LInstruction* LChunkBuilder::DoCheckNonSmi(HCheckNonSmi* instr) { | 1916 LInstruction* LChunkBuilder::DoCheckHeapObject(HCheckHeapObject* instr) { |
| 1940 LOperand* value = UseRegisterAtStart(instr->value()); | 1917 LOperand* value = UseRegisterAtStart(instr->value()); |
| 1941 return AssignEnvironment(new(zone()) LCheckNonSmi(value)); | 1918 return AssignEnvironment(new(zone()) LCheckNonSmi(value)); |
| 1942 } | 1919 } |
| 1943 | 1920 |
| 1944 | 1921 |
| 1945 LInstruction* LChunkBuilder::DoCheckInstanceType(HCheckInstanceType* instr) { | 1922 LInstruction* LChunkBuilder::DoCheckInstanceType(HCheckInstanceType* instr) { |
| 1946 LOperand* value = UseRegisterAtStart(instr->value()); | 1923 LOperand* value = UseRegisterAtStart(instr->value()); |
| 1947 LCheckInstanceType* result = new(zone()) LCheckInstanceType(value); | 1924 LCheckInstanceType* result = new(zone()) LCheckInstanceType(value); |
| 1948 return AssignEnvironment(result); | 1925 return AssignEnvironment(result); |
| 1949 } | 1926 } |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2350 return AssignPointerMap(DefineAsRegister(result)); | 2327 return AssignPointerMap(DefineAsRegister(result)); |
| 2351 } | 2328 } |
| 2352 | 2329 |
| 2353 | 2330 |
| 2354 LInstruction* LChunkBuilder::DoStringLength(HStringLength* instr) { | 2331 LInstruction* LChunkBuilder::DoStringLength(HStringLength* instr) { |
| 2355 LOperand* string = UseRegisterAtStart(instr->value()); | 2332 LOperand* string = UseRegisterAtStart(instr->value()); |
| 2356 return DefineAsRegister(new(zone()) LStringLength(string)); | 2333 return DefineAsRegister(new(zone()) LStringLength(string)); |
| 2357 } | 2334 } |
| 2358 | 2335 |
| 2359 | 2336 |
| 2337 LInstruction* LChunkBuilder::DoAllocateObject(HAllocateObject* instr) { |
| 2338 info()->MarkAsDeferredCalling(); |
| 2339 LAllocateObject* result = new(zone()) LAllocateObject(TempRegister()); |
| 2340 return AssignPointerMap(DefineAsRegister(result)); |
| 2341 } |
| 2342 |
| 2343 |
| 2360 LInstruction* LChunkBuilder::DoAllocate(HAllocate* instr) { | 2344 LInstruction* LChunkBuilder::DoAllocate(HAllocate* instr) { |
| 2361 info()->MarkAsDeferredCalling(); | 2345 info()->MarkAsDeferredCalling(); |
| 2362 LOperand* size = instr->size()->IsConstant() | 2346 LOperand* size = instr->size()->IsConstant() |
| 2363 ? UseConstant(instr->size()) | 2347 ? UseConstant(instr->size()) |
| 2364 : UseTempRegister(instr->size()); | 2348 : UseTempRegister(instr->size()); |
| 2365 LOperand* temp = TempRegister(); | 2349 LOperand* temp = TempRegister(); |
| 2366 LAllocate* result = new(zone()) LAllocate(size, temp); | 2350 LAllocate* result = new(zone()) LAllocate(size, temp); |
| 2367 return AssignPointerMap(DefineAsRegister(result)); | 2351 return AssignPointerMap(DefineAsRegister(result)); |
| 2368 } | 2352 } |
| 2369 | 2353 |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2591 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2575 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2592 LOperand* object = UseRegister(instr->object()); | 2576 LOperand* object = UseRegister(instr->object()); |
| 2593 LOperand* index = UseTempRegister(instr->index()); | 2577 LOperand* index = UseTempRegister(instr->index()); |
| 2594 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2578 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
| 2595 } | 2579 } |
| 2596 | 2580 |
| 2597 | 2581 |
| 2598 } } // namespace v8::internal | 2582 } } // namespace v8::internal |
| 2599 | 2583 |
| 2600 #endif // V8_TARGET_ARCH_X64 | 2584 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |