Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: src/ia32/assembler-ia32.h

Issue 2900683002: [compiler] Delay allocation of code-embedded heap numbers. (Closed)
Patch Set: Fix rebase. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/deoptimizer.cc ('k') | src/ia32/assembler-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 268
269 class Immediate BASE_EMBEDDED { 269 class Immediate BASE_EMBEDDED {
270 public: 270 public:
271 inline explicit Immediate(int x); 271 inline explicit Immediate(int x);
272 inline explicit Immediate(const ExternalReference& ext); 272 inline explicit Immediate(const ExternalReference& ext);
273 inline explicit Immediate(Handle<Object> handle); 273 inline explicit Immediate(Handle<Object> handle);
274 inline explicit Immediate(Smi* value); 274 inline explicit Immediate(Smi* value);
275 inline explicit Immediate(Address addr); 275 inline explicit Immediate(Address addr);
276 inline explicit Immediate(Address x, RelocInfo::Mode rmode); 276 inline explicit Immediate(Address x, RelocInfo::Mode rmode);
277 277
278 static Immediate EmbeddedNumber(double value); // Smi or HeapNumber.
279
278 static Immediate CodeRelativeOffset(Label* label) { 280 static Immediate CodeRelativeOffset(Label* label) {
279 return Immediate(label); 281 return Immediate(label);
280 } 282 }
281 283
282 bool is_zero() const { return x_ == 0 && RelocInfo::IsNone(rmode_); } 284 bool is_heap_number() const {
285 DCHECK_IMPLIES(is_heap_number_, rmode_ == RelocInfo::EMBEDDED_OBJECT);
286 return is_heap_number_;
287 }
288
289 double heap_number() const {
290 DCHECK(is_heap_number());
291 return value_.heap_number;
292 }
293
294 int immediate() const {
295 DCHECK(!is_heap_number());
296 return value_.immediate;
297 }
298
299 bool is_zero() const { return RelocInfo::IsNone(rmode_) && immediate() == 0; }
283 bool is_int8() const { 300 bool is_int8() const {
284 return -128 <= x_ && x_ < 128 && RelocInfo::IsNone(rmode_); 301 return RelocInfo::IsNone(rmode_) && i::is_int8(immediate());
285 } 302 }
286 bool is_uint8() const { 303 bool is_uint8() const {
287 return v8::internal::is_uint8(x_) && RelocInfo::IsNone(rmode_); 304 return RelocInfo::IsNone(rmode_) && i::is_uint8(immediate());
288 } 305 }
289 bool is_int16() const { 306 bool is_int16() const {
290 return -32768 <= x_ && x_ < 32768 && RelocInfo::IsNone(rmode_); 307 return RelocInfo::IsNone(rmode_) && i::is_int16(immediate());
291 } 308 }
309
292 bool is_uint16() const { 310 bool is_uint16() const {
293 return v8::internal::is_uint16(x_) && RelocInfo::IsNone(rmode_); 311 return RelocInfo::IsNone(rmode_) && i::is_uint16(immediate());
294 } 312 }
295 313
296 private: 314 private:
297 inline explicit Immediate(Label* value); 315 inline explicit Immediate(Label* value);
298 316
299 int x_; 317 union {
318 double heap_number;
319 int immediate;
320 } value_;
321 bool is_heap_number_ = false;
300 RelocInfo::Mode rmode_; 322 RelocInfo::Mode rmode_;
301 323
302 friend class Operand; 324 friend class Operand;
303 friend class Assembler; 325 friend class Assembler;
304 friend class MacroAssembler; 326 friend class MacroAssembler;
305 }; 327 };
306 328
307 329
308 // ----------------------------------------------------------------------------- 330 // -----------------------------------------------------------------------------
309 // Machine instruction Operands 331 // Machine instruction Operands
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 RelocInfo::EXTERNAL_REFERENCE); 390 RelocInfo::EXTERNAL_REFERENCE);
369 } 391 }
370 392
371 static Operand ForCell(Handle<Cell> cell) { 393 static Operand ForCell(Handle<Cell> cell) {
372 AllowDeferredHandleDereference embedding_raw_address; 394 AllowDeferredHandleDereference embedding_raw_address;
373 return Operand(reinterpret_cast<int32_t>(cell.location()), 395 return Operand(reinterpret_cast<int32_t>(cell.location()),
374 RelocInfo::CELL); 396 RelocInfo::CELL);
375 } 397 }
376 398
377 static Operand ForRegisterPlusImmediate(Register base, Immediate imm) { 399 static Operand ForRegisterPlusImmediate(Register base, Immediate imm) {
378 return Operand(base, imm.x_, imm.rmode_); 400 return Operand(base, imm.value_.immediate, imm.rmode_);
379 } 401 }
380 402
381 // Returns true if this Operand is a wrapper for the specified register. 403 // Returns true if this Operand is a wrapper for the specified register.
382 bool is_reg(Register reg) const; 404 bool is_reg(Register reg) const;
383 405
384 // Returns true if this Operand is a wrapper for one register. 406 // Returns true if this Operand is a wrapper for one register.
385 bool is_reg_only() const; 407 bool is_reg_only() const;
386 408
387 // Asserts that this Operand is a wrapper for one register and returns the 409 // Asserts that this Operand is a wrapper for one register and returns the
388 // register. 410 // register.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 // is too small, a fatal error occurs. No deallocation of the buffer is done 508 // is too small, a fatal error occurs. No deallocation of the buffer is done
487 // upon destruction of the assembler. 509 // upon destruction of the assembler.
488 Assembler(Isolate* isolate, void* buffer, int buffer_size) 510 Assembler(Isolate* isolate, void* buffer, int buffer_size)
489 : Assembler(IsolateData(isolate), buffer, buffer_size) {} 511 : Assembler(IsolateData(isolate), buffer, buffer_size) {}
490 Assembler(IsolateData isolate_data, void* buffer, int buffer_size); 512 Assembler(IsolateData isolate_data, void* buffer, int buffer_size);
491 virtual ~Assembler() { } 513 virtual ~Assembler() { }
492 514
493 // GetCode emits any pending (non-emitted) code and fills the descriptor 515 // GetCode emits any pending (non-emitted) code and fills the descriptor
494 // desc. GetCode() is idempotent; it returns the same result if no other 516 // desc. GetCode() is idempotent; it returns the same result if no other
495 // Assembler functions are invoked in between GetCode() calls. 517 // Assembler functions are invoked in between GetCode() calls.
496 void GetCode(CodeDesc* desc); 518 void GetCode(Isolate* isolate, CodeDesc* desc);
497 519
498 // Read/Modify the code target in the branch/call instruction at pc. 520 // Read/Modify the code target in the branch/call instruction at pc.
499 // The isolate argument is unused (and may be nullptr) when skipping flushing. 521 // The isolate argument is unused (and may be nullptr) when skipping flushing.
500 inline static Address target_address_at(Address pc, Address constant_pool); 522 inline static Address target_address_at(Address pc, Address constant_pool);
501 inline static void set_target_address_at( 523 inline static void set_target_address_at(
502 Isolate* isolate, Address pc, Address constant_pool, Address target, 524 Isolate* isolate, Address pc, Address constant_pool, Address target,
503 ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); 525 ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED);
504 static inline Address target_address_at(Address pc, Code* code); 526 static inline Address target_address_at(Address pc, Code* code);
505 static inline void set_target_address_at( 527 static inline void set_target_address_at(
506 Isolate* isolate, Address pc, Code* code, Address target, 528 Isolate* isolate, Address pc, Code* code, Address target,
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1608 byte byte_at(int pos) { return buffer_[pos]; } 1630 byte byte_at(int pos) { return buffer_[pos]; }
1609 void set_byte_at(int pos, byte value) { buffer_[pos] = value; } 1631 void set_byte_at(int pos, byte value) { buffer_[pos] = value; }
1610 1632
1611 void PatchConstantPoolAccessInstruction(int pc_offset, int offset, 1633 void PatchConstantPoolAccessInstruction(int pc_offset, int offset,
1612 ConstantPoolEntry::Access access, 1634 ConstantPoolEntry::Access access,
1613 ConstantPoolEntry::Type type) { 1635 ConstantPoolEntry::Type type) {
1614 // No embedded constant pool support. 1636 // No embedded constant pool support.
1615 UNREACHABLE(); 1637 UNREACHABLE();
1616 } 1638 }
1617 1639
1640 // Patch the dummy heap number that we emitted at {pc} during code assembly
1641 // with the actual heap object (handle).
1642 static void set_heap_number(Handle<HeapObject> number, Address pc) {
1643 Memory::Object_Handle_at(pc) = number;
1644 }
1645
1618 protected: 1646 protected:
1619 void emit_sse_operand(XMMRegister reg, const Operand& adr); 1647 void emit_sse_operand(XMMRegister reg, const Operand& adr);
1620 void emit_sse_operand(XMMRegister dst, XMMRegister src); 1648 void emit_sse_operand(XMMRegister dst, XMMRegister src);
1621 void emit_sse_operand(Register dst, XMMRegister src); 1649 void emit_sse_operand(Register dst, XMMRegister src);
1622 void emit_sse_operand(XMMRegister dst, Register src); 1650 void emit_sse_operand(XMMRegister dst, Register src);
1623 1651
1624 byte* addr_at(int pos) { return buffer_ + pos; } 1652 byte* addr_at(int pos) { return buffer_ + pos; }
1625 1653
1626 1654
1627 private: 1655 private:
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1736 Assembler* assembler_; 1764 Assembler* assembler_;
1737 #ifdef DEBUG 1765 #ifdef DEBUG
1738 int space_before_; 1766 int space_before_;
1739 #endif 1767 #endif
1740 }; 1768 };
1741 1769
1742 } // namespace internal 1770 } // namespace internal
1743 } // namespace v8 1771 } // namespace v8
1744 1772
1745 #endif // V8_IA32_ASSEMBLER_IA32_H_ 1773 #endif // V8_IA32_ASSEMBLER_IA32_H_
OLDNEW
« no previous file with comments | « src/deoptimizer.cc ('k') | src/ia32/assembler-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698