Merge Label and NearLabel

by adding NearLabel's functionality to Label and introducing a "near" parameter to jump instructions.

TEST=compiles; existing tests still pass.

Review URL: http://codereview.chromium.org/6928060

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7832 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 5d8cd989
......@@ -78,18 +78,28 @@ class DoubleConstant: public AllStatic {
class Label BASE_EMBEDDED {
public:
INLINE(Label()) { Unuse(); }
enum Distance {
kNear, kFar
};
INLINE(Label()) {
Unuse();
UnuseNear();
}
INLINE(~Label()) { ASSERT(!is_linked()); }
INLINE(void Unuse()) { pos_ = 0; }
INLINE(void UnuseNear()) { near_link_pos_ = 0; }
INLINE(bool is_bound() const) { return pos_ < 0; }
INLINE(bool is_unused() const) { return pos_ == 0; }
INLINE(bool is_unused() const) { return pos_ == 0 && near_link_pos_ == 0; }
INLINE(bool is_linked() const) { return pos_ > 0; }
INLINE(bool is_near_linked() const) { return near_link_pos_ > 0; }
// Returns the position of bound or linked labels. Cannot be used
// for unused labels.
int pos() const;
int near_link_pos() const { return near_link_pos_ - 1; }
private:
// pos_ encodes both the binding state (via its sign)
......@@ -100,13 +110,21 @@ class Label BASE_EMBEDDED {
// pos_ > 0 linked label, pos() returns the last reference position
int pos_;
// Behaves like |pos_| in the "> 0" case, but for near jumps to this label.
int near_link_pos_;
void bind_to(int pos) {
pos_ = -pos - 1;
ASSERT(is_bound());
}
void link_to(int pos) {
pos_ = pos + 1;
ASSERT(is_linked());
void link_to(int pos, Distance distance = kFar) {
if (distance == kNear) {
near_link_pos_ = pos + 1;
ASSERT(is_near_linked());
} else {
pos_ = pos + 1;
ASSERT(is_linked());
}
}
friend class Assembler;
......
......@@ -380,6 +380,18 @@ void Assembler::emit_disp(Label* L, Displacement::Type type) {
}
void Assembler::emit_near_disp(Label* L) {
byte disp = 0x00;
if (L->is_near_linked()) {
int offset = L->near_link_pos() - pc_offset();
ASSERT(is_int8(offset));
disp = static_cast<byte>(offset & 0xFF);
}
L->link_to(pc_offset(), Label::kNear);
*pc_++ = disp;
}
void Operand::set_modrm(int mod, Register rm) {
ASSERT((mod & -4) == 0);
buf_[0] = mod << 6 | rm.code();
......
......@@ -1525,6 +1525,21 @@ void Assembler::bind_to(Label* L, int pos) {
}
disp.next(L);
}
while (L->is_near_linked()) {
int fixup_pos = L->near_link_pos();
int offset_to_next =
static_cast<int>(*reinterpret_cast<int8_t*>(addr_at(fixup_pos)));
ASSERT(offset_to_next <= 0);
// Relative address, relative to point after address.
int disp = pos - fixup_pos - sizeof(int8_t);
ASSERT(0 <= disp && disp <= 127);
set_byte_at(fixup_pos, disp);
if (offset_to_next < 0) {
L->link_to(fixup_pos + offset_to_next, Label::kNear);
} else {
L->UnuseNear();
}
}
L->bind_to(pos);
}
......@@ -1613,7 +1628,7 @@ void Assembler::call(Handle<Code> code,
}
void Assembler::jmp(Label* L) {
void Assembler::jmp(Label* L, Label::Distance distance) {
EnsureSpace ensure_space(this);
last_pc_ = pc_;
if (L->is_bound()) {
......@@ -1630,6 +1645,9 @@ void Assembler::jmp(Label* L) {
EMIT(0xE9);
emit(offs - long_size);
}
} else if (distance == Label::kNear) {
EMIT(0xEB);
emit_near_disp(L);
} else {
// 1110 1001 #32-bit disp.
EMIT(0xE9);
......@@ -1683,7 +1701,7 @@ void Assembler::jmp(NearLabel* L) {
}
void Assembler::j(Condition cc, Label* L, Hint hint) {
void Assembler::j(Condition cc, Label* L, Hint hint, Label::Distance distance) {
EnsureSpace ensure_space(this);
last_pc_ = pc_;
ASSERT(0 <= cc && cc < 16);
......@@ -1703,6 +1721,9 @@ void Assembler::j(Condition cc, Label* L, Hint hint) {
EMIT(0x80 | cc);
emit(offs - long_size);
}
} else if (distance == Label::kNear) {
EMIT(0x70 | cc);
emit_near_disp(L);
} else {
// 0000 1111 1000 tttn #32-bit disp
// Note: could eliminate cond. jumps to this jump if condition
......
......@@ -842,6 +842,7 @@ class Assembler : public AssemblerBase {
// but it may be bound only once.
void bind(Label* L); // binds an unbound label L to the current code position
// DEPRECATED. Use bind(Label*) with jmp(Label*, Label::kNear) instead.
void bind(NearLabel* L);
// Calls
......@@ -855,20 +856,29 @@ class Assembler : public AssemblerBase {
unsigned ast_id = kNoASTId);
// Jumps
void jmp(Label* L); // unconditional jump to L
// unconditional jump to L
void jmp(Label* L, Label::Distance distance = Label::kFar);
void jmp(byte* entry, RelocInfo::Mode rmode);
void jmp(const Operand& adr);
void jmp(Handle<Code> code, RelocInfo::Mode rmode);
// Short jump
// DEPRECATED. Use jmp(Label*, Label::kNear) instead.
void jmp(NearLabel* L);
// Conditional jumps
void j(Condition cc, Label* L, Hint hint = no_hint);
void j(Condition cc,
Label* L,
Hint hint,
Label::Distance distance = Label::kFar);
void j(Condition cc, Label* L, Label::Distance distance = Label::kFar) {
j(cc, L, no_hint, distance);
}
void j(Condition cc, byte* entry, RelocInfo::Mode rmode, Hint hint = no_hint);
void j(Condition cc, Handle<Code> code, Hint hint = no_hint);
// Conditional short jump
// DEPRECATED. Use j(Condition, Label*, Label::kNear) instead.
void j(Condition cc, NearLabel* L, Hint hint = no_hint);
// Floating-point operations
......@@ -1105,6 +1115,7 @@ class Assembler : public AssemblerBase {
inline Displacement disp_at(Label* L);
inline void disp_at_put(Label* L, Displacement disp);
inline void emit_disp(Label* L, Displacement::Type type);
inline void emit_near_disp(Label* L);
// record reloc info for current pc_
void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0);
......
......@@ -520,15 +520,15 @@ static void Generate_NotifyDeoptimizedHelper(MacroAssembler* masm,
__ SmiUntag(ecx);
// Switch on the state.
NearLabel not_no_registers, not_tos_eax;
Label not_no_registers, not_tos_eax;
__ cmp(ecx, FullCodeGenerator::NO_REGISTERS);
__ j(not_equal, &not_no_registers);
__ j(not_equal, &not_no_registers, Label::kNear);
__ ret(1 * kPointerSize); // Remove state.
__ bind(&not_no_registers);
__ mov(eax, Operand(esp, 2 * kPointerSize));
__ cmp(ecx, FullCodeGenerator::TOS_REG);
__ j(not_equal, &not_tos_eax);
__ j(not_equal, &not_tos_eax, Label::kNear);
__ ret(2 * kPointerSize); // Remove state, eax.
__ bind(&not_tos_eax);
......@@ -1577,19 +1577,19 @@ void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) {
// If the result was -1 it means that we couldn't optimize the
// function. Just return and continue in the unoptimized version.
NearLabel skip;
Label skip;
__ cmp(Operand(eax), Immediate(Smi::FromInt(-1)));
__ j(not_equal, &skip);
__ j(not_equal, &skip, Label::kNear);
__ ret(0);
// If we decide not to perform on-stack replacement we perform a
// stack guard check to enable interrupts.
__ bind(&stack_check);
NearLabel ok;
Label ok;
ExternalReference stack_limit =
ExternalReference::address_of_stack_limit(masm->isolate());
__ cmp(esp, Operand::StaticVariable(stack_limit));
__ j(above_equal, &ok, taken);
__ j(above_equal, &ok, taken, Label::kNear);
StackCheckStub stub;
__ TailCallStub(&stub);
__ Abort("Unreachable code: returned from tail call.");
......
This diff is collapsed.
This diff is collapsed.
......@@ -97,7 +97,6 @@ static void GenerateStringDictionaryReceiverCheck(MacroAssembler* masm,
}
// Helper function used to load a property from a dictionary backing
// storage. This function may fail to load a property even though it is
// in the dictionary, so code at miss_label must always call a backup
......@@ -749,7 +748,8 @@ void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm,
// ecx: key, a smi.
// edi: receiver->elements, a FixedArray
// flags: compare (ecx, edx.length())
__ j(not_equal, &slow, not_taken); // do not leave holes in the array
// do not leave holes in the array:
__ j(not_equal, &slow, not_taken);
__ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset));
__ j(above_equal, &slow, not_taken);
// Add 1 to receiver->length, and go to fast array write.
......@@ -942,13 +942,13 @@ static void GenerateCallMiss(MacroAssembler* masm,
Label invoke, global;
__ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); // receiver
__ test(edx, Immediate(kSmiTagMask));
__ j(zero, &invoke, not_taken);
__ j(zero, &invoke, not_taken, Label::kNear);
__ mov(ebx, FieldOperand(edx, HeapObject::kMapOffset));
__ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset));
__ cmp(ebx, JS_GLOBAL_OBJECT_TYPE);
__ j(equal, &global);
__ j(equal, &global, Label::kNear);
__ cmp(ebx, JS_BUILTINS_OBJECT_TYPE);
__ j(not_equal, &invoke);
__ j(not_equal, &invoke, Label::kNear);
// Patch the receiver on the stack.
__ bind(&global);
......
This diff is collapsed.
......@@ -484,9 +484,9 @@ void MacroAssembler::Throw(Register value) {
// not NULL. The frame pointer is NULL in the exception handler of
// a JS entry frame.
Set(esi, Immediate(0)); // Tentatively set context pointer to NULL.
NearLabel skip;
Label skip;
cmp(ebp, 0);
j(equal, &skip, not_taken);
j(equal, &skip, not_taken, Label::kNear);
mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
bind(&skip);
......@@ -511,12 +511,12 @@ void MacroAssembler::ThrowUncatchable(UncatchableExceptionType type,
mov(esp, Operand::StaticVariable(handler_address));
// Unwind the handlers until the ENTRY handler is found.
NearLabel loop, done;
Label loop, done;
bind(&loop);
// Load the type of the current stack handler.
const int kStateOffset = StackHandlerConstants::kStateOffset;
cmp(Operand(esp, kStateOffset), Immediate(StackHandler::ENTRY));
j(equal, &done);
j(equal, &done, Label::kNear);
// Fetch the next handler in the list.
const int kNextOffset = StackHandlerConstants::kNextOffset;
mov(esp, Operand(esp, kNextOffset));
......
......@@ -971,9 +971,9 @@ void RegExpMacroAssemblerIA32::ReadStackPointerFromRegister(int reg) {
}
void RegExpMacroAssemblerIA32::SetCurrentPositionFromEnd(int by) {
NearLabel after_position;
Label after_position;
__ cmp(edi, -by * char_size());
__ j(greater_equal, &after_position);
__ j(greater_equal, &after_position, Label::kNear);
__ mov(edi, -by * char_size());
// On RegExp code entry (where this operation is used), the character before
// the current position is expected to be already loaded.
......
......@@ -3511,9 +3511,9 @@ MaybeObject* ExternalArrayStubCompiler::CompileKeyedStoreStub(
switch (array_type) {
case kExternalPixelArray:
{ // Clamp the value to [0..255].
NearLabel done;
Label done;
__ test(ecx, Immediate(0xFFFFFF00));
__ j(zero, &done);
__ j(zero, &done, Label::kNear);
__ setcc(negative, ecx); // 1 if negative, 0 if positive.
__ dec_b(ecx); // 0 if negative, 255 if positive.
__ bind(&done);
......@@ -3594,9 +3594,9 @@ MaybeObject* ExternalArrayStubCompiler::CompileKeyedStoreStub(
switch (array_type) {
case kExternalPixelArray:
{ // Clamp the value to [0..255].
NearLabel done;
Label done;
__ test(ecx, Immediate(0xFFFFFF00));
__ j(zero, &done);
__ j(zero, &done, Label::kNear);
__ setcc(negative, ecx); // 1 if negative, 0 if positive.
__ dec_b(ecx); // 0 if negative, 255 if positive.
__ bind(&done);
......
......@@ -458,6 +458,20 @@ void Assembler::bind_to(Label* L, int pos) {
int last_imm32 = pos - (current + sizeof(int32_t));
long_at_put(current, last_imm32);
}
while (L->is_near_linked()) {
int fixup_pos = L->near_link_pos();
int offset_to_next =
static_cast<int>(*reinterpret_cast<int8_t*>(addr_at(fixup_pos)));
ASSERT(offset_to_next <= 0);
int disp = pos - (fixup_pos + sizeof(int8_t));
ASSERT(is_int8(disp));
set_byte_at(fixup_pos, disp);
if (offset_to_next < 0) {
L->link_to(fixup_pos + offset_to_next, Label::kNear);
} else {
L->UnuseNear();
}
}
L->bind_to(pos);
}
......@@ -1214,7 +1228,7 @@ void Assembler::int3() {
}
void Assembler::j(Condition cc, Label* L) {
void Assembler::j(Condition cc, Label* L, Hint hint, Label::Distance distance) {
if (cc == always) {
jmp(L);
return;
......@@ -1223,6 +1237,7 @@ void Assembler::j(Condition cc, Label* L) {
}
EnsureSpace ensure_space(this);
ASSERT(is_uint4(cc));
if (FLAG_emit_branch_hints && hint != no_hint) emit(hint);
if (L->is_bound()) {
const int short_size = 2;
const int long_size = 6;
......@@ -1238,6 +1253,17 @@ void Assembler::j(Condition cc, Label* L) {
emit(0x80 | cc);
emitl(offs - long_size);
}
} else if (distance == Label::kNear) {
// 0111 tttn #8-bit disp
emit(0x70 | cc);
byte disp = 0x00;
if (L->is_near_linked()) {
int offset = L->near_link_pos() - pc_offset();
ASSERT(is_int8(offset));
disp = static_cast<byte>(offset & 0xFF);
}
L->link_to(pc_offset(), Label::kNear);
emit(disp);
} else if (L->is_linked()) {
// 0000 1111 1000 tttn #32-bit disp.
emit(0x0F);
......@@ -1287,7 +1313,7 @@ void Assembler::j(Condition cc, NearLabel* L, Hint hint) {
}
void Assembler::jmp(Label* L) {
void Assembler::jmp(Label* L, Label::Distance distance) {
EnsureSpace ensure_space(this);
const int short_size = sizeof(int8_t);
const int long_size = sizeof(int32_t);
......@@ -1303,7 +1329,17 @@ void Assembler::jmp(Label* L) {
emit(0xE9);
emitl(offs - long_size);
}
} else if (L->is_linked()) {
} else if (distance == Label::kNear) {
emit(0xEB);
byte disp = 0x00;
if (L->is_near_linked()) {
int offset = L->near_link_pos() - pc_offset();
ASSERT(is_int8(offset));
disp = static_cast<byte>(offset & 0xFF);
}
L->link_to(pc_offset(), Label::kNear);
emit(disp);
} else if (L->is_linked()) {
// 1110 1001 #32-bit disp.
emit(0xE9);
emitl(L->pos());
......
......@@ -1178,6 +1178,7 @@ class Assembler : public AssemblerBase {
// but it may be bound only once.
void bind(Label* L); // binds an unbound label L to the current code position
// DEPRECATED. Use bind(Label*) with jmp(Label*, Label::kNear) instead.
void bind(NearLabel* L);
// Calls
......@@ -1202,7 +1203,8 @@ class Assembler : public AssemblerBase {
// Jumps
// Jump short or near relative.
// Use a 32-bit signed displacement.
void jmp(Label* L); // unconditional jump to L
// Unconditional jump to L
void jmp(Label* L, Label::Distance distance = Label::kFar);
void jmp(Handle<Code> target, RelocInfo::Mode rmode);
// Jump near absolute indirect (r64)
......@@ -1212,13 +1214,21 @@ class Assembler : public AssemblerBase {
void jmp(const Operand& src);
// Short jump
// DEPRECATED. Use jmp(L, Label::kNear) instead.
void jmp(NearLabel* L);
// Conditional jumps
void j(Condition cc, Label* L);
void j(Condition cc,
Label* L,
Hint hint,
Label::Distance distance = Label::kFar);
void j(Condition cc, Label* L, Label::Distance distance = Label::kFar) {
j(cc, L, no_hint, distance);
}
void j(Condition cc, Handle<Code> target, RelocInfo::Mode rmode);
// Conditional short jump
// DEPRECATED. Use jmp(L, Label::kNear) instead.
void j(Condition cc, NearLabel* L, Hint hint = no_hint);
// Floating-point operations
......
......@@ -576,15 +576,15 @@ static void Generate_NotifyDeoptimizedHelper(MacroAssembler* masm,
__ SmiToInteger32(rcx, Operand(rsp, 1 * kPointerSize));
// Switch on the state.
NearLabel not_no_registers, not_tos_rax;
Label not_no_registers, not_tos_rax;
__ cmpq(rcx, Immediate(FullCodeGenerator::NO_REGISTERS));
__ j(not_equal, &not_no_registers);
__ j(not_equal, &not_no_registers, Label::kNear);
__ ret(1 * kPointerSize); // Remove state.
__ bind(&not_no_registers);
__ movq(rax, Operand(rsp, 2 * kPointerSize));
__ cmpq(rcx, Immediate(FullCodeGenerator::TOS_REG));
__ j(not_equal, &not_tos_rax);
__ j(not_equal, &not_tos_rax, Label::kNear);
__ ret(2 * kPointerSize); // Remove state, rax.
__ bind(&not_tos_rax);
......@@ -1474,17 +1474,17 @@ void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) {
// If the result was -1 it means that we couldn't optimize the
// function. Just return and continue in the unoptimized version.
NearLabel skip;
Label skip;
__ SmiCompare(rax, Smi::FromInt(-1));
__ j(not_equal, &skip);
__ j(not_equal, &skip, Label::kNear);
__ ret(0);
// If we decide not to perform on-stack replacement we perform a
// stack guard check to enable interrupts.
__ bind(&stack_check);
NearLabel ok;
Label ok;
__ CompareRoot(rsp, Heap::kStackLimitRootIndex);
__ j(above_equal, &ok);
__ j(above_equal, &ok, Label::kNear);
StackCheckStub stub;
__ TailCallStub(&stub);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -344,13 +344,13 @@ void MacroAssembler::Assert(Condition cc, const char* msg) {
void MacroAssembler::AssertFastElements(Register elements) {
if (emit_debug_code()) {
NearLabel ok;
Label ok;
CompareRoot(FieldOperand(elements, HeapObject::kMapOffset),
Heap::kFixedArrayMapRootIndex);
j(equal, &ok);
j(equal, &ok, Label::kNear);
CompareRoot(FieldOperand(elements, HeapObject::kMapOffset),
Heap::kFixedCOWArrayMapRootIndex);
j(equal, &ok);
j(equal, &ok, Label::kNear);
Abort("JSObject with fast elements map has slow elements");
bind(&ok);
}
......@@ -358,8 +358,8 @@ void MacroAssembler::AssertFastElements(Register elements) {
void MacroAssembler::Check(Condition cc, const char* msg) {
NearLabel L;
j(cc, &L);
Label L;
j(cc, &L, Label::kNear);
Abort(msg);
// will not return here
bind(&L);
......@@ -371,9 +371,9 @@ void MacroAssembler::CheckStackAlignment() {
int frame_alignment_mask = frame_alignment - 1;
if (frame_alignment > kPointerSize) {
ASSERT(IsPowerOf2(frame_alignment));
NearLabel alignment_as_expected;
Label alignment_as_expected;
testq(rsp, Immediate(frame_alignment_mask));
j(zero, &alignment_as_expected);
j(zero, &alignment_as_expected, Label::kNear);
// Abort if stack is not aligned.
int3();
bind(&alignment_as_expected);
......@@ -384,9 +384,9 @@ void MacroAssembler::CheckStackAlignment() {
void MacroAssembler::NegativeZeroTest(Register result,
Register op,
Label* then_label) {
NearLabel ok;
Label ok;
testl(result, result);
j(not_zero, &ok);
j(not_zero, &ok, Label::kNear);
testl(op, op);
j(sign, then_label);
bind(&ok);
......@@ -832,8 +832,8 @@ void MacroAssembler::LoadSmiConstant(Register dst, Smi* source) {
if (allow_stub_calls()) {
Assert(equal, "Uninitialized kSmiConstantRegister");
} else {
NearLabel ok;
j(equal, &ok);
Label ok;
j(equal, &ok, Label::kNear);
int3();
bind(&ok);
}
......@@ -895,8 +895,8 @@ void MacroAssembler::Integer32ToSmi(Register dst, Register src) {
void MacroAssembler::Integer32ToSmiField(const Operand& dst, Register src) {
if (emit_debug_code()) {
testb(dst, Immediate(0x01));
NearLabel ok;
j(zero, &ok);
Label ok;
j(zero, &ok, Label::kNear);
if (allow_stub_calls()) {
Abort("Integer32ToSmiField writing to non-smi location");
} else {
......@@ -1397,7 +1397,6 @@ void MacroAssembler::SmiShiftLeft(Register dst,
Register src1,
Register src2) {
ASSERT(!dst.is(rcx));
NearLabel result_ok;
// Untag shift amount.
if (!dst.is(src1)) {
movq(dst, src1);
......@@ -1782,9 +1781,9 @@ void MacroAssembler::Throw(Register value) {
// Before returning we restore the context from the frame pointer if not NULL.
// The frame pointer is NULL in the exception handler of a JS entry frame.
Set(rsi, 0); // Tentatively set context pointer to NULL
NearLabel skip;
Label skip;
cmpq(rbp, Immediate(0));
j(equal, &skip);
j(equal, &skip, Label::kNear);
movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
bind(&skip);
ret(0);
......@@ -1802,12 +1801,12 @@ void MacroAssembler::ThrowUncatchable(UncatchableExceptionType type,
Load(rsp, handler_address);
// Unwind the handlers until the ENTRY handler is found.
NearLabel loop, done;
Label loop, done;
bind(&loop);
// Load the type of the current stack handler.
const int kStateOffset = StackHandlerConstants::kStateOffset;
cmpq(Operand(rsp, kStateOffset), Immediate(StackHandler::ENTRY));
j(equal, &done);
j(equal, &done, Label::kNear);
// Fetch the next handler in the list.
const int kNextOffset = StackHandlerConstants::kNextOffset;
movq(rsp, Operand(rsp, kNextOffset));
......@@ -1899,9 +1898,9 @@ void MacroAssembler::CheckMap(Register obj,
void MacroAssembler::AbortIfNotNumber(Register object) {
NearLabel ok;
Label ok;
Condition is_smi = CheckSmi(object);
j(is_smi, &ok);
j(is_smi, &ok, Label::kNear);
Cmp(FieldOperand(object, HeapObject::kMapOffset),
isolate()->factory()->heap_number_map());
Assert(equal, "Operand not a number");
......@@ -1910,7 +1909,6 @@ void MacroAssembler::AbortIfNotNumber(Register object) {
void MacroAssembler::AbortIfSmi(Register object) {
NearLabel ok;
Condition is_smi = CheckSmi(object);
Assert(NegateCondition(is_smi), "Operand is a smi");
}
......@@ -1973,10 +1971,10 @@ void MacroAssembler::TryGetFunctionPrototype(Register function,
j(not_equal, miss);
// Make sure that the function has an instance prototype.
NearLabel non_instance;
Label non_instance;
testb(FieldOperand(result, Map::kBitFieldOffset),
Immediate(1 << Map::kHasNonInstancePrototype));
j(not_zero, &non_instance);
j(not_zero, &non_instance, Label::kNear);
// Get the prototype or initial map from the function.
movq(result,
......@@ -1989,13 +1987,13 @@ void MacroAssembler::TryGetFunctionPrototype(Register function,
j(equal, miss);
// If the function does not have an initial map, we're done.
NearLabel done;
Label done;
CmpObjectType(result, MAP_TYPE, kScratchRegister);
j(not_equal, &done);
j(not_equal, &done, Label::kNear);
// Get the prototype from the initial map.
movq(result, FieldOperand(result, Map::kPrototypeOffset));
jmp(&done);
jmp(&done, Label::kNear);
// Non-instance prototype: Fetch prototype from constructor field
// in initial map.
......
......@@ -1369,21 +1369,22 @@ void MacroAssembler::SmiMul(Register dst,
ASSERT(!src2.is(kScratchRegister));
if (dst.is(src1)) {
NearLabel failure, zero_correct_result;
Label failure, zero_correct_result;
movq(kScratchRegister, src1); // Create backup for later testing.
SmiToInteger64(dst, src1);
imul(dst, src2);
j(overflow, &failure);
j(overflow, &failure, Label::kNear);
// Check for negative zero result. If product is zero, and one
// argument is negative, go to slow case.
NearLabel correct_result;
Label correct_result;
testq(dst, dst);
j(not_zero, &correct_result);
j(not_zero, &correct_result, Label::kNear);
movq(dst, kScratchRegister);
xor_(dst, src2);
j(positive, &zero_correct_result); // Result was positive zero.
// Result was positive zero.
j(positive, &zero_correct_result, Label::kNear);
bind(&failure); // Reused failure exit, restores src1.
movq(src1, kScratchRegister);
......@@ -1399,9 +1400,9 @@ void MacroAssembler::SmiMul(Register dst,
j(overflow, on_not_smi_result);
// Check for negative zero result. If product is zero, and one
// argument is negative, go to slow case.
NearLabel correct_result;
Label correct_result;
testq(dst, dst);
j(not_zero, &correct_result);
j(not_zero, &correct_result, Label::kNear);
// One of src1 and src2 is zero, the check whether the other is
// negative.
movq(kScratchRegister, src1);
......@@ -1516,7 +1517,6 @@ void MacroAssembler::SmiDiv(Register dst,
ASSERT(!src1.is(rdx));
// Check for 0 divisor (result is +/-Infinity).
NearLabel positive_divisor;
testq(src2, src2);
j(zero, on_not_smi_result);
......@@ -1531,12 +1531,12 @@ void MacroAssembler::SmiDiv(Register dst,
// We overshoot a little and go to slow case if we divide min-value
// by any negative value, not just -1.
NearLabel safe_div;
Label safe_div;
testl(rax, Immediate(0x7fffffff));
j(not_zero, &safe_div);
j(not_zero, &safe_div, Label::kNear);
testq(src2, src2);
if (src1.is(rax)) {
j(positive, &safe_div);
j(positive, &safe_div, Label::kNear);
movq(src1, kScratchRegister);
jmp(on_not_smi_result);
} else {
......@@ -1552,8 +1552,8 @@ void MacroAssembler::SmiDiv(Register dst,
// Check that the remainder is zero.
testl(rdx, rdx);
if (src1.is(rax)) {
NearLabel smi_result;
j(zero, &smi_result);
Label smi_result;
j(zero, &smi_result, Label::kNear);
movq(src1, kScratchRegister);
jmp(on_not_smi_result);
bind(&smi_result);
......@@ -1590,11 +1590,11 @@ void MacroAssembler::SmiMod(Register dst,
SmiToInteger32(src2, src2);
// Test for the edge case of dividing Smi::kMinValue by -1 (will overflow).
NearLabel safe_div;
Label safe_div;
cmpl(rax, Immediate(Smi::kMinValue));
j(not_equal, &safe_div);
j(not_equal, &safe_div, Label::kNear);
cmpl(src2, Immediate(-1));
j(not_equal, &safe_div);
j(not_equal, &safe_div, Label::kNear);
// Retag inputs and go slow case.
Integer32ToSmi(src2, src2);
if (src1.is(rax)) {
......@@ -1613,9 +1613,9 @@ void MacroAssembler::SmiMod(Register dst,
}
// Check for a negative zero result. If the result is zero, and the
// dividend is negative, go slow to return a floating point negative zero.
NearLabel smi_result;
Label smi_result;
testl(rdx, rdx);
j(not_zero, &smi_result);
j(not_zero, &smi_result, Label::kNear);
testq(src1, src1);
j(negative, on_not_smi_result);
bind(&smi_result);
......@@ -1652,7 +1652,6 @@ void MacroAssembler::SmiShiftLogicalRight(Register dst,
ASSERT(!dst.is(rcx));
// dst and src1 can be the same, because the one case that bails out
// is a shift by 0, which leaves dst, and therefore src1, unchanged.
NearLabel result_ok;
if (src1.is(rcx) || src2.is(rcx)) {
movq(kScratchRegister, rcx);
}
......@@ -1665,8 +1664,8 @@ void MacroAssembler::SmiShiftLogicalRight(Register dst,
shl(dst, Immediate(kSmiShift));
testq(dst, dst);
if (src1.is(rcx) || src2.is(rcx)) {
NearLabel positive_result;
j(positive, &positive_result);
Label positive_result;
j(positive, &positive_result, Label::kNear);
if (src1.is(rcx)) {
movq(src1, kScratchRegister);
} else {
......@@ -1938,7 +1937,7 @@ void MacroAssembler::InvokePrologue(const ParameterCount& expected,
InvokeFlag flag,
const CallWrapper& call_wrapper) {
bool definitely_matches = false;
NearLabel invoke;
Label invoke;
if (expected.is_immediate()) {
ASSERT(actual.is_immediate());
if (expected.immediate() == actual.immediate()) {
......@@ -1962,14 +1961,14 @@ void MacroAssembler::InvokePrologue(const ParameterCount& expected,
// case when we invoke function values without going through the
// IC mechanism.
cmpq(expected.reg(), Immediate(actual.immediate()));
j(equal, &invoke);
j(equal, &invoke, Label::kNear);
ASSERT(expected.reg().is(rbx));
Set(rax, actual.immediate());
} else if (!expected.reg().is(actual.reg())) {
// Both expected and actual are in (different) registers. This
// is the case when we invoke functions using call and apply.
cmpq(expected.reg(), actual.reg());
j(equal, &invoke);
j(equal, &invoke, Label::kNear);
ASSERT(actual.reg().is(rax));
ASSERT(expected.reg().is(rbx));
}
......
......@@ -1065,9 +1065,9 @@ void RegExpMacroAssemblerX64::ReadStackPointerFromRegister(int reg) {
void RegExpMacroAssemblerX64::SetCurrentPositionFromEnd(int by) {
NearLabel after_position;
Label after_position;
__ cmpq(rdi, Immediate(-by * char_size()));
__ j(greater_equal, &after_position);
__ j(greater_equal, &after_position, Label::kNear);
__ movq(rdi, Immediate(-by * char_size()));
// On RegExp code entry (where this operation is used), the character before
// the current position is expected to be already loaded.
......
......@@ -3300,9 +3300,9 @@ MaybeObject* ExternalArrayStubCompiler::CompileKeyedStoreStub(
switch (array_type) {
case kExternalPixelArray:
{ // Clamp the value to [0..255].
NearLabel done;
Label done;
__ testl(rdx, Immediate(0xFFFFFF00));
__ j(zero, &done);
__ j(zero, &done, Label::kNear);
__ setcc(negative, rdx); // 1 if negative, 0 if positive.
__ decb(rdx); // 0 if negative, 255 if positive.
__ bind(&done);
......
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