Commit 4938aca2 authored by jacob.bramley's avatar jacob.bramley Committed by Commit bot

[arm64] Add assertions to Claim and Drop.

In particular, Claim doesn't work with a negative size, so ensure that
it is positive.

BUG=

Review URL: https://codereview.chromium.org/1565193002

Cr-Commit-Position: refs/heads/master@{#33198}
parent 37b4f287
......@@ -1462,7 +1462,8 @@ void MacroAssembler::Push(Handle<Object> handle) {
}
void MacroAssembler::Claim(uint64_t count, uint64_t unit_size) {
void MacroAssembler::Claim(int64_t count, uint64_t unit_size) {
DCHECK(count >= 0);
uint64_t size = count * unit_size;
if (size == 0) {
......@@ -1490,6 +1491,7 @@ void MacroAssembler::Claim(const Register& count, uint64_t unit_size) {
return;
}
AssertPositiveOrZero(count);
if (!csp.Is(StackPointer())) {
BumpSystemStackPointer(size);
}
......@@ -1517,7 +1519,8 @@ void MacroAssembler::ClaimBySMI(const Register& count_smi, uint64_t unit_size) {
}
void MacroAssembler::Drop(uint64_t count, uint64_t unit_size) {
void MacroAssembler::Drop(int64_t count, uint64_t unit_size) {
DCHECK(count >= 0);
uint64_t size = count * unit_size;
if (size == 0) {
......@@ -1548,6 +1551,7 @@ void MacroAssembler::Drop(const Register& count, uint64_t unit_size) {
return;
}
AssertPositiveOrZero(count);
Add(StackPointer(), StackPointer(), size);
if (!csp.Is(StackPointer()) && emit_debug_code()) {
......
......@@ -1669,6 +1669,17 @@ void MacroAssembler::AssertString(Register object) {
}
void MacroAssembler::AssertPositiveOrZero(Register value) {
if (emit_debug_code()) {
Label done;
int sign_bit = value.Is64Bits() ? kXSignBit : kWSignBit;
Tbz(value, sign_bit, &done);
Abort(kUnexpectedNegativeValue);
Bind(&done);
}
}
void MacroAssembler::CallStub(CodeStub* stub, TypeFeedbackId ast_id) {
DCHECK(AllowThisStubCall(stub)); // Stub calls are not allowed in some stubs.
Call(stub->GetCode(), RelocInfo::CODE_TARGET, ast_id);
......
......@@ -724,10 +724,10 @@ class MacroAssembler : public Assembler {
//
// Note that unit_size must be specified in bytes. For variants which take a
// Register count, the unit size must be a power of two.
inline void Claim(uint64_t count, uint64_t unit_size = kXRegSize);
inline void Claim(int64_t count, uint64_t unit_size = kXRegSize);
inline void Claim(const Register& count,
uint64_t unit_size = kXRegSize);
inline void Drop(uint64_t count, uint64_t unit_size = kXRegSize);
inline void Drop(int64_t count, uint64_t unit_size = kXRegSize);
inline void Drop(const Register& count,
uint64_t unit_size = kXRegSize);
......@@ -977,6 +977,10 @@ class MacroAssembler : public Assembler {
// Abort execution if argument is not a string, enabled via --debug-code.
void AssertString(Register object);
// Abort execution if argument is not a positive or zero integer, enabled via
// --debug-code.
void AssertPositiveOrZero(Register value);
void JumpIfHeapNumber(Register object, Label* on_heap_number,
SmiCheckType smi_check_type = DONT_DO_SMI_CHECK);
void JumpIfNotHeapNumber(Register object, Label* on_not_heap_number,
......
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