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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 INLINE(explicit Operand(intptr_t immediate, | 302 INLINE(explicit Operand(intptr_t immediate, |
303 RelocInfo::Mode rmode = kRelocInfo_NONEPTR)); | 303 RelocInfo::Mode rmode = kRelocInfo_NONEPTR)); |
304 INLINE(static Operand Zero()) { return Operand(static_cast<intptr_t>(0)); } | 304 INLINE(static Operand Zero()) { return Operand(static_cast<intptr_t>(0)); } |
305 INLINE(explicit Operand(const ExternalReference& f)); | 305 INLINE(explicit Operand(const ExternalReference& f)); |
306 explicit Operand(Handle<Object> handle); | 306 explicit Operand(Handle<Object> handle); |
307 INLINE(explicit Operand(Smi* value)); | 307 INLINE(explicit Operand(Smi* value)); |
308 | 308 |
309 // rm | 309 // rm |
310 INLINE(explicit Operand(Register rm)); | 310 INLINE(explicit Operand(Register rm)); |
311 | 311 |
| 312 static Operand EmbeddedNumber(double value); // Smi or HeapNumber |
| 313 |
312 // Return true if this is a register operand. | 314 // Return true if this is a register operand. |
313 INLINE(bool is_reg() const); | 315 INLINE(bool is_reg() const); |
314 | 316 |
315 bool must_output_reloc_info(const Assembler* assembler) const; | 317 bool must_output_reloc_info(const Assembler* assembler) const; |
316 | 318 |
317 inline intptr_t immediate() const { | 319 inline intptr_t immediate() const { |
318 DCHECK(!rm_.is_valid()); | 320 DCHECK(!rm_.is_valid()); |
319 return imm_; | 321 DCHECK(!is_heap_number()); |
| 322 return value_.immediate; |
| 323 } |
| 324 |
| 325 double heap_number() const { |
| 326 DCHECK(is_heap_number()); |
| 327 return value_.heap_number; |
320 } | 328 } |
321 | 329 |
322 Register rm() const { return rm_; } | 330 Register rm() const { return rm_; } |
323 | 331 |
| 332 bool is_heap_number() const { |
| 333 DCHECK_IMPLIES(is_heap_number_, !rm_.is_valid()); |
| 334 DCHECK_IMPLIES(is_heap_number_, rmode_ == RelocInfo::EMBEDDED_OBJECT); |
| 335 return is_heap_number_; |
| 336 } |
| 337 |
| 338 |
324 private: | 339 private: |
325 Register rm_; | 340 Register rm_; |
326 intptr_t imm_; // valid if rm_ == no_reg | 341 int shift_imm_; // valid if rm_ != no_reg && rs_ == no_reg |
| 342 union { |
| 343 double heap_number; // if is_heap_number_ |
| 344 int32_t immediate; // otherwise |
| 345 } value_; // valid if rm_ == no_reg |
| 346 bool is_heap_number_ = false; |
| 347 |
327 RelocInfo::Mode rmode_; | 348 RelocInfo::Mode rmode_; |
328 | 349 |
329 friend class Assembler; | 350 friend class Assembler; |
330 friend class MacroAssembler; | 351 friend class MacroAssembler; |
331 }; | 352 }; |
332 | 353 |
333 | 354 |
334 // Class MemOperand represents a memory operand in load and store instructions | 355 // Class MemOperand represents a memory operand in load and store instructions |
335 // On PowerPC we have base register + 16bit signed value | 356 // On PowerPC we have base register + 16bit signed value |
336 // Alternatively we can have a 16bit signed value immediate | 357 // Alternatively we can have a 16bit signed value immediate |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 // is too small, a fatal error occurs. No deallocation of the buffer is done | 419 // is too small, a fatal error occurs. No deallocation of the buffer is done |
399 // upon destruction of the assembler. | 420 // upon destruction of the assembler. |
400 Assembler(Isolate* isolate, void* buffer, int buffer_size) | 421 Assembler(Isolate* isolate, void* buffer, int buffer_size) |
401 : Assembler(IsolateData(isolate), buffer, buffer_size) {} | 422 : Assembler(IsolateData(isolate), buffer, buffer_size) {} |
402 Assembler(IsolateData isolate_data, void* buffer, int buffer_size); | 423 Assembler(IsolateData isolate_data, void* buffer, int buffer_size); |
403 virtual ~Assembler() {} | 424 virtual ~Assembler() {} |
404 | 425 |
405 // GetCode emits any pending (non-emitted) code and fills the descriptor | 426 // GetCode emits any pending (non-emitted) code and fills the descriptor |
406 // desc. GetCode() is idempotent; it returns the same result if no other | 427 // desc. GetCode() is idempotent; it returns the same result if no other |
407 // Assembler functions are invoked in between GetCode() calls. | 428 // Assembler functions are invoked in between GetCode() calls. |
408 void GetCode(CodeDesc* desc); | 429 void GetCode(Isolate* islate, CodeDesc* desc); |
409 | 430 |
410 // Label operations & relative jumps (PPUM Appendix D) | 431 // Label operations & relative jumps (PPUM Appendix D) |
411 // | 432 // |
412 // Takes a branch opcode (cc) and a label (L) and generates | 433 // Takes a branch opcode (cc) and a label (L) and generates |
413 // either a backward branch or a forward branch and links it | 434 // either a backward branch or a forward branch and links it |
414 // to the label fixup chain. Usage: | 435 // to the label fixup chain. Usage: |
415 // | 436 // |
416 // Label L; // unbound label | 437 // Label L; // unbound label |
417 // j(cc, &L); // forward branch to unbound label | 438 // j(cc, &L); // forward branch to unbound label |
418 // bind(&L); // bind label to the current pc | 439 // bind(&L); // bind label to the current pc |
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1281 | 1302 |
1282 // Record a comment relocation entry that can be used by a disassembler. | 1303 // Record a comment relocation entry that can be used by a disassembler. |
1283 // Use --code-comments to enable. | 1304 // Use --code-comments to enable. |
1284 void RecordComment(const char* msg); | 1305 void RecordComment(const char* msg); |
1285 | 1306 |
1286 // Record a deoptimization reason that can be used by a log or cpu profiler. | 1307 // Record a deoptimization reason that can be used by a log or cpu profiler. |
1287 // Use --trace-deopt to enable. | 1308 // Use --trace-deopt to enable. |
1288 void RecordDeoptReason(DeoptimizeReason reason, SourcePosition position, | 1309 void RecordDeoptReason(DeoptimizeReason reason, SourcePosition position, |
1289 int id); | 1310 int id); |
1290 | 1311 |
| 1312 // Patch the dummy heap number that we emitted during code assembly in the |
| 1313 // constant pool entry referenced by {pc}. Replace it with the actual heap |
| 1314 // object (handle). |
| 1315 static void set_heap_number(Handle<HeapObject> number, Address pc) { |
| 1316 Memory::Address_at( |
| 1317 target_constant_pool_address_at(pc, 0, ConstantPoolEntry::REGULAR, |
| 1318 ConstantPoolEntry::INTPTR /* unused */)) = |
| 1319 reinterpret_cast<Address>(number.location()); |
| 1320 } |
| 1321 |
1291 // Writes a single byte or word of data in the code stream. Used | 1322 // Writes a single byte or word of data in the code stream. Used |
1292 // for inline tables, e.g., jump-tables. | 1323 // for inline tables, e.g., jump-tables. |
1293 void db(uint8_t data); | 1324 void db(uint8_t data); |
1294 void dd(uint32_t data); | 1325 void dd(uint32_t data); |
1295 void dq(uint64_t data); | 1326 void dq(uint64_t data); |
1296 void dp(uintptr_t data); | 1327 void dp(uintptr_t data); |
1297 | 1328 |
1298 // Read/patch instructions | 1329 // Read/patch instructions |
1299 Instr instr_at(int pos) { return *reinterpret_cast<Instr*>(buffer_ + pos); } | 1330 Instr instr_at(int pos) { return *reinterpret_cast<Instr*>(buffer_ + pos); } |
1300 void instr_at_put(int pos, Instr instr) { | 1331 void instr_at_put(int pos, Instr instr) { |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1557 PatchingAssembler(IsolateData isolate_data, byte* address, int instructions); | 1588 PatchingAssembler(IsolateData isolate_data, byte* address, int instructions); |
1558 ~PatchingAssembler(); | 1589 ~PatchingAssembler(); |
1559 | 1590 |
1560 void FlushICache(Isolate* isolate); | 1591 void FlushICache(Isolate* isolate); |
1561 }; | 1592 }; |
1562 | 1593 |
1563 } // namespace internal | 1594 } // namespace internal |
1564 } // namespace v8 | 1595 } // namespace v8 |
1565 | 1596 |
1566 #endif // V8_PPC_ASSEMBLER_PPC_H_ | 1597 #endif // V8_PPC_ASSEMBLER_PPC_H_ |
OLD | NEW |