Revision: 24565
Author: [email protected]
Date: Mon Oct 13 14:41:33 2014 UTC
Log: Refactor FrameAndConstantPoolScope and
ConstantPoolUnavailableScope to be architecture independent
Move the FrameAndConstantPoolScope and ConstantPoolUnavailableScope out of
the arm architecture directory to enable them to be used on all
architectures.
[email protected]
Review URL: https://codereview.chromium.org/609843002
Patch from André Baixo <[email protected]>.
https://code.google.com/p/v8/source/detail?r=24565
Modified:
/branches/bleeding_edge/src/arm/assembler-arm.cc
/branches/bleeding_edge/src/arm/assembler-arm.h
/branches/bleeding_edge/src/arm/macro-assembler-arm.cc
/branches/bleeding_edge/src/arm/macro-assembler-arm.h
/branches/bleeding_edge/src/arm64/macro-assembler-arm64.cc
/branches/bleeding_edge/src/arm64/macro-assembler-arm64.h
/branches/bleeding_edge/src/assembler.cc
/branches/bleeding_edge/src/assembler.h
/branches/bleeding_edge/src/flag-definitions.h
/branches/bleeding_edge/src/ia32/macro-assembler-ia32.cc
/branches/bleeding_edge/src/ia32/macro-assembler-ia32.h
/branches/bleeding_edge/src/macro-assembler.h
/branches/bleeding_edge/src/mips/macro-assembler-mips.cc
/branches/bleeding_edge/src/mips/macro-assembler-mips.h
/branches/bleeding_edge/src/mips64/macro-assembler-mips64.cc
/branches/bleeding_edge/src/mips64/macro-assembler-mips64.h
/branches/bleeding_edge/src/x64/macro-assembler-x64.cc
/branches/bleeding_edge/src/x64/macro-assembler-x64.h
/branches/bleeding_edge/src/x87/macro-assembler-x87.cc
/branches/bleeding_edge/src/x87/macro-assembler-x87.h
=======================================
--- /branches/bleeding_edge/src/arm/assembler-arm.cc Tue Sep 2 13:36:35
2014 UTC
+++ /branches/bleeding_edge/src/arm/assembler-arm.cc Mon Oct 13 14:41:33
2014 UTC
@@ -472,7 +472,6 @@
first_const_pool_32_use_ = -1;
first_const_pool_64_use_ = -1;
last_bound_pos_ = 0;
- constant_pool_available_ = !FLAG_enable_ool_constant_pool;
ClearRecordedAstId();
}
@@ -1056,7 +1055,8 @@
static bool use_mov_immediate_load(const Operand& x,
const Assembler* assembler) {
- if (assembler != NULL && !assembler->is_constant_pool_available()) {
+ if (FLAG_enable_ool_constant_pool && assembler != NULL &&
+ !assembler->is_ool_constant_pool_available()) {
return true;
} else if (CpuFeatures::IsSupported(MOVW_MOVT_IMMEDIATE_LOADS) &&
(assembler == NULL || !assembler->predictable_code_size())) {
@@ -1137,7 +1137,7 @@
mov(rd, target, LeaveCC, cond);
}
} else {
- DCHECK(is_constant_pool_available());
+ DCHECK(!FLAG_enable_ool_constant_pool ||
is_ool_constant_pool_available());
ConstantPoolArray::LayoutSection section = ConstantPoolAddEntry(rinfo);
if (section == ConstantPoolArray::EXTENDED_SECTION) {
DCHECK(FLAG_enable_ool_constant_pool);
@@ -2492,7 +2492,7 @@
int vd, d;
dst.split_code(&vd, &d);
emit(al | 0x1D*B23 | d*B22 | 0x3*B20 | vd*B12 | 0x5*B9 | B8 | enc);
- } else if (FLAG_enable_vldr_imm && is_constant_pool_available()) {
+ } else if (FLAG_enable_vldr_imm && is_ool_constant_pool_available()) {
// TODO(jfb) Temporarily turned off until we have constant blinding or
// some equivalent mitigation: an attacker can otherwise
control
// generated data which also happens to be executable, a
Very Bad
=======================================
--- /branches/bleeding_edge/src/arm/assembler-arm.h Wed Sep 24 11:08:35
2014 UTC
+++ /branches/bleeding_edge/src/arm/assembler-arm.h Mon Oct 13 14:41:33
2014 UTC
@@ -1487,8 +1487,6 @@
// Generate the constant pool for the generated code.
void PopulateConstantPool(ConstantPoolArray* constant_pool);
-
- bool is_constant_pool_available() const { return
constant_pool_available_; }
bool use_extended_constant_pool() const {
return constant_pool_builder_.current_section() ==
@@ -1548,10 +1546,6 @@
return (const_pool_blocked_nesting_ > 0) ||
(pc_offset() < no_const_pool_before_);
}
-
- void set_constant_pool_available(bool available) {
- constant_pool_available_ = available;
- }
private:
int next_buffer_check_; // pc offset of next buffer check
@@ -1615,10 +1609,6 @@
// The bound position, before this we cannot do instruction elimination.
int last_bound_pos_;
- // Indicates whether the constant pool can be accessed, which is only
possible
- // if the pp register points to the current code object's constant pool.
- bool constant_pool_available_;
-
// Code emission
inline void CheckBuffer();
void GrowBuffer();
@@ -1654,9 +1644,6 @@
friend class RelocInfo;
friend class CodePatcher;
friend class BlockConstPoolScope;
- friend class FrameAndConstantPoolScope;
- friend class ConstantPoolUnavailableScope;
-
PositionsRecorder positions_recorder_;
friend class PositionsRecorder;
friend class EnsureSpace;
=======================================
--- /branches/bleeding_edge/src/arm/macro-assembler-arm.cc Thu Sep 25
07:16:15 2014 UTC
+++ /branches/bleeding_edge/src/arm/macro-assembler-arm.cc Mon Oct 13
14:41:33 2014 UTC
@@ -967,7 +967,7 @@
add(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
if (FLAG_enable_ool_constant_pool) {
LoadConstantPoolPointerRegister();
- set_constant_pool_available(true);
+ set_ool_constant_pool_available(true);
}
}
@@ -992,16 +992,16 @@
}
if (FLAG_enable_ool_constant_pool) {
LoadConstantPoolPointerRegister();
- set_constant_pool_available(true);
+ set_ool_constant_pool_available(true);
}
}
void MacroAssembler::EnterFrame(StackFrame::Type type,
- bool load_constant_pool) {
+ bool load_constant_pool_pointer_reg) {
// r0-r3: preserved
PushFixedFrame();
- if (FLAG_enable_ool_constant_pool && load_constant_pool) {
+ if (FLAG_enable_ool_constant_pool && load_constant_pool_pointer_reg) {
LoadConstantPoolPointerRegister();
}
mov(ip, Operand(Smi::FromInt(type)));
=======================================
--- /branches/bleeding_edge/src/arm/macro-assembler-arm.h Wed Sep 24
07:08:27 2014 UTC
+++ /branches/bleeding_edge/src/arm/macro-assembler-arm.h Mon Oct 13
14:41:33 2014 UTC
@@ -1401,7 +1401,8 @@
}
// Activation support.
- void EnterFrame(StackFrame::Type type, bool load_constant_pool = false);
+ void EnterFrame(StackFrame::Type type,
+ bool load_constant_pool_pointer_reg = false);
// Returns the pc offset at which the frame ends.
int LeaveFrame(StackFrame::Type type);
@@ -1530,71 +1531,6 @@
};
-class FrameAndConstantPoolScope {
- public:
- FrameAndConstantPoolScope(MacroAssembler* masm, StackFrame::Type type)
- : masm_(masm),
- type_(type),
- old_has_frame_(masm->has_frame()),
- old_constant_pool_available_(masm->is_constant_pool_available()) {
- // We only want to enable constant pool access for non-manual frame
scopes
- // to ensure the constant pool pointer is valid throughout the scope.
- DCHECK(type_ != StackFrame::MANUAL && type_ != StackFrame::NONE);
- masm->set_has_frame(true);
- masm->set_constant_pool_available(true);
- masm->EnterFrame(type, !old_constant_pool_available_);
- }
-
- ~FrameAndConstantPoolScope() {
- masm_->LeaveFrame(type_);
- masm_->set_has_frame(old_has_frame_);
- masm_->set_constant_pool_available(old_constant_pool_available_);
- }
-
- // Normally we generate the leave-frame code when this object goes
- // out of scope. Sometimes we may need to generate the code somewhere
else
- // in addition. Calling this will achieve that, but the object stays in
- // scope, the MacroAssembler is still marked as being in a frame scope,
and
- // the code will be generated again when it goes out of scope.
- void GenerateLeaveFrame() {
- DCHECK(type_ != StackFrame::MANUAL && type_ != StackFrame::NONE);
- masm_->LeaveFrame(type_);
- }
-
- private:
- MacroAssembler* masm_;
- StackFrame::Type type_;
- bool old_has_frame_;
- bool old_constant_pool_available_;
-
- DISALLOW_IMPLICIT_CONSTRUCTORS(FrameAndConstantPoolScope);
-};
-
-
-// Class for scoping the the unavailability of constant pool access.
-class ConstantPoolUnavailableScope {
- public:
- explicit ConstantPoolUnavailableScope(MacroAssembler* masm)
- : masm_(masm),
- old_constant_pool_available_(masm->is_constant_pool_available()) {
- if (FLAG_enable_ool_constant_pool) {
- masm_->set_constant_pool_available(false);
- }
- }
- ~ConstantPoolUnavailableScope() {
- if (FLAG_enable_ool_constant_pool) {
- masm_->set_constant_pool_available(old_constant_pool_available_);
- }
- }
-
- private:
- MacroAssembler* masm_;
- int old_constant_pool_available_;
-
- DISALLOW_IMPLICIT_CONSTRUCTORS(ConstantPoolUnavailableScope);
-};
-
-
//
-----------------------------------------------------------------------------
// Static helper functions.
=======================================
--- /branches/bleeding_edge/src/arm64/macro-assembler-arm64.cc Thu Sep 25
07:16:15 2014 UTC
+++ /branches/bleeding_edge/src/arm64/macro-assembler-arm64.cc Mon Oct 13
14:41:33 2014 UTC
@@ -3062,6 +3062,13 @@
__ EmitFrameSetupForCodeAgePatching();
}
}
+
+
+void MacroAssembler::EnterFrame(StackFrame::Type type,
+ bool load_constant_pool_pointer_reg) {
+ // Out-of-line constant pool not implemented on arm64.
+ UNREACHABLE();
+}
void MacroAssembler::EnterFrame(StackFrame::Type type) {
=======================================
--- /branches/bleeding_edge/src/arm64/macro-assembler-arm64.h Wed Sep 24
10:22:11 2014 UTC
+++ /branches/bleeding_edge/src/arm64/macro-assembler-arm64.h Mon Oct 13
14:41:33 2014 UTC
@@ -1627,6 +1627,7 @@
// Activation support.
void EnterFrame(StackFrame::Type type);
+ void EnterFrame(StackFrame::Type type, bool
load_constant_pool_pointer_reg);
void LeaveFrame(StackFrame::Type type);
// Returns map with validated enum cache in object register.
=======================================
--- /branches/bleeding_edge/src/assembler.cc Tue Oct 7 13:30:28 2014 UTC
+++ /branches/bleeding_edge/src/assembler.cc Mon Oct 13 14:41:33 2014 UTC
@@ -131,7 +131,8 @@
emit_debug_code_(FLAG_debug_code),
predictable_code_size_(false),
// We may use the assembler without an isolate.
- serializer_enabled_(isolate && isolate->serializer_enabled()) {
+ serializer_enabled_(isolate && isolate->serializer_enabled()),
+ ool_constant_pool_available_(false) {
if (FLAG_mask_constants_with_cookie && isolate != NULL) {
jit_cookie_ = isolate->random_number_generator()->NextInt();
}
=======================================
--- /branches/bleeding_edge/src/assembler.h Tue Oct 7 13:30:28 2014 UTC
+++ /branches/bleeding_edge/src/assembler.h Mon Oct 13 14:41:33 2014 UTC
@@ -78,6 +78,16 @@
bool IsEnabled(CpuFeature f) {
return (enabled_cpu_features_ & (static_cast<uint64_t>(1) << f)) != 0;
}
+
+ bool is_ool_constant_pool_available() const {
+ if (FLAG_enable_ool_constant_pool) {
+ return ool_constant_pool_available_;
+ } else {
+ // Out-of-line constant pool not supported on this architecture.
+ UNREACHABLE();
+ return false;
+ }
+ }
// Overwrite a host NaN with a quiet target NaN. Used by mksnapshot for
// cross-snapshotting.
@@ -98,6 +108,15 @@
int buffer_size_;
bool own_buffer_;
+ void set_ool_constant_pool_available(bool available) {
+ if (FLAG_enable_ool_constant_pool) {
+ ool_constant_pool_available_ = available;
+ } else {
+ // Out-of-line constant pool not supported on this architecture.
+ UNREACHABLE();
+ }
+ }
+
// The program counter, which points into the buffer above and moves
forward.
byte* pc_;
@@ -108,6 +127,14 @@
bool emit_debug_code_;
bool predictable_code_size_;
bool serializer_enabled_;
+
+ // Indicates whether the constant pool can be accessed, which is only
possible
+ // if the pp register points to the current code object's constant pool.
+ bool ool_constant_pool_available_;
+
+ // Constant pool.
+ friend class FrameAndConstantPoolScope;
+ friend class ConstantPoolUnavailableScope;
};
=======================================
--- /branches/bleeding_edge/src/flag-definitions.h Thu Oct 9 14:01:59 2014
UTC
+++ /branches/bleeding_edge/src/flag-definitions.h Mon Oct 13 14:41:33 2014
UTC
@@ -901,7 +901,7 @@
#undef FLAG
#define FLAG FLAG_READONLY
-// assembler-arm.h
+// assembler.h
DEFINE_BOOL(enable_ool_constant_pool, V8_OOL_CONSTANT_POOL,
"enable use of out-of-line constant pools (ARM only)")
=======================================
--- /branches/bleeding_edge/src/ia32/macro-assembler-ia32.cc Thu Oct 9
12:16:27 2014 UTC
+++ /branches/bleeding_edge/src/ia32/macro-assembler-ia32.cc Mon Oct 13
14:41:33 2014 UTC
@@ -894,6 +894,13 @@
push(edi); // Callee's JS function.
}
}
+
+
+void MacroAssembler::EnterFrame(StackFrame::Type type,
+ bool load_constant_pool_pointer_reg) {
+ // Out-of-line constant pool not implemented on ia32.
+ UNREACHABLE();
+}
void MacroAssembler::EnterFrame(StackFrame::Type type) {
=======================================
--- /branches/bleeding_edge/src/ia32/macro-assembler-ia32.h Thu Oct 9
09:32:59 2014 UTC
+++ /branches/bleeding_edge/src/ia32/macro-assembler-ia32.h Mon Oct 13
14:41:33 2014 UTC
@@ -941,6 +941,7 @@
// Activation support.
void EnterFrame(StackFrame::Type type);
+ void EnterFrame(StackFrame::Type type, bool
load_constant_pool_pointer_reg);
void LeaveFrame(StackFrame::Type type);
// Expects object in eax and returns map with validated enum cache
=======================================
--- /branches/bleeding_edge/src/macro-assembler.h Tue Aug 12 13:33:35 2014
UTC
+++ /branches/bleeding_edge/src/macro-assembler.h Mon Oct 13 14:41:33 2014
UTC
@@ -124,6 +124,74 @@
bool old_has_frame_;
};
+class FrameAndConstantPoolScope {
+ public:
+ FrameAndConstantPoolScope(MacroAssembler* masm, StackFrame::Type type)
+ : masm_(masm),
+ type_(type),
+ old_has_frame_(masm->has_frame()),
+ old_constant_pool_available_(FLAG_enable_ool_constant_pool &&
+
masm->is_ool_constant_pool_available()) {
+ masm->set_has_frame(true);
+ if (FLAG_enable_ool_constant_pool) {
+ masm->set_ool_constant_pool_available(true);
+ }
+ if (type_ != StackFrame::MANUAL && type_ != StackFrame::NONE) {
+ masm->EnterFrame(type, !old_constant_pool_available_);
+ }
+ }
+
+ ~FrameAndConstantPoolScope() {
+ masm_->LeaveFrame(type_);
+ masm_->set_has_frame(old_has_frame_);
+ if (FLAG_enable_ool_constant_pool) {
+ masm_->set_ool_constant_pool_available(old_constant_pool_available_);
+ }
+ }
+
+ // Normally we generate the leave-frame code when this object goes
+ // out of scope. Sometimes we may need to generate the code somewhere
else
+ // in addition. Calling this will achieve that, but the object stays in
+ // scope, the MacroAssembler is still marked as being in a frame scope,
and
+ // the code will be generated again when it goes out of scope.
+ void GenerateLeaveFrame() {
+ DCHECK(type_ != StackFrame::MANUAL && type_ != StackFrame::NONE);
+ masm_->LeaveFrame(type_);
+ }
+
+ private:
+ MacroAssembler* masm_;
+ StackFrame::Type type_;
+ bool old_has_frame_;
+ bool old_constant_pool_available_;
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(FrameAndConstantPoolScope);
+};
+
+// Class for scoping the the unavailability of constant pool access.
+class ConstantPoolUnavailableScope {
+ public:
+ explicit ConstantPoolUnavailableScope(MacroAssembler* masm)
+ : masm_(masm),
+ old_constant_pool_available_(FLAG_enable_ool_constant_pool &&
+
masm->is_ool_constant_pool_available()) {
+ if (FLAG_enable_ool_constant_pool) {
+ masm_->set_ool_constant_pool_available(false);
+ }
+ }
+ ~ConstantPoolUnavailableScope() {
+ if (FLAG_enable_ool_constant_pool) {
+ masm_->set_ool_constant_pool_available(old_constant_pool_available_);
+ }
+ }
+
+ private:
+ MacroAssembler* masm_;
+ int old_constant_pool_available_;
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(ConstantPoolUnavailableScope);
+};
+
class AllowExternalCallThatCantCauseGC: public FrameScope {
public:
=======================================
--- /branches/bleeding_edge/src/mips/macro-assembler-mips.cc Fri Oct 10
18:00:58 2014 UTC
+++ /branches/bleeding_edge/src/mips/macro-assembler-mips.cc Mon Oct 13
14:41:33 2014 UTC
@@ -5004,6 +5004,13 @@
Addu(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
}
}
+
+
+void MacroAssembler::EnterFrame(StackFrame::Type type,
+ bool load_constant_pool_pointer_reg) {
+ // Out-of-line constant pool not implemented on mips.
+ UNREACHABLE();
+}
void MacroAssembler::EnterFrame(StackFrame::Type type) {
=======================================
--- /branches/bleeding_edge/src/mips/macro-assembler-mips.h Fri Oct 10
18:00:58 2014 UTC
+++ /branches/bleeding_edge/src/mips/macro-assembler-mips.h Mon Oct 13
14:41:33 2014 UTC
@@ -1563,6 +1563,7 @@
// Activation support.
void EnterFrame(StackFrame::Type type);
+ void EnterFrame(StackFrame::Type type, bool
load_constant_pool_pointer_reg);
void LeaveFrame(StackFrame::Type type);
// Patch the relocated value (lui/ori pair).
=======================================
--- /branches/bleeding_edge/src/mips64/macro-assembler-mips64.cc Wed Oct 8
16:15:28 2014 UTC
+++ /branches/bleeding_edge/src/mips64/macro-assembler-mips64.cc Mon Oct 13
14:41:33 2014 UTC
@@ -4777,6 +4777,13 @@
Daddu(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
}
}
+
+
+void MacroAssembler::EnterFrame(StackFrame::Type type,
+ bool load_constant_pool_pointer_reg) {
+ // Out-of-line constant pool not implemented on mips64.
+ UNREACHABLE();
+}
void MacroAssembler::EnterFrame(StackFrame::Type type) {
=======================================
--- /branches/bleeding_edge/src/mips64/macro-assembler-mips64.h Tue Sep 23
09:20:36 2014 UTC
+++ /branches/bleeding_edge/src/mips64/macro-assembler-mips64.h Mon Oct 13
14:41:33 2014 UTC
@@ -1617,6 +1617,7 @@
// Activation support.
void EnterFrame(StackFrame::Type type);
+ void EnterFrame(StackFrame::Type type, bool
load_constant_pool_pointer_reg);
void LeaveFrame(StackFrame::Type type);
// Patch the relocated value (lui/ori pair).
=======================================
--- /branches/bleeding_edge/src/x64/macro-assembler-x64.cc Tue Sep 23
11:38:12 2014 UTC
+++ /branches/bleeding_edge/src/x64/macro-assembler-x64.cc Mon Oct 13
14:41:33 2014 UTC
@@ -3982,6 +3982,13 @@
Push(rdi); // Callee's JS function.
}
}
+
+
+void MacroAssembler::EnterFrame(StackFrame::Type type,
+ bool load_constant_pool_pointer_reg) {
+ // Out-of-line constant pool not implemented on x64.
+ UNREACHABLE();
+}
void MacroAssembler::EnterFrame(StackFrame::Type type) {
=======================================
--- /branches/bleeding_edge/src/x64/macro-assembler-x64.h Wed Sep 24
07:08:27 2014 UTC
+++ /branches/bleeding_edge/src/x64/macro-assembler-x64.h Mon Oct 13
14:41:33 2014 UTC
@@ -1438,6 +1438,7 @@
// Activation support.
void EnterFrame(StackFrame::Type type);
+ void EnterFrame(StackFrame::Type type, bool
load_constant_pool_pointer_reg);
void LeaveFrame(StackFrame::Type type);
// Expects object in rax and returns map with validated enum cache
=======================================
--- /branches/bleeding_edge/src/x87/macro-assembler-x87.cc Wed Oct 8
06:08:25 2014 UTC
+++ /branches/bleeding_edge/src/x87/macro-assembler-x87.cc Mon Oct 13
14:41:33 2014 UTC
@@ -858,6 +858,13 @@
push(edi); // Callee's JS function.
}
}
+
+
+void MacroAssembler::EnterFrame(StackFrame::Type type,
+ bool load_constant_pool_pointer_reg) {
+ // Out-of-line constant pool not implemented on x87.
+ UNREACHABLE();
+}
void MacroAssembler::EnterFrame(StackFrame::Type type) {
=======================================
--- /branches/bleeding_edge/src/x87/macro-assembler-x87.h Wed Oct 8
06:08:25 2014 UTC
+++ /branches/bleeding_edge/src/x87/macro-assembler-x87.h Mon Oct 13
14:41:33 2014 UTC
@@ -906,6 +906,7 @@
// Activation support.
void EnterFrame(StackFrame::Type type);
+ void EnterFrame(StackFrame::Type type, bool
load_constant_pool_pointer_reg);
void LeaveFrame(StackFrame::Type type);
// Expects object in eax and returns map with validated enum cache
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.