Revision: 12920
Author: [email protected]
Date: Fri Nov 9 05:10:10 2012
Log: Refactoring: Make predictable code flag handling
architecture-independent.
Review URL: https://codereview.chromium.org/11359127
http://code.google.com/p/v8/source/detail?r=12920
Modified:
/branches/bleeding_edge/src/arm/assembler-arm.cc
/branches/bleeding_edge/src/arm/assembler-arm.h
/branches/bleeding_edge/src/assembler.cc
/branches/bleeding_edge/src/assembler.h
/branches/bleeding_edge/src/ia32/assembler-ia32.h
/branches/bleeding_edge/src/x64/assembler-x64.cc
/branches/bleeding_edge/src/x64/assembler-x64.h
=======================================
--- /branches/bleeding_edge/src/arm/assembler-arm.cc Mon Oct 22 08:25:17
2012
+++ /branches/bleeding_edge/src/arm/assembler-arm.cc Fri Nov 9 05:10:10
2012
@@ -326,8 +326,7 @@
: AssemblerBase(arg_isolate),
recorded_ast_id_(TypeFeedbackId::None()),
positions_recorder_(this),
- emit_debug_code_(FLAG_debug_code),
- predictable_code_size_(false) {
+ emit_debug_code_(FLAG_debug_code) {
if (buffer == NULL) {
// Do our own buffer management.
if (buffer_size <= kMinimalBufferSize) {
=======================================
--- /branches/bleeding_edge/src/arm/assembler-arm.h Mon Oct 22 08:25:17 2012
+++ /branches/bleeding_edge/src/arm/assembler-arm.h Fri Nov 9 05:10:10 2012
@@ -651,11 +651,6 @@
// Overrides the default provided by FLAG_debug_code.
void set_emit_debug_code(bool value) { emit_debug_code_ = value; }
-
- // Avoids using instructions that vary in size in unpredictable ways
between
- // the snapshot and the running VM. This is needed by the full compiler
so
- // that it can recompile code with debug support and fix the PC.
- void set_predictable_code_size(bool value) { predictable_code_size_ =
value; }
// GetCode emits any pending (non-emitted) code and fills the descriptor
// desc. GetCode() is idempotent; it returns the same result if no other
@@ -1184,8 +1179,6 @@
// Jump unconditionally to given label.
void jmp(Label* L) { b(L, al); }
-
- bool predictable_code_size() const { return predictable_code_size_; }
static bool use_immediate_embedded_pointer_loads(
const Assembler* assembler) {
@@ -1499,7 +1492,6 @@
PositionsRecorder positions_recorder_;
bool emit_debug_code_;
- bool predictable_code_size_;
friend class PositionsRecorder;
friend class EnsureSpace;
@@ -1514,26 +1506,6 @@
};
-class PredictableCodeSizeScope {
- public:
- explicit PredictableCodeSizeScope(Assembler* assembler)
- : asm_(assembler) {
- old_value_ = assembler->predictable_code_size();
- assembler->set_predictable_code_size(true);
- }
-
- ~PredictableCodeSizeScope() {
- if (!old_value_) {
- asm_->set_predictable_code_size(false);
- }
- }
-
- private:
- Assembler* asm_;
- bool old_value_;
-};
-
-
} } // namespace v8::internal
#endif // V8_ARM_ASSEMBLER_ARM_H_
=======================================
--- /branches/bleeding_edge/src/assembler.cc Thu Nov 8 04:18:11 2012
+++ /branches/bleeding_edge/src/assembler.cc Fri Nov 9 05:10:10 2012
@@ -108,7 +108,8 @@
AssemblerBase::AssemblerBase(Isolate* isolate)
: isolate_(isolate),
- jit_cookie_(0) {
+ jit_cookie_(0),
+ predictable_code_size_(false) {
if (FLAG_mask_constants_with_cookie && isolate != NULL) {
jit_cookie_ = V8::RandomPrivate(isolate);
}
=======================================
--- /branches/bleeding_edge/src/assembler.h Thu Nov 8 04:18:11 2012
+++ /branches/bleeding_edge/src/assembler.h Fri Nov 9 05:10:10 2012
@@ -59,7 +59,10 @@
explicit AssemblerBase(Isolate* isolate);
Isolate* isolate() const { return isolate_; }
- int jit_cookie() { return jit_cookie_; }
+ int jit_cookie() const { return jit_cookie_; }
+
+ bool predictable_code_size() const { return predictable_code_size_; }
+ void set_predictable_code_size(bool value) { predictable_code_size_ =
value; }
// Overwrite a host NaN with a quiet target NaN. Used by mksnapshot for
// cross-snapshotting.
@@ -68,6 +71,27 @@
private:
Isolate* isolate_;
int jit_cookie_;
+ bool predictable_code_size_;
+};
+
+
+// Avoids using instructions that vary in size in unpredictable ways
between the
+// snapshot and the running VM.
+class PredictableCodeSizeScope {
+ public:
+ explicit PredictableCodeSizeScope(AssemblerBase* assembler)
+ : assembler_(assembler) {
+ old_value_ = assembler_->predictable_code_size();
+ assembler_->set_predictable_code_size(true);
+ }
+
+ ~PredictableCodeSizeScope() {
+ assembler_->set_predictable_code_size(old_value_);
+ }
+
+ private:
+ AssemblerBase* assembler_;
+ bool old_value_;
};
=======================================
--- /branches/bleeding_edge/src/ia32/assembler-ia32.h Mon Nov 5 05:28:10
2012
+++ /branches/bleeding_edge/src/ia32/assembler-ia32.h Fri Nov 9 05:10:10
2012
@@ -586,11 +586,6 @@
// Overrides the default provided by FLAG_debug_code.
void set_emit_debug_code(bool value) { emit_debug_code_ = value; }
-
- // Avoids using instructions that vary in size in unpredictable ways
between
- // the snapshot and the running VM. This is needed by the full compiler
so
- // that it can recompile code with debug support and fix the PC.
- void set_predictable_code_size(bool value) { predictable_code_size_ =
value; }
// GetCode emits any pending (non-emitted) code and fills the descriptor
// desc. GetCode() is idempotent; it returns the same result if no other
@@ -1126,7 +1121,6 @@
protected:
bool emit_debug_code() const { return emit_debug_code_; }
- bool predictable_code_size() const { return predictable_code_size_ ; }
void movsd(XMMRegister dst, const Operand& src);
void movsd(const Operand& dst, XMMRegister src);
@@ -1202,7 +1196,6 @@
PositionsRecorder positions_recorder_;
bool emit_debug_code_;
- bool predictable_code_size_;
friend class PositionsRecorder;
};
=======================================
--- /branches/bleeding_edge/src/x64/assembler-x64.cc Thu Nov 8 04:18:11
2012
+++ /branches/bleeding_edge/src/x64/assembler-x64.cc Fri Nov 9 05:10:10
2012
@@ -350,8 +350,7 @@
: AssemblerBase(arg_isolate),
code_targets_(100),
positions_recorder_(this),
- emit_debug_code_(FLAG_debug_code),
- predictable_code_size_(false) {
+ emit_debug_code_(FLAG_debug_code) {
if (buffer == NULL) {
// Do our own buffer management.
if (buffer_size <= kMinimalBufferSize) {
@@ -1238,13 +1237,13 @@
// Determine whether we can use 1-byte offsets for backwards branches,
// which have a max range of 128 bytes.
- // We also need to check the predictable_code_size_ flag here, because
- // on x64, when the full code generator recompiles code for debugging,
some
- // places need to be padded out to a certain size. The debugger is
keeping
- // track of how often it did this so that it can adjust return
addresses on
- // the stack, but if the size of jump instructions can also change,
that's
- // not enough and the calculated offsets would be incorrect.
- if (is_int8(offs - short_size) && !predictable_code_size_) {
+ // We also need to check predictable_code_size() flag here, because on
x64,
+ // when the full code generator recompiles code for debugging, some
places
+ // need to be padded out to a certain size. The debugger is keeping
track of
+ // how often it did this so that it can adjust return addresses on the
+ // stack, but if the size of jump instructions can also change, that's
not
+ // enough and the calculated offsets would be incorrect.
+ if (is_int8(offs - short_size) && !predictable_code_size()) {
// 0111 tttn #8-bit disp.
emit(0x70 | cc);
emit((offs - short_size) & 0xFF);
@@ -1301,7 +1300,7 @@
if (L->is_bound()) {
int offs = L->pos() - pc_offset() - 1;
ASSERT(offs <= 0);
- if (is_int8(offs - short_size) && !predictable_code_size_) {
+ if (is_int8(offs - short_size) && !predictable_code_size()) {
// 1110 1011 #8-bit disp.
emit(0xEB);
emit((offs - short_size) & 0xFF);
=======================================
--- /branches/bleeding_edge/src/x64/assembler-x64.h Mon Nov 5 05:28:10 2012
+++ /branches/bleeding_edge/src/x64/assembler-x64.h Fri Nov 9 05:10:10 2012
@@ -560,11 +560,6 @@
// Overrides the default provided by FLAG_debug_code.
void set_emit_debug_code(bool value) { emit_debug_code_ = value; }
-
- // Avoids using instructions that vary in size in unpredictable ways
between
- // the snapshot and the running VM. This is needed by the full compiler
so
- // that it can recompile code with debug support and fix the PC.
- void set_predictable_code_size(bool value) { predictable_code_size_ =
value; }
// GetCode emits any pending (non-emitted) code and fills the descriptor
// desc. GetCode() is idempotent; it returns the same result if no other
@@ -1451,7 +1446,6 @@
protected:
bool emit_debug_code() const { return emit_debug_code_; }
- bool predictable_code_size() const { return predictable_code_size_; }
private:
byte* addr_at(int pos) { return buffer_ + pos; }
@@ -1656,7 +1650,6 @@
PositionsRecorder positions_recorder_;
bool emit_debug_code_;
- bool predictable_code_size_;
friend class PositionsRecorder;
};
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev