Commit ea5f23af authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[Code] Store stack_slots and safepoint_table_offset as int

The value is passed as int in most places anyway, so better also store
it as int, and make sure that it's in the range [0..kMaxInt].
Also, our style guide only allows {int} out of the standard integer types.

R=mstarzinger@chromium.org

Bug: v8:6600
Change-Id: Ia425a8a6f64c9e617de02bb1d4f07413e9da4fc6
Reviewed-on: https://chromium-review.googlesource.com/810645
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49904}
parent ac5b4223
......@@ -14524,8 +14524,7 @@ void Code::Disassemble(const char* name, std::ostream& os) { // NOLINT
{
Isolate* isolate = GetIsolate();
int size = instruction_size();
int safepoint_offset =
is_turbofanned() ? static_cast<int>(safepoint_table_offset()) : size;
int safepoint_offset = is_turbofanned() ? safepoint_table_offset() : size;
int constant_pool_offset = FLAG_enable_embedded_constant_pool
? this->constant_pool_offset()
: size;
......
......@@ -290,7 +290,7 @@ Code::Kind Code::kind() const {
void Code::initialize_flags(Kind kind, bool has_unwinding_info,
bool is_turbofanned, int stack_slots) {
CHECK_LE(stack_slots, StackSlotsField::kMax);
CHECK(0 <= stack_slots && stack_slots < StackSlotsField::kMax);
DCHECK_IMPLIES(stack_slots != 0, is_turbofanned);
static_assert(Code::NUMBER_OF_KINDS <= KindField::kMax + 1, "field overflow");
uint32_t flags = HasUnwindingInfoField::encode(has_unwinding_info) |
......@@ -411,21 +411,21 @@ void Code::set_builtin_index(int index) {
bool Code::is_builtin() const { return builtin_index() != -1; }
unsigned Code::stack_slots() const {
int Code::stack_slots() const {
DCHECK(is_turbofanned());
return StackSlotsField::decode(READ_UINT32_FIELD(this, kFlagsOffset));
}
unsigned Code::safepoint_table_offset() const {
int Code::safepoint_table_offset() const {
DCHECK(is_turbofanned());
return READ_UINT32_FIELD(this, kSafepointTableOffsetOffset);
return READ_INT32_FIELD(this, kSafepointTableOffsetOffset);
}
void Code::set_safepoint_table_offset(unsigned offset) {
CHECK(offset <= std::numeric_limits<uint32_t>::max());
void Code::set_safepoint_table_offset(int offset) {
CHECK_LE(0, offset);
DCHECK(is_turbofanned() || offset == 0); // Allow zero initialization.
DCHECK(IsAligned(offset, static_cast<unsigned>(kIntSize)));
WRITE_UINT32_FIELD(this, kSafepointTableOffsetOffset, offset);
WRITE_INT32_FIELD(this, kSafepointTableOffsetOffset, offset);
}
bool Code::marked_for_deoptimization() const {
......
......@@ -235,12 +235,12 @@ class Code : public HeapObject {
// [stack_slots]: For kind OPTIMIZED_FUNCTION, the number of stack slots
// reserved in the code prologue.
inline unsigned stack_slots() const;
inline int stack_slots() const;
// [safepoint_table_start]: For kind OPTIMIZED_FUNCTION, the offset in
// the instruction stream where the safepoint table starts.
inline unsigned safepoint_table_offset() const;
inline void set_safepoint_table_offset(unsigned offset);
inline int safepoint_table_offset() const;
inline void set_safepoint_table_offset(int offset);
// [marked_for_deoptimization]: For kind OPTIMIZED_FUNCTION tells whether
// the code is going to be deoptimized because of dead embedded maps.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment