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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 base_object()->PrintTo(stream); | 295 base_object()->PrintTo(stream); |
296 stream->Add(" + %d", offset()); | 296 stream->Add(" + %d", offset()); |
297 } | 297 } |
298 | 298 |
299 | 299 |
300 void LCallConstantFunction::PrintDataTo(StringStream* stream) { | 300 void LCallConstantFunction::PrintDataTo(StringStream* stream) { |
301 stream->Add("#%d / ", arity()); | 301 stream->Add("#%d / ", arity()); |
302 } | 302 } |
303 | 303 |
304 | 304 |
305 ExternalReference LLinkObjectInList::GetReference(Isolate* isolate) { | |
306 switch (hydrogen()->known_list()) { | |
307 case HLinkObjectInList::ALLOCATION_SITE_LIST: | |
308 return ExternalReference::allocation_sites_list_address(isolate); | |
309 } | |
310 | |
311 UNREACHABLE(); | |
312 // Return a dummy value | |
313 return ExternalReference::isolate_address(isolate); | |
314 } | |
315 | |
316 | |
317 void LLinkObjectInList::PrintDataTo(StringStream* stream) { | |
318 object()->PrintTo(stream); | |
319 stream->Add(" offset %d", hydrogen()->store_field().offset()); | |
320 } | |
321 | |
322 | |
323 void LLoadContextSlot::PrintDataTo(StringStream* stream) { | 305 void LLoadContextSlot::PrintDataTo(StringStream* stream) { |
324 context()->PrintTo(stream); | 306 context()->PrintTo(stream); |
325 stream->Add("[%d]", slot_index()); | 307 stream->Add("[%d]", slot_index()); |
326 } | 308 } |
327 | 309 |
328 | 310 |
329 void LStoreContextSlot::PrintDataTo(StringStream* stream) { | 311 void LStoreContextSlot::PrintDataTo(StringStream* stream) { |
330 context()->PrintTo(stream); | 312 context()->PrintTo(stream); |
331 stream->Add("[%d] <- ", slot_index()); | 313 stream->Add("[%d] <- ", slot_index()); |
332 value()->PrintTo(stream); | 314 value()->PrintTo(stream); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 HBasicBlock* next = NULL; | 480 HBasicBlock* next = NULL; |
499 if (i < blocks->length() - 1) next = blocks->at(i + 1); | 481 if (i < blocks->length() - 1) next = blocks->at(i + 1); |
500 DoBasicBlock(blocks->at(i), next); | 482 DoBasicBlock(blocks->at(i), next); |
501 if (is_aborted()) return NULL; | 483 if (is_aborted()) return NULL; |
502 } | 484 } |
503 status_ = DONE; | 485 status_ = DONE; |
504 return chunk_; | 486 return chunk_; |
505 } | 487 } |
506 | 488 |
507 | 489 |
508 void LChunkBuilder::Abort(const char* reason) { | 490 void LChunkBuilder::Abort(BailoutReason reason) { |
509 info()->set_bailout_reason(reason); | 491 info()->set_bailout_reason(reason); |
510 status_ = ABORTED; | 492 status_ = ABORTED; |
511 } | 493 } |
512 | 494 |
513 | 495 |
514 LUnallocated* LChunkBuilder::ToUnallocated(Register reg) { | 496 LUnallocated* LChunkBuilder::ToUnallocated(Register reg) { |
515 return new(zone()) LUnallocated(LUnallocated::FIXED_REGISTER, | 497 return new(zone()) LUnallocated(LUnallocated::FIXED_REGISTER, |
516 Register::ToAllocationIndex(reg)); | 498 Register::ToAllocationIndex(reg)); |
517 } | 499 } |
518 | 500 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 instr->set_pointer_map(new(zone()) LPointerMap(position_, zone())); | 691 instr->set_pointer_map(new(zone()) LPointerMap(position_, zone())); |
710 return instr; | 692 return instr; |
711 } | 693 } |
712 | 694 |
713 | 695 |
714 LUnallocated* LChunkBuilder::TempRegister() { | 696 LUnallocated* LChunkBuilder::TempRegister() { |
715 LUnallocated* operand = | 697 LUnallocated* operand = |
716 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER); | 698 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER); |
717 int vreg = allocator_->GetVirtualRegister(); | 699 int vreg = allocator_->GetVirtualRegister(); |
718 if (!allocator_->AllocationOk()) { | 700 if (!allocator_->AllocationOk()) { |
719 Abort("Out of virtual registers while trying to allocate temp register."); | 701 Abort(kOutOfVirtualRegistersWhileTryingToAllocateTempRegister); |
720 vreg = 0; | 702 vreg = 0; |
721 } | 703 } |
722 operand->set_virtual_register(vreg); | 704 operand->set_virtual_register(vreg); |
723 return operand; | 705 return operand; |
724 } | 706 } |
725 | 707 |
726 | 708 |
727 LOperand* LChunkBuilder::FixedTemp(Register reg) { | 709 LOperand* LChunkBuilder::FixedTemp(Register reg) { |
728 LUnallocated* operand = ToUnallocated(reg); | 710 LUnallocated* operand = ToUnallocated(reg); |
729 ASSERT(operand->HasFixedPolicy()); | 711 ASSERT(operand->HasFixedPolicy()); |
(...skipping 1409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2139 Representation r = instr->representation(); | 2121 Representation r = instr->representation(); |
2140 if (r.IsSmi()) { | 2122 if (r.IsSmi()) { |
2141 return DefineAsRegister(new(zone()) LConstantS); | 2123 return DefineAsRegister(new(zone()) LConstantS); |
2142 } else if (r.IsInteger32()) { | 2124 } else if (r.IsInteger32()) { |
2143 return DefineAsRegister(new(zone()) LConstantI); | 2125 return DefineAsRegister(new(zone()) LConstantI); |
2144 } else if (r.IsDouble()) { | 2126 } else if (r.IsDouble()) { |
2145 double value = instr->DoubleValue(); | 2127 double value = instr->DoubleValue(); |
2146 bool value_is_zero = BitCast<uint64_t, double>(value) == 0; | 2128 bool value_is_zero = BitCast<uint64_t, double>(value) == 0; |
2147 LOperand* temp = value_is_zero ? NULL : TempRegister(); | 2129 LOperand* temp = value_is_zero ? NULL : TempRegister(); |
2148 return DefineAsRegister(new(zone()) LConstantD(temp)); | 2130 return DefineAsRegister(new(zone()) LConstantD(temp)); |
| 2131 } else if (r.IsExternal()) { |
| 2132 return DefineAsRegister(new(zone()) LConstantE); |
2149 } else if (r.IsTagged()) { | 2133 } else if (r.IsTagged()) { |
2150 return DefineAsRegister(new(zone()) LConstantT); | 2134 return DefineAsRegister(new(zone()) LConstantT); |
2151 } else { | 2135 } else { |
2152 UNREACHABLE(); | 2136 UNREACHABLE(); |
2153 return NULL; | 2137 return NULL; |
2154 } | 2138 } |
2155 } | 2139 } |
2156 | 2140 |
2157 | 2141 |
2158 LInstruction* LChunkBuilder::DoLoadGlobalCell(HLoadGlobalCell* instr) { | 2142 LInstruction* LChunkBuilder::DoLoadGlobalCell(HLoadGlobalCell* instr) { |
(...skipping 23 matching lines...) Expand all Loading... |
2182 LInstruction* LChunkBuilder::DoStoreGlobalGeneric(HStoreGlobalGeneric* instr) { | 2166 LInstruction* LChunkBuilder::DoStoreGlobalGeneric(HStoreGlobalGeneric* instr) { |
2183 LOperand* context = UseFixed(instr->context(), esi); | 2167 LOperand* context = UseFixed(instr->context(), esi); |
2184 LOperand* global_object = UseFixed(instr->global_object(), edx); | 2168 LOperand* global_object = UseFixed(instr->global_object(), edx); |
2185 LOperand* value = UseFixed(instr->value(), eax); | 2169 LOperand* value = UseFixed(instr->value(), eax); |
2186 LStoreGlobalGeneric* result = | 2170 LStoreGlobalGeneric* result = |
2187 new(zone()) LStoreGlobalGeneric(context, global_object, value); | 2171 new(zone()) LStoreGlobalGeneric(context, global_object, value); |
2188 return MarkAsCall(result, instr); | 2172 return MarkAsCall(result, instr); |
2189 } | 2173 } |
2190 | 2174 |
2191 | 2175 |
2192 LInstruction* LChunkBuilder::DoLinkObjectInList(HLinkObjectInList* instr) { | |
2193 LOperand* object = UseRegister(instr->value()); | |
2194 LOperand* temp = TempRegister(); | |
2195 LLinkObjectInList* result = new(zone()) LLinkObjectInList(object, temp); | |
2196 return result; | |
2197 } | |
2198 | |
2199 | |
2200 LInstruction* LChunkBuilder::DoLoadContextSlot(HLoadContextSlot* instr) { | 2176 LInstruction* LChunkBuilder::DoLoadContextSlot(HLoadContextSlot* instr) { |
2201 LOperand* context = UseRegisterAtStart(instr->value()); | 2177 LOperand* context = UseRegisterAtStart(instr->value()); |
2202 LInstruction* result = | 2178 LInstruction* result = |
2203 DefineAsRegister(new(zone()) LLoadContextSlot(context)); | 2179 DefineAsRegister(new(zone()) LLoadContextSlot(context)); |
2204 return instr->RequiresHoleCheck() ? AssignEnvironment(result) : result; | 2180 return instr->RequiresHoleCheck() ? AssignEnvironment(result) : result; |
2205 } | 2181 } |
2206 | 2182 |
2207 | 2183 |
2208 LInstruction* LChunkBuilder::DoStoreContextSlot(HStoreContextSlot* instr) { | 2184 LInstruction* LChunkBuilder::DoStoreContextSlot(HStoreContextSlot* instr) { |
2209 LOperand* value; | 2185 LOperand* value; |
2210 LOperand* temp; | 2186 LOperand* temp; |
2211 LOperand* context = UseRegister(instr->context()); | 2187 LOperand* context = UseRegister(instr->context()); |
2212 if (instr->NeedsWriteBarrier()) { | 2188 if (instr->NeedsWriteBarrier()) { |
2213 value = UseTempRegister(instr->value()); | 2189 value = UseTempRegister(instr->value()); |
2214 temp = TempRegister(); | 2190 temp = TempRegister(); |
2215 } else { | 2191 } else { |
2216 value = UseRegister(instr->value()); | 2192 value = UseRegister(instr->value()); |
2217 temp = NULL; | 2193 temp = NULL; |
2218 } | 2194 } |
2219 LInstruction* result = new(zone()) LStoreContextSlot(context, value, temp); | 2195 LInstruction* result = new(zone()) LStoreContextSlot(context, value, temp); |
2220 return instr->RequiresHoleCheck() ? AssignEnvironment(result) : result; | 2196 return instr->RequiresHoleCheck() ? AssignEnvironment(result) : result; |
2221 } | 2197 } |
2222 | 2198 |
2223 | 2199 |
2224 LInstruction* LChunkBuilder::DoLoadNamedField(HLoadNamedField* instr) { | 2200 LInstruction* LChunkBuilder::DoLoadNamedField(HLoadNamedField* instr) { |
2225 LOperand* obj = UseRegisterAtStart(instr->object()); | 2201 LOperand* obj = (instr->access().IsExternalMemory() && |
| 2202 instr->access().offset() == 0) |
| 2203 ? UseRegisterOrConstantAtStart(instr->object()) |
| 2204 : UseRegisterAtStart(instr->object()); |
2226 return DefineAsRegister(new(zone()) LLoadNamedField(obj)); | 2205 return DefineAsRegister(new(zone()) LLoadNamedField(obj)); |
2227 } | 2206 } |
2228 | 2207 |
2229 | 2208 |
2230 LInstruction* LChunkBuilder::DoLoadNamedFieldPolymorphic( | 2209 LInstruction* LChunkBuilder::DoLoadNamedFieldPolymorphic( |
2231 HLoadNamedFieldPolymorphic* instr) { | 2210 HLoadNamedFieldPolymorphic* instr) { |
2232 ASSERT(instr->representation().IsTagged()); | 2211 ASSERT(instr->representation().IsTagged()); |
2233 if (instr->need_generic()) { | 2212 if (instr->need_generic()) { |
2234 LOperand* context = UseFixed(instr->context(), esi); | 2213 LOperand* context = UseFixed(instr->context(), esi); |
2235 LOperand* obj = UseFixed(instr->object(), edx); | 2214 LOperand* obj = UseFixed(instr->object(), edx); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2429 LOperand* object = UseRegister(instr->object()); | 2408 LOperand* object = UseRegister(instr->object()); |
2430 LOperand* temp = TempRegister(); | 2409 LOperand* temp = TempRegister(); |
2431 LTrapAllocationMemento* result = | 2410 LTrapAllocationMemento* result = |
2432 new(zone()) LTrapAllocationMemento(object, temp); | 2411 new(zone()) LTrapAllocationMemento(object, temp); |
2433 return AssignEnvironment(result); | 2412 return AssignEnvironment(result); |
2434 } | 2413 } |
2435 | 2414 |
2436 | 2415 |
2437 LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { | 2416 LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { |
2438 bool is_in_object = instr->access().IsInobject(); | 2417 bool is_in_object = instr->access().IsInobject(); |
| 2418 bool is_external_location = instr->access().IsExternalMemory() && |
| 2419 instr->access().offset() == 0; |
2439 bool needs_write_barrier = instr->NeedsWriteBarrier(); | 2420 bool needs_write_barrier = instr->NeedsWriteBarrier(); |
2440 bool needs_write_barrier_for_map = !instr->transition().is_null() && | 2421 bool needs_write_barrier_for_map = !instr->transition().is_null() && |
2441 instr->NeedsWriteBarrierForMap(); | 2422 instr->NeedsWriteBarrierForMap(); |
2442 | 2423 |
2443 LOperand* obj; | 2424 LOperand* obj; |
2444 if (needs_write_barrier) { | 2425 if (needs_write_barrier) { |
2445 obj = is_in_object | 2426 obj = is_in_object |
2446 ? UseRegister(instr->object()) | 2427 ? UseRegister(instr->object()) |
2447 : UseTempRegister(instr->object()); | 2428 : UseTempRegister(instr->object()); |
| 2429 } else if (is_external_location) { |
| 2430 ASSERT(!is_in_object); |
| 2431 ASSERT(!needs_write_barrier); |
| 2432 ASSERT(!needs_write_barrier_for_map); |
| 2433 obj = UseRegisterOrConstant(instr->object()); |
2448 } else { | 2434 } else { |
2449 obj = needs_write_barrier_for_map | 2435 obj = needs_write_barrier_for_map |
2450 ? UseRegister(instr->object()) | 2436 ? UseRegister(instr->object()) |
2451 : UseRegisterAtStart(instr->object()); | 2437 : UseRegisterAtStart(instr->object()); |
2452 } | 2438 } |
2453 | 2439 |
2454 bool can_be_constant = instr->value()->IsConstant() && | 2440 bool can_be_constant = instr->value()->IsConstant() && |
2455 HConstant::cast(instr->value())->NotInNewSpace() && | 2441 HConstant::cast(instr->value())->NotInNewSpace() && |
2456 !(FLAG_track_double_fields && instr->field_representation().IsDouble()); | 2442 !(FLAG_track_double_fields && instr->field_representation().IsDouble()); |
2457 | 2443 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2521 | 2507 |
2522 LInstruction* LChunkBuilder::DoStringCharFromCode(HStringCharFromCode* instr) { | 2508 LInstruction* LChunkBuilder::DoStringCharFromCode(HStringCharFromCode* instr) { |
2523 LOperand* char_code = UseRegister(instr->value()); | 2509 LOperand* char_code = UseRegister(instr->value()); |
2524 LOperand* context = UseAny(instr->context()); | 2510 LOperand* context = UseAny(instr->context()); |
2525 LStringCharFromCode* result = | 2511 LStringCharFromCode* result = |
2526 new(zone()) LStringCharFromCode(context, char_code); | 2512 new(zone()) LStringCharFromCode(context, char_code); |
2527 return AssignPointerMap(DefineAsRegister(result)); | 2513 return AssignPointerMap(DefineAsRegister(result)); |
2528 } | 2514 } |
2529 | 2515 |
2530 | 2516 |
2531 LInstruction* LChunkBuilder::DoStringLength(HStringLength* instr) { | |
2532 LOperand* string = UseRegisterAtStart(instr->value()); | |
2533 return DefineAsRegister(new(zone()) LStringLength(string)); | |
2534 } | |
2535 | |
2536 | |
2537 LInstruction* LChunkBuilder::DoAllocate(HAllocate* instr) { | 2517 LInstruction* LChunkBuilder::DoAllocate(HAllocate* instr) { |
2538 info()->MarkAsDeferredCalling(); | 2518 info()->MarkAsDeferredCalling(); |
2539 LOperand* context = UseAny(instr->context()); | 2519 LOperand* context = UseAny(instr->context()); |
2540 LOperand* size = instr->size()->IsConstant() | 2520 LOperand* size = instr->size()->IsConstant() |
2541 ? UseConstant(instr->size()) | 2521 ? UseConstant(instr->size()) |
2542 : UseTempRegister(instr->size()); | 2522 : UseTempRegister(instr->size()); |
2543 LOperand* temp = TempRegister(); | 2523 LOperand* temp = TempRegister(); |
2544 LAllocate* result = new(zone()) LAllocate(context, size, temp); | 2524 LAllocate* result = new(zone()) LAllocate(context, size, temp); |
2545 return AssignPointerMap(DefineAsRegister(result)); | 2525 return AssignPointerMap(DefineAsRegister(result)); |
2546 } | 2526 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2580 int index = static_cast<int>(instr->index()); | 2560 int index = static_cast<int>(instr->index()); |
2581 Register reg = DESCRIPTOR_GET_PARAMETER_REGISTER(descriptor, index); | 2561 Register reg = DESCRIPTOR_GET_PARAMETER_REGISTER(descriptor, index); |
2582 return DefineFixed(result, reg); | 2562 return DefineFixed(result, reg); |
2583 } | 2563 } |
2584 } | 2564 } |
2585 | 2565 |
2586 | 2566 |
2587 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { | 2567 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { |
2588 int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width. | 2568 int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width. |
2589 if (spill_index > LUnallocated::kMaxFixedSlotIndex) { | 2569 if (spill_index > LUnallocated::kMaxFixedSlotIndex) { |
2590 Abort("Too many spill slots needed for OSR"); | 2570 Abort(kTooManySpillSlotsNeededForOSR); |
2591 spill_index = 0; | 2571 spill_index = 0; |
2592 } | 2572 } |
2593 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); | 2573 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); |
2594 } | 2574 } |
2595 | 2575 |
2596 | 2576 |
2597 LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) { | 2577 LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) { |
2598 LOperand* context = UseFixed(instr->context(), esi); | 2578 LOperand* context = UseFixed(instr->context(), esi); |
2599 argument_count_ -= instr->argument_count(); | 2579 argument_count_ -= instr->argument_count(); |
2600 LCallStub* result = new(zone()) LCallStub(context); | 2580 LCallStub* result = new(zone()) LCallStub(context); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2765 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2745 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2766 LOperand* object = UseRegister(instr->object()); | 2746 LOperand* object = UseRegister(instr->object()); |
2767 LOperand* index = UseTempRegister(instr->index()); | 2747 LOperand* index = UseTempRegister(instr->index()); |
2768 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2748 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2769 } | 2749 } |
2770 | 2750 |
2771 | 2751 |
2772 } } // namespace v8::internal | 2752 } } // namespace v8::internal |
2773 | 2753 |
2774 #endif // V8_TARGET_ARCH_IA32 | 2754 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |