| OLD | NEW | 
|---|
| 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 
| 2 // All Rights Reserved. | 2 // All Rights Reserved. | 
| 3 // | 3 // | 
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without | 
| 5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions | 
| 6 // are met: | 6 // are met: | 
| 7 // | 7 // | 
| 8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, | 
| 9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. | 
| 10 // | 10 // | 
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 177   return Assembler::target_address_at(pc_, host_); | 177   return Assembler::target_address_at(pc_, host_); | 
| 178 } | 178 } | 
| 179 | 179 | 
| 180 uint32_t RelocInfo::wasm_function_table_size_reference() { | 180 uint32_t RelocInfo::wasm_function_table_size_reference() { | 
| 181   DCHECK(IsWasmFunctionTableSizeReference(rmode_)); | 181   DCHECK(IsWasmFunctionTableSizeReference(rmode_)); | 
| 182   return static_cast<uint32_t>( | 182   return static_cast<uint32_t>( | 
| 183       reinterpret_cast<intptr_t>(Assembler::target_address_at(pc_, host_))); | 183       reinterpret_cast<intptr_t>(Assembler::target_address_at(pc_, host_))); | 
| 184 } | 184 } | 
| 185 | 185 | 
| 186 void RelocInfo::unchecked_update_wasm_memory_reference( | 186 void RelocInfo::unchecked_update_wasm_memory_reference( | 
| 187     Address address, ICacheFlushMode flush_mode) { | 187     Isolate* isolate, Address address, ICacheFlushMode flush_mode) { | 
| 188   Assembler::set_target_address_at(isolate_, pc_, host_, address, flush_mode); | 188   Assembler::set_target_address_at(isolate, pc_, host_, address, flush_mode); | 
| 189 } | 189 } | 
| 190 | 190 | 
| 191 void RelocInfo::unchecked_update_wasm_size(uint32_t size, | 191 void RelocInfo::unchecked_update_wasm_size(Isolate* isolate, uint32_t size, | 
| 192                                            ICacheFlushMode flush_mode) { | 192                                            ICacheFlushMode flush_mode) { | 
| 193   Assembler::set_target_address_at(isolate_, pc_, host_, | 193   Assembler::set_target_address_at(isolate, pc_, host_, | 
| 194                                    reinterpret_cast<Address>(size), flush_mode); | 194                                    reinterpret_cast<Address>(size), flush_mode); | 
| 195 } | 195 } | 
| 196 | 196 | 
| 197 // ----------------------------------------------------------------------------- | 197 // ----------------------------------------------------------------------------- | 
| 198 // Implementation of Operand and MemOperand | 198 // Implementation of Operand and MemOperand | 
| 199 // See assembler-ppc-inl.h for inlined constructors | 199 // See assembler-ppc-inl.h for inlined constructors | 
| 200 | 200 | 
| 201 Operand::Operand(Handle<Object> handle) { | 201 Operand::Operand(Handle<Object> handle) { | 
| 202   AllowDeferredHandleDereference using_raw_address; | 202   AllowDeferredHandleDereference using_raw_address; | 
| 203   rm_ = no_reg; | 203   rm_ = no_reg; | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
| 224 MemOperand::MemOperand(Register ra, Register rb) { | 224 MemOperand::MemOperand(Register ra, Register rb) { | 
| 225   ra_ = ra; | 225   ra_ = ra; | 
| 226   rb_ = rb; | 226   rb_ = rb; | 
| 227   offset_ = 0; | 227   offset_ = 0; | 
| 228 } | 228 } | 
| 229 | 229 | 
| 230 | 230 | 
| 231 // ----------------------------------------------------------------------------- | 231 // ----------------------------------------------------------------------------- | 
| 232 // Specific instructions, constants, and masks. | 232 // Specific instructions, constants, and masks. | 
| 233 | 233 | 
| 234 Assembler::Assembler(Isolate* isolate, void* buffer, int buffer_size) | 234 Assembler::Assembler(IsolateData isolate_data, void* buffer, int buffer_size) | 
| 235     : AssemblerBase(isolate, buffer, buffer_size), | 235     : AssemblerBase(isolate_data, buffer, buffer_size), | 
| 236       recorded_ast_id_(TypeFeedbackId::None()), | 236       recorded_ast_id_(TypeFeedbackId::None()), | 
| 237       constant_pool_builder_(kLoadPtrMaxReachBits, kLoadDoubleMaxReachBits) { | 237       constant_pool_builder_(kLoadPtrMaxReachBits, kLoadDoubleMaxReachBits) { | 
| 238   reloc_info_writer.Reposition(buffer_ + buffer_size_, pc_); | 238   reloc_info_writer.Reposition(buffer_ + buffer_size_, pc_); | 
| 239 | 239 | 
| 240   no_trampoline_pool_before_ = 0; | 240   no_trampoline_pool_before_ = 0; | 
| 241   trampoline_pool_blocked_nesting_ = 0; | 241   trampoline_pool_blocked_nesting_ = 0; | 
| 242   constant_pool_entry_sharing_blocked_nesting_ = 0; | 242   constant_pool_entry_sharing_blocked_nesting_ = 0; | 
| 243   next_trampoline_check_ = kMaxInt; | 243   next_trampoline_check_ = kMaxInt; | 
| 244   internal_trampoline_exception_ = false; | 244   internal_trampoline_exception_ = false; | 
| 245   last_bound_pos_ = 0; | 245   last_bound_pos_ = 0; | 
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 486         instr |= (imm16 & kImm16Mask); | 486         instr |= (imm16 & kImm16Mask); | 
| 487       } | 487       } | 
| 488       instr_at_put(pos, instr); | 488       instr_at_put(pos, instr); | 
| 489       break; | 489       break; | 
| 490     } | 490     } | 
| 491     case kUnboundMovLabelOffsetOpcode: { | 491     case kUnboundMovLabelOffsetOpcode: { | 
| 492       // Load the position of the label relative to the generated code object | 492       // Load the position of the label relative to the generated code object | 
| 493       // pointer in a register. | 493       // pointer in a register. | 
| 494       Register dst = Register::from_code(instr_at(pos + kInstrSize)); | 494       Register dst = Register::from_code(instr_at(pos + kInstrSize)); | 
| 495       int32_t offset = target_pos + (Code::kHeaderSize - kHeapObjectTag); | 495       int32_t offset = target_pos + (Code::kHeaderSize - kHeapObjectTag); | 
| 496       CodePatcher patcher(isolate(), reinterpret_cast<byte*>(buffer_ + pos), 2, | 496       PatchingAssembler patcher(isolate_data(), | 
| 497                           CodePatcher::DONT_FLUSH); | 497                                 reinterpret_cast<byte*>(buffer_ + pos), 2); | 
| 498       patcher.masm()->bitwise_mov32(dst, offset); | 498       patcher.bitwise_mov32(dst, offset); | 
| 499       break; | 499       break; | 
| 500     } | 500     } | 
| 501     case kUnboundAddLabelOffsetOpcode: { | 501     case kUnboundAddLabelOffsetOpcode: { | 
| 502       // dst = base + position + immediate | 502       // dst = base + position + immediate | 
| 503       Instr operands = instr_at(pos + kInstrSize); | 503       Instr operands = instr_at(pos + kInstrSize); | 
| 504       Register dst = Register::from_code((operands >> 21) & 0x1f); | 504       Register dst = Register::from_code((operands >> 21) & 0x1f); | 
| 505       Register base = Register::from_code((operands >> 16) & 0x1f); | 505       Register base = Register::from_code((operands >> 16) & 0x1f); | 
| 506       int32_t offset = target_pos + SIGN_EXT_IMM16(operands & kImm16Mask); | 506       int32_t offset = target_pos + SIGN_EXT_IMM16(operands & kImm16Mask); | 
| 507       CodePatcher patcher(isolate(), reinterpret_cast<byte*>(buffer_ + pos), 2, | 507       PatchingAssembler patcher(isolate_data(), | 
| 508                           CodePatcher::DONT_FLUSH); | 508                                 reinterpret_cast<byte*>(buffer_ + pos), 2); | 
| 509       patcher.masm()->bitwise_add32(dst, base, offset); | 509       patcher.bitwise_add32(dst, base, offset); | 
| 510       break; | 510       break; | 
| 511     } | 511     } | 
| 512     case kUnboundMovLabelAddrOpcode: { | 512     case kUnboundMovLabelAddrOpcode: { | 
| 513       // Load the address of the label in a register. | 513       // Load the address of the label in a register. | 
| 514       Register dst = Register::from_code(instr_at(pos + kInstrSize)); | 514       Register dst = Register::from_code(instr_at(pos + kInstrSize)); | 
| 515       CodePatcher patcher(isolate(), reinterpret_cast<byte*>(buffer_ + pos), | 515       PatchingAssembler patcher(isolate_data(), | 
| 516                           kMovInstructionsNoConstantPool, | 516                                 reinterpret_cast<byte*>(buffer_ + pos), | 
| 517                           CodePatcher::DONT_FLUSH); | 517                                 kMovInstructionsNoConstantPool); | 
| 518       // Keep internal references relative until EmitRelocations. | 518       // Keep internal references relative until EmitRelocations. | 
| 519       patcher.masm()->bitwise_mov(dst, target_pos); | 519       patcher.bitwise_mov(dst, target_pos); | 
| 520       break; | 520       break; | 
| 521     } | 521     } | 
| 522     case kUnboundJumpTableEntryOpcode: { | 522     case kUnboundJumpTableEntryOpcode: { | 
| 523       CodePatcher patcher(isolate(), reinterpret_cast<byte*>(buffer_ + pos), | 523       PatchingAssembler patcher(isolate_data(), | 
| 524                           kPointerSize / kInstrSize, CodePatcher::DONT_FLUSH); | 524                                 reinterpret_cast<byte*>(buffer_ + pos), | 
|  | 525                                 kPointerSize / kInstrSize); | 
| 525       // Keep internal references relative until EmitRelocations. | 526       // Keep internal references relative until EmitRelocations. | 
| 526       patcher.masm()->dp(target_pos); | 527       patcher.dp(target_pos); | 
| 527       break; | 528       break; | 
| 528     } | 529     } | 
| 529     default: | 530     default: | 
| 530       DCHECK(false); | 531       DCHECK(false); | 
| 531       break; | 532       break; | 
| 532   } | 533   } | 
| 533 } | 534 } | 
| 534 | 535 | 
| 535 | 536 | 
| 536 int Assembler::max_reach_from(int pos) { | 537 int Assembler::max_reach_from(int pos) { | 
| (...skipping 1941 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2478 | 2479 | 
| 2479 | 2480 | 
| 2480 void Assembler::EmitRelocations() { | 2481 void Assembler::EmitRelocations() { | 
| 2481   EnsureSpaceFor(relocations_.size() * kMaxRelocSize); | 2482   EnsureSpaceFor(relocations_.size() * kMaxRelocSize); | 
| 2482 | 2483 | 
| 2483   for (std::vector<DeferredRelocInfo>::iterator it = relocations_.begin(); | 2484   for (std::vector<DeferredRelocInfo>::iterator it = relocations_.begin(); | 
| 2484        it != relocations_.end(); it++) { | 2485        it != relocations_.end(); it++) { | 
| 2485     RelocInfo::Mode rmode = it->rmode(); | 2486     RelocInfo::Mode rmode = it->rmode(); | 
| 2486     Address pc = buffer_ + it->position(); | 2487     Address pc = buffer_ + it->position(); | 
| 2487     Code* code = NULL; | 2488     Code* code = NULL; | 
| 2488     RelocInfo rinfo(isolate(), pc, rmode, it->data(), code); | 2489     RelocInfo rinfo(pc, rmode, it->data(), code); | 
| 2489 | 2490 | 
| 2490     // Fix up internal references now that they are guaranteed to be bound. | 2491     // Fix up internal references now that they are guaranteed to be bound. | 
| 2491     if (RelocInfo::IsInternalReference(rmode)) { | 2492     if (RelocInfo::IsInternalReference(rmode)) { | 
| 2492       // Jump table entry | 2493       // Jump table entry | 
| 2493       intptr_t pos = reinterpret_cast<intptr_t>(Memory::Address_at(pc)); | 2494       intptr_t pos = reinterpret_cast<intptr_t>(Memory::Address_at(pc)); | 
| 2494       Memory::Address_at(pc) = buffer_ + pos; | 2495       Memory::Address_at(pc) = buffer_ + pos; | 
| 2495     } else if (RelocInfo::IsInternalReferenceEncoded(rmode)) { | 2496     } else if (RelocInfo::IsInternalReferenceEncoded(rmode)) { | 
| 2496       // mov sequence | 2497       // mov sequence | 
| 2497       intptr_t pos = reinterpret_cast<intptr_t>(target_address_at(pc, code)); | 2498       intptr_t pos = reinterpret_cast<intptr_t>(target_address_at(pc, code)); | 
| 2498       set_target_address_at(isolate(), pc, code, buffer_ + pos, | 2499       set_target_address_at(nullptr, pc, code, buffer_ + pos, | 
| 2499                             SKIP_ICACHE_FLUSH); | 2500                             SKIP_ICACHE_FLUSH); | 
| 2500     } | 2501     } | 
| 2501 | 2502 | 
| 2502     reloc_info_writer.Write(&rinfo); | 2503     reloc_info_writer.Write(&rinfo); | 
| 2503   } | 2504   } | 
| 2504 } | 2505 } | 
| 2505 | 2506 | 
| 2506 | 2507 | 
| 2507 void Assembler::BlockTrampolinePoolFor(int instructions) { | 2508 void Assembler::BlockTrampolinePoolFor(int instructions) { | 
| 2508   BlockTrampolinePoolBefore(pc_offset() + instructions * kInstrSize); | 2509   BlockTrampolinePoolBefore(pc_offset() + instructions * kInstrSize); | 
| (...skipping 24 matching lines...) Expand all  Loading... | 
| 2533     // First we emit jump, then we emit trampoline pool. | 2534     // First we emit jump, then we emit trampoline pool. | 
| 2534     b(size + kInstrSize, LeaveLK); | 2535     b(size + kInstrSize, LeaveLK); | 
| 2535     for (int i = size; i > 0; i -= kInstrSize) { | 2536     for (int i = size; i > 0; i -= kInstrSize) { | 
| 2536       b(i, LeaveLK); | 2537       b(i, LeaveLK); | 
| 2537     } | 2538     } | 
| 2538 | 2539 | 
| 2539     trampoline_ = Trampoline(pc_offset() - size, tracked_branch_count_); | 2540     trampoline_ = Trampoline(pc_offset() - size, tracked_branch_count_); | 
| 2540   } | 2541   } | 
| 2541 } | 2542 } | 
| 2542 | 2543 | 
|  | 2544 PatchingAssembler::PatchingAssembler(IsolateData isolate_data, byte* address, | 
|  | 2545                                      int instructions) | 
|  | 2546     : Assembler(isolate_data, address, instructions * kInstrSize + kGap) { | 
|  | 2547   DCHECK_EQ(reloc_info_writer.pos(), buffer_ + buffer_size_); | 
|  | 2548 } | 
|  | 2549 | 
|  | 2550 PatchingAssembler::~PatchingAssembler() { | 
|  | 2551   // Check that the code was patched as expected. | 
|  | 2552   DCHECK_EQ(pc_, buffer_ + buffer_size_ - kGap); | 
|  | 2553   DCHECK_EQ(reloc_info_writer.pos(), buffer_ + buffer_size_); | 
|  | 2554 } | 
|  | 2555 | 
|  | 2556 void PatchingAssembler::FlushICache(Isolate* isolate) { | 
|  | 2557   Assembler::FlushICache(isolate, buffer_, buffer_size_ - kGap); | 
|  | 2558 } | 
| 2543 | 2559 | 
| 2544 }  // namespace internal | 2560 }  // namespace internal | 
| 2545 }  // namespace v8 | 2561 }  // namespace v8 | 
| 2546 | 2562 | 
| 2547 #endif  // V8_TARGET_ARCH_PPC | 2563 #endif  // V8_TARGET_ARCH_PPC | 
| OLD | NEW | 
|---|