| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "debug.h" | 36 #include "debug.h" |
| 37 #include "runtime.h" | 37 #include "runtime.h" |
| 38 | 38 |
| 39 namespace v8 { | 39 namespace v8 { |
| 40 namespace internal { | 40 namespace internal { |
| 41 | 41 |
| 42 MacroAssembler::MacroAssembler(void* buffer, int size) | 42 MacroAssembler::MacroAssembler(void* buffer, int size) |
| 43 : Assembler(buffer, size), | 43 : Assembler(buffer, size), |
| 44 generating_stub_(false), | 44 generating_stub_(false), |
| 45 allow_stub_calls_(true), | 45 allow_stub_calls_(true), |
| 46 code_object_(Heap::undefined_value()) { | 46 code_object_(HEAP->undefined_value()) { |
| 47 } | 47 } |
| 48 | 48 |
| 49 | 49 |
| 50 // We always generate arm code, never thumb code, even if V8 is compiled to | 50 // We always generate arm code, never thumb code, even if V8 is compiled to |
| 51 // thumb, so we require inter-working support | 51 // thumb, so we require inter-working support |
| 52 #if defined(__thumb__) && !defined(USE_THUMB_INTERWORK) | 52 #if defined(__thumb__) && !defined(USE_THUMB_INTERWORK) |
| 53 #error "flag -mthumb-interwork missing" | 53 #error "flag -mthumb-interwork missing" |
| 54 #endif | 54 #endif |
| 55 | 55 |
| 56 | 56 |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 | 285 |
| 286 void MacroAssembler::And(Register dst, Register src1, const Operand& src2, | 286 void MacroAssembler::And(Register dst, Register src1, const Operand& src2, |
| 287 Condition cond) { | 287 Condition cond) { |
| 288 if (!src2.is_reg() && | 288 if (!src2.is_reg() && |
| 289 !src2.must_use_constant_pool() && | 289 !src2.must_use_constant_pool() && |
| 290 src2.immediate() == 0) { | 290 src2.immediate() == 0) { |
| 291 mov(dst, Operand(0, RelocInfo::NONE), LeaveCC, cond); | 291 mov(dst, Operand(0, RelocInfo::NONE), LeaveCC, cond); |
| 292 | 292 |
| 293 } else if (!src2.is_single_instruction() && | 293 } else if (!src2.is_single_instruction() && |
| 294 !src2.must_use_constant_pool() && | 294 !src2.must_use_constant_pool() && |
| 295 CpuFeatures::IsSupported(ARMv7) && | 295 Isolate::Current()->cpu_features()->IsSupported(ARMv7) && |
| 296 IsPowerOf2(src2.immediate() + 1)) { | 296 IsPowerOf2(src2.immediate() + 1)) { |
| 297 ubfx(dst, src1, 0, WhichPowerOf2(src2.immediate() + 1), cond); | 297 ubfx(dst, src1, 0, WhichPowerOf2(src2.immediate() + 1), cond); |
| 298 | 298 |
| 299 } else { | 299 } else { |
| 300 and_(dst, src1, src2, LeaveCC, cond); | 300 and_(dst, src1, src2, LeaveCC, cond); |
| 301 } | 301 } |
| 302 } | 302 } |
| 303 | 303 |
| 304 | 304 |
| 305 void MacroAssembler::Ubfx(Register dst, Register src1, int lsb, int width, | 305 void MacroAssembler::Ubfx(Register dst, Register src1, int lsb, int width, |
| 306 Condition cond) { | 306 Condition cond) { |
| 307 ASSERT(lsb < 32); | 307 ASSERT(lsb < 32); |
| 308 if (!CpuFeatures::IsSupported(ARMv7)) { | 308 if (!Isolate::Current()->cpu_features()->IsSupported(ARMv7)) { |
| 309 int mask = (1 << (width + lsb)) - 1 - ((1 << lsb) - 1); | 309 int mask = (1 << (width + lsb)) - 1 - ((1 << lsb) - 1); |
| 310 and_(dst, src1, Operand(mask), LeaveCC, cond); | 310 and_(dst, src1, Operand(mask), LeaveCC, cond); |
| 311 if (lsb != 0) { | 311 if (lsb != 0) { |
| 312 mov(dst, Operand(dst, LSR, lsb), LeaveCC, cond); | 312 mov(dst, Operand(dst, LSR, lsb), LeaveCC, cond); |
| 313 } | 313 } |
| 314 } else { | 314 } else { |
| 315 ubfx(dst, src1, lsb, width, cond); | 315 ubfx(dst, src1, lsb, width, cond); |
| 316 } | 316 } |
| 317 } | 317 } |
| 318 | 318 |
| 319 | 319 |
| 320 void MacroAssembler::Sbfx(Register dst, Register src1, int lsb, int width, | 320 void MacroAssembler::Sbfx(Register dst, Register src1, int lsb, int width, |
| 321 Condition cond) { | 321 Condition cond) { |
| 322 ASSERT(lsb < 32); | 322 ASSERT(lsb < 32); |
| 323 if (!CpuFeatures::IsSupported(ARMv7)) { | 323 if (!Isolate::Current()->cpu_features()->IsSupported(ARMv7)) { |
| 324 int mask = (1 << (width + lsb)) - 1 - ((1 << lsb) - 1); | 324 int mask = (1 << (width + lsb)) - 1 - ((1 << lsb) - 1); |
| 325 and_(dst, src1, Operand(mask), LeaveCC, cond); | 325 and_(dst, src1, Operand(mask), LeaveCC, cond); |
| 326 int shift_up = 32 - lsb - width; | 326 int shift_up = 32 - lsb - width; |
| 327 int shift_down = lsb + shift_up; | 327 int shift_down = lsb + shift_up; |
| 328 if (shift_up != 0) { | 328 if (shift_up != 0) { |
| 329 mov(dst, Operand(dst, LSL, shift_up), LeaveCC, cond); | 329 mov(dst, Operand(dst, LSL, shift_up), LeaveCC, cond); |
| 330 } | 330 } |
| 331 if (shift_down != 0) { | 331 if (shift_down != 0) { |
| 332 mov(dst, Operand(dst, ASR, shift_down), LeaveCC, cond); | 332 mov(dst, Operand(dst, ASR, shift_down), LeaveCC, cond); |
| 333 } | 333 } |
| 334 } else { | 334 } else { |
| 335 sbfx(dst, src1, lsb, width, cond); | 335 sbfx(dst, src1, lsb, width, cond); |
| 336 } | 336 } |
| 337 } | 337 } |
| 338 | 338 |
| 339 | 339 |
| 340 void MacroAssembler::Bfi(Register dst, | 340 void MacroAssembler::Bfi(Register dst, |
| 341 Register src, | 341 Register src, |
| 342 Register scratch, | 342 Register scratch, |
| 343 int lsb, | 343 int lsb, |
| 344 int width, | 344 int width, |
| 345 Condition cond) { | 345 Condition cond) { |
| 346 ASSERT(0 <= lsb && lsb < 32); | 346 ASSERT(0 <= lsb && lsb < 32); |
| 347 ASSERT(0 <= width && width < 32); | 347 ASSERT(0 <= width && width < 32); |
| 348 ASSERT(lsb + width < 32); | 348 ASSERT(lsb + width < 32); |
| 349 ASSERT(!scratch.is(dst)); | 349 ASSERT(!scratch.is(dst)); |
| 350 if (width == 0) return; | 350 if (width == 0) return; |
| 351 if (!CpuFeatures::IsSupported(ARMv7)) { | 351 if (!Isolate::Current()->cpu_features()->IsSupported(ARMv7)) { |
| 352 int mask = (1 << (width + lsb)) - 1 - ((1 << lsb) - 1); | 352 int mask = (1 << (width + lsb)) - 1 - ((1 << lsb) - 1); |
| 353 bic(dst, dst, Operand(mask)); | 353 bic(dst, dst, Operand(mask)); |
| 354 and_(scratch, src, Operand((1 << width) - 1)); | 354 and_(scratch, src, Operand((1 << width) - 1)); |
| 355 mov(scratch, Operand(scratch, LSL, lsb)); | 355 mov(scratch, Operand(scratch, LSL, lsb)); |
| 356 orr(dst, dst, scratch); | 356 orr(dst, dst, scratch); |
| 357 } else { | 357 } else { |
| 358 bfi(dst, src, lsb, width, cond); | 358 bfi(dst, src, lsb, width, cond); |
| 359 } | 359 } |
| 360 } | 360 } |
| 361 | 361 |
| 362 | 362 |
| 363 void MacroAssembler::Bfc(Register dst, int lsb, int width, Condition cond) { | 363 void MacroAssembler::Bfc(Register dst, int lsb, int width, Condition cond) { |
| 364 ASSERT(lsb < 32); | 364 ASSERT(lsb < 32); |
| 365 if (!CpuFeatures::IsSupported(ARMv7)) { | 365 if (!Isolate::Current()->cpu_features()->IsSupported(ARMv7)) { |
| 366 int mask = (1 << (width + lsb)) - 1 - ((1 << lsb) - 1); | 366 int mask = (1 << (width + lsb)) - 1 - ((1 << lsb) - 1); |
| 367 bic(dst, dst, Operand(mask)); | 367 bic(dst, dst, Operand(mask)); |
| 368 } else { | 368 } else { |
| 369 bfc(dst, lsb, width, cond); | 369 bfc(dst, lsb, width, cond); |
| 370 } | 370 } |
| 371 } | 371 } |
| 372 | 372 |
| 373 | 373 |
| 374 void MacroAssembler::Usat(Register dst, int satpos, const Operand& src, | 374 void MacroAssembler::Usat(Register dst, int satpos, const Operand& src, |
| 375 Condition cond) { | 375 Condition cond) { |
| 376 if (!CpuFeatures::IsSupported(ARMv7)) { | 376 if (!Isolate::Current()->cpu_features()->IsSupported(ARMv7)) { |
| 377 ASSERT(!dst.is(pc) && !src.rm().is(pc)); | 377 ASSERT(!dst.is(pc) && !src.rm().is(pc)); |
| 378 ASSERT((satpos >= 0) && (satpos <= 31)); | 378 ASSERT((satpos >= 0) && (satpos <= 31)); |
| 379 | 379 |
| 380 // These asserts are required to ensure compatibility with the ARMv7 | 380 // These asserts are required to ensure compatibility with the ARMv7 |
| 381 // implementation. | 381 // implementation. |
| 382 ASSERT((src.shift_op() == ASR) || (src.shift_op() == LSL)); | 382 ASSERT((src.shift_op() == ASR) || (src.shift_op() == LSL)); |
| 383 ASSERT(src.rs().is(no_reg)); | 383 ASSERT(src.rs().is(no_reg)); |
| 384 | 384 |
| 385 Label done; | 385 Label done; |
| 386 int satval = (1 << satpos) - 1; | 386 int satval = (1 << satpos) - 1; |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 | 613 |
| 614 | 614 |
| 615 void MacroAssembler::Ldrd(Register dst1, Register dst2, | 615 void MacroAssembler::Ldrd(Register dst1, Register dst2, |
| 616 const MemOperand& src, Condition cond) { | 616 const MemOperand& src, Condition cond) { |
| 617 ASSERT(src.rm().is(no_reg)); | 617 ASSERT(src.rm().is(no_reg)); |
| 618 ASSERT(!dst1.is(lr)); // r14. | 618 ASSERT(!dst1.is(lr)); // r14. |
| 619 ASSERT_EQ(0, dst1.code() % 2); | 619 ASSERT_EQ(0, dst1.code() % 2); |
| 620 ASSERT_EQ(dst1.code() + 1, dst2.code()); | 620 ASSERT_EQ(dst1.code() + 1, dst2.code()); |
| 621 | 621 |
| 622 // Generate two ldr instructions if ldrd is not available. | 622 // Generate two ldr instructions if ldrd is not available. |
| 623 if (CpuFeatures::IsSupported(ARMv7)) { | 623 if (Isolate::Current()->cpu_features()->IsSupported(ARMv7)) { |
| 624 CpuFeatures::Scope scope(ARMv7); | 624 CpuFeatures::Scope scope(ARMv7); |
| 625 ldrd(dst1, dst2, src, cond); | 625 ldrd(dst1, dst2, src, cond); |
| 626 } else { | 626 } else { |
| 627 MemOperand src2(src); | 627 MemOperand src2(src); |
| 628 src2.set_offset(src2.offset() + 4); | 628 src2.set_offset(src2.offset() + 4); |
| 629 if (dst1.is(src.rn())) { | 629 if (dst1.is(src.rn())) { |
| 630 ldr(dst2, src2, cond); | 630 ldr(dst2, src2, cond); |
| 631 ldr(dst1, src, cond); | 631 ldr(dst1, src, cond); |
| 632 } else { | 632 } else { |
| 633 ldr(dst1, src, cond); | 633 ldr(dst1, src, cond); |
| 634 ldr(dst2, src2, cond); | 634 ldr(dst2, src2, cond); |
| 635 } | 635 } |
| 636 } | 636 } |
| 637 } | 637 } |
| 638 | 638 |
| 639 | 639 |
| 640 void MacroAssembler::Strd(Register src1, Register src2, | 640 void MacroAssembler::Strd(Register src1, Register src2, |
| 641 const MemOperand& dst, Condition cond) { | 641 const MemOperand& dst, Condition cond) { |
| 642 ASSERT(dst.rm().is(no_reg)); | 642 ASSERT(dst.rm().is(no_reg)); |
| 643 ASSERT(!src1.is(lr)); // r14. | 643 ASSERT(!src1.is(lr)); // r14. |
| 644 ASSERT_EQ(0, src1.code() % 2); | 644 ASSERT_EQ(0, src1.code() % 2); |
| 645 ASSERT_EQ(src1.code() + 1, src2.code()); | 645 ASSERT_EQ(src1.code() + 1, src2.code()); |
| 646 | 646 |
| 647 // Generate two str instructions if strd is not available. | 647 // Generate two str instructions if strd is not available. |
| 648 if (CpuFeatures::IsSupported(ARMv7)) { | 648 if (Isolate::Current()->cpu_features()->IsSupported(ARMv7)) { |
| 649 CpuFeatures::Scope scope(ARMv7); | 649 CpuFeatures::Scope scope(ARMv7); |
| 650 strd(src1, src2, dst, cond); | 650 strd(src1, src2, dst, cond); |
| 651 } else { | 651 } else { |
| 652 MemOperand dst2(dst); | 652 MemOperand dst2(dst); |
| 653 dst2.set_offset(dst2.offset() + 4); | 653 dst2.set_offset(dst2.offset() + 4); |
| 654 str(src1, dst, cond); | 654 str(src1, dst, cond); |
| 655 str(src2, dst2, cond); | 655 str(src2, dst2, cond); |
| 656 } | 656 } |
| 657 } | 657 } |
| 658 | 658 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 // Reserve room for saved entry sp and code object. | 733 // Reserve room for saved entry sp and code object. |
| 734 sub(sp, sp, Operand(2 * kPointerSize)); | 734 sub(sp, sp, Operand(2 * kPointerSize)); |
| 735 if (emit_debug_code()) { | 735 if (emit_debug_code()) { |
| 736 mov(ip, Operand(0)); | 736 mov(ip, Operand(0)); |
| 737 str(ip, MemOperand(fp, ExitFrameConstants::kSPOffset)); | 737 str(ip, MemOperand(fp, ExitFrameConstants::kSPOffset)); |
| 738 } | 738 } |
| 739 mov(ip, Operand(CodeObject())); | 739 mov(ip, Operand(CodeObject())); |
| 740 str(ip, MemOperand(fp, ExitFrameConstants::kCodeOffset)); | 740 str(ip, MemOperand(fp, ExitFrameConstants::kCodeOffset)); |
| 741 | 741 |
| 742 // Save the frame pointer and the context in top. | 742 // Save the frame pointer and the context in top. |
| 743 mov(ip, Operand(ExternalReference(Top::k_c_entry_fp_address))); | 743 mov(ip, Operand(ExternalReference(Isolate::k_c_entry_fp_address))); |
| 744 str(fp, MemOperand(ip)); | 744 str(fp, MemOperand(ip)); |
| 745 mov(ip, Operand(ExternalReference(Top::k_context_address))); | 745 mov(ip, Operand(ExternalReference(Isolate::k_context_address))); |
| 746 str(cp, MemOperand(ip)); | 746 str(cp, MemOperand(ip)); |
| 747 | 747 |
| 748 // Optionally save all double registers. | 748 // Optionally save all double registers. |
| 749 if (save_doubles) { | 749 if (save_doubles) { |
| 750 sub(sp, sp, Operand(DwVfpRegister::kNumRegisters * kDoubleSize)); | 750 sub(sp, sp, Operand(DwVfpRegister::kNumRegisters * kDoubleSize)); |
| 751 const int offset = -2 * kPointerSize; | 751 const int offset = -2 * kPointerSize; |
| 752 for (int i = 0; i < DwVfpRegister::kNumRegisters; i++) { | 752 for (int i = 0; i < DwVfpRegister::kNumRegisters; i++) { |
| 753 DwVfpRegister reg = DwVfpRegister::from_code(i); | 753 DwVfpRegister reg = DwVfpRegister::from_code(i); |
| 754 vstr(reg, fp, offset - ((i + 1) * kDoubleSize)); | 754 vstr(reg, fp, offset - ((i + 1) * kDoubleSize)); |
| 755 } | 755 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 if (save_doubles) { | 811 if (save_doubles) { |
| 812 for (int i = 0; i < DwVfpRegister::kNumRegisters; i++) { | 812 for (int i = 0; i < DwVfpRegister::kNumRegisters; i++) { |
| 813 DwVfpRegister reg = DwVfpRegister::from_code(i); | 813 DwVfpRegister reg = DwVfpRegister::from_code(i); |
| 814 const int offset = -2 * kPointerSize; | 814 const int offset = -2 * kPointerSize; |
| 815 vldr(reg, fp, offset - ((i + 1) * kDoubleSize)); | 815 vldr(reg, fp, offset - ((i + 1) * kDoubleSize)); |
| 816 } | 816 } |
| 817 } | 817 } |
| 818 | 818 |
| 819 // Clear top frame. | 819 // Clear top frame. |
| 820 mov(r3, Operand(0, RelocInfo::NONE)); | 820 mov(r3, Operand(0, RelocInfo::NONE)); |
| 821 mov(ip, Operand(ExternalReference(Top::k_c_entry_fp_address))); | 821 mov(ip, Operand(ExternalReference(Isolate::k_c_entry_fp_address))); |
| 822 str(r3, MemOperand(ip)); | 822 str(r3, MemOperand(ip)); |
| 823 | 823 |
| 824 // Restore current context from top and clear it in debug mode. | 824 // Restore current context from top and clear it in debug mode. |
| 825 mov(ip, Operand(ExternalReference(Top::k_context_address))); | 825 mov(ip, Operand(ExternalReference(Isolate::k_context_address))); |
| 826 ldr(cp, MemOperand(ip)); | 826 ldr(cp, MemOperand(ip)); |
| 827 #ifdef DEBUG | 827 #ifdef DEBUG |
| 828 str(r3, MemOperand(ip)); | 828 str(r3, MemOperand(ip)); |
| 829 #endif | 829 #endif |
| 830 | 830 |
| 831 // Tear down the exit frame, pop the arguments, and return. | 831 // Tear down the exit frame, pop the arguments, and return. |
| 832 mov(sp, Operand(fp)); | 832 mov(sp, Operand(fp)); |
| 833 ldm(ia_w, sp, fp.bit() | lr.bit()); | 833 ldm(ia_w, sp, fp.bit() | lr.bit()); |
| 834 if (argument_count.is_valid()) { | 834 if (argument_count.is_valid()) { |
| 835 add(sp, sp, Operand(argument_count, LSL, kPointerSizeLog2)); | 835 add(sp, sp, Operand(argument_count, LSL, kPointerSizeLog2)); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 } | 897 } |
| 898 } | 898 } |
| 899 | 899 |
| 900 if (!definitely_matches) { | 900 if (!definitely_matches) { |
| 901 if (!code_constant.is_null()) { | 901 if (!code_constant.is_null()) { |
| 902 mov(r3, Operand(code_constant)); | 902 mov(r3, Operand(code_constant)); |
| 903 add(r3, r3, Operand(Code::kHeaderSize - kHeapObjectTag)); | 903 add(r3, r3, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 904 } | 904 } |
| 905 | 905 |
| 906 Handle<Code> adaptor = | 906 Handle<Code> adaptor = |
| 907 Handle<Code>(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline)); | 907 Handle<Code>(Isolate::Current()->builtins()->builtin( |
| 908 Builtins::ArgumentsAdaptorTrampoline)); |
| 908 if (flag == CALL_FUNCTION) { | 909 if (flag == CALL_FUNCTION) { |
| 909 if (call_wrapper != NULL) { | 910 if (call_wrapper != NULL) { |
| 910 call_wrapper->BeforeCall(CallSize(adaptor, RelocInfo::CODE_TARGET)); | 911 call_wrapper->BeforeCall(CallSize(adaptor, RelocInfo::CODE_TARGET)); |
| 911 } | 912 } |
| 912 Call(adaptor, RelocInfo::CODE_TARGET); | 913 Call(adaptor, RelocInfo::CODE_TARGET); |
| 913 if (call_wrapper != NULL) call_wrapper->AfterCall(); | 914 if (call_wrapper != NULL) call_wrapper->AfterCall(); |
| 914 b(done); | 915 b(done); |
| 915 } else { | 916 } else { |
| 916 Jump(adaptor, RelocInfo::CODE_TARGET); | 917 Jump(adaptor, RelocInfo::CODE_TARGET); |
| 917 } | 918 } |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1064 if (type == TRY_CATCH_HANDLER) { | 1065 if (type == TRY_CATCH_HANDLER) { |
| 1065 mov(r3, Operand(StackHandler::TRY_CATCH)); | 1066 mov(r3, Operand(StackHandler::TRY_CATCH)); |
| 1066 } else { | 1067 } else { |
| 1067 mov(r3, Operand(StackHandler::TRY_FINALLY)); | 1068 mov(r3, Operand(StackHandler::TRY_FINALLY)); |
| 1068 } | 1069 } |
| 1069 ASSERT(StackHandlerConstants::kStateOffset == 1 * kPointerSize | 1070 ASSERT(StackHandlerConstants::kStateOffset == 1 * kPointerSize |
| 1070 && StackHandlerConstants::kFPOffset == 2 * kPointerSize | 1071 && StackHandlerConstants::kFPOffset == 2 * kPointerSize |
| 1071 && StackHandlerConstants::kPCOffset == 3 * kPointerSize); | 1072 && StackHandlerConstants::kPCOffset == 3 * kPointerSize); |
| 1072 stm(db_w, sp, r3.bit() | fp.bit() | lr.bit()); | 1073 stm(db_w, sp, r3.bit() | fp.bit() | lr.bit()); |
| 1073 // Save the current handler as the next handler. | 1074 // Save the current handler as the next handler. |
| 1074 mov(r3, Operand(ExternalReference(Top::k_handler_address))); | 1075 mov(r3, Operand(ExternalReference(Isolate::k_handler_address))); |
| 1075 ldr(r1, MemOperand(r3)); | 1076 ldr(r1, MemOperand(r3)); |
| 1076 ASSERT(StackHandlerConstants::kNextOffset == 0); | 1077 ASSERT(StackHandlerConstants::kNextOffset == 0); |
| 1077 push(r1); | 1078 push(r1); |
| 1078 // Link this handler as the new current one. | 1079 // Link this handler as the new current one. |
| 1079 str(sp, MemOperand(r3)); | 1080 str(sp, MemOperand(r3)); |
| 1080 } else { | 1081 } else { |
| 1081 // Must preserve r0-r4, r5-r7 are available. | 1082 // Must preserve r0-r4, r5-r7 are available. |
| 1082 ASSERT(try_location == IN_JS_ENTRY); | 1083 ASSERT(try_location == IN_JS_ENTRY); |
| 1083 // The frame pointer does not point to a JS frame so we save NULL | 1084 // The frame pointer does not point to a JS frame so we save NULL |
| 1084 // for fp. We expect the code throwing an exception to check fp | 1085 // for fp. We expect the code throwing an exception to check fp |
| 1085 // before dereferencing it to restore the context. | 1086 // before dereferencing it to restore the context. |
| 1086 mov(ip, Operand(0, RelocInfo::NONE)); // To save a NULL frame pointer. | 1087 mov(ip, Operand(0, RelocInfo::NONE)); // To save a NULL frame pointer. |
| 1087 mov(r6, Operand(StackHandler::ENTRY)); | 1088 mov(r6, Operand(StackHandler::ENTRY)); |
| 1088 ASSERT(StackHandlerConstants::kStateOffset == 1 * kPointerSize | 1089 ASSERT(StackHandlerConstants::kStateOffset == 1 * kPointerSize |
| 1089 && StackHandlerConstants::kFPOffset == 2 * kPointerSize | 1090 && StackHandlerConstants::kFPOffset == 2 * kPointerSize |
| 1090 && StackHandlerConstants::kPCOffset == 3 * kPointerSize); | 1091 && StackHandlerConstants::kPCOffset == 3 * kPointerSize); |
| 1091 stm(db_w, sp, r6.bit() | ip.bit() | lr.bit()); | 1092 stm(db_w, sp, r6.bit() | ip.bit() | lr.bit()); |
| 1092 // Save the current handler as the next handler. | 1093 // Save the current handler as the next handler. |
| 1093 mov(r7, Operand(ExternalReference(Top::k_handler_address))); | 1094 mov(r7, Operand(ExternalReference(Isolate::k_handler_address))); |
| 1094 ldr(r6, MemOperand(r7)); | 1095 ldr(r6, MemOperand(r7)); |
| 1095 ASSERT(StackHandlerConstants::kNextOffset == 0); | 1096 ASSERT(StackHandlerConstants::kNextOffset == 0); |
| 1096 push(r6); | 1097 push(r6); |
| 1097 // Link this handler as the new current one. | 1098 // Link this handler as the new current one. |
| 1098 str(sp, MemOperand(r7)); | 1099 str(sp, MemOperand(r7)); |
| 1099 } | 1100 } |
| 1100 } | 1101 } |
| 1101 | 1102 |
| 1102 | 1103 |
| 1103 void MacroAssembler::PopTryHandler() { | 1104 void MacroAssembler::PopTryHandler() { |
| 1104 ASSERT_EQ(0, StackHandlerConstants::kNextOffset); | 1105 ASSERT_EQ(0, StackHandlerConstants::kNextOffset); |
| 1105 pop(r1); | 1106 pop(r1); |
| 1106 mov(ip, Operand(ExternalReference(Top::k_handler_address))); | 1107 mov(ip, Operand(ExternalReference(Isolate::k_handler_address))); |
| 1107 add(sp, sp, Operand(StackHandlerConstants::kSize - kPointerSize)); | 1108 add(sp, sp, Operand(StackHandlerConstants::kSize - kPointerSize)); |
| 1108 str(r1, MemOperand(ip)); | 1109 str(r1, MemOperand(ip)); |
| 1109 } | 1110 } |
| 1110 | 1111 |
| 1111 | 1112 |
| 1112 void MacroAssembler::Throw(Register value) { | 1113 void MacroAssembler::Throw(Register value) { |
| 1113 // r0 is expected to hold the exception. | 1114 // r0 is expected to hold the exception. |
| 1114 if (!value.is(r0)) { | 1115 if (!value.is(r0)) { |
| 1115 mov(r0, value); | 1116 mov(r0, value); |
| 1116 } | 1117 } |
| 1117 | 1118 |
| 1118 // Adjust this code if not the case. | 1119 // Adjust this code if not the case. |
| 1119 STATIC_ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize); | 1120 STATIC_ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize); |
| 1120 | 1121 |
| 1121 // Drop the sp to the top of the handler. | 1122 // Drop the sp to the top of the handler. |
| 1122 mov(r3, Operand(ExternalReference(Top::k_handler_address))); | 1123 mov(r3, Operand(ExternalReference(Isolate::k_handler_address))); |
| 1123 ldr(sp, MemOperand(r3)); | 1124 ldr(sp, MemOperand(r3)); |
| 1124 | 1125 |
| 1125 // Restore the next handler and frame pointer, discard handler state. | 1126 // Restore the next handler and frame pointer, discard handler state. |
| 1126 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); | 1127 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); |
| 1127 pop(r2); | 1128 pop(r2); |
| 1128 str(r2, MemOperand(r3)); | 1129 str(r2, MemOperand(r3)); |
| 1129 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 2 * kPointerSize); | 1130 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 2 * kPointerSize); |
| 1130 ldm(ia_w, sp, r3.bit() | fp.bit()); // r3: discarded state. | 1131 ldm(ia_w, sp, r3.bit() | fp.bit()); // r3: discarded state. |
| 1131 | 1132 |
| 1132 // Before returning we restore the context from the frame pointer if | 1133 // Before returning we restore the context from the frame pointer if |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1151 Register value) { | 1152 Register value) { |
| 1152 // Adjust this code if not the case. | 1153 // Adjust this code if not the case. |
| 1153 STATIC_ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize); | 1154 STATIC_ASSERT(StackHandlerConstants::kSize == 4 * kPointerSize); |
| 1154 | 1155 |
| 1155 // r0 is expected to hold the exception. | 1156 // r0 is expected to hold the exception. |
| 1156 if (!value.is(r0)) { | 1157 if (!value.is(r0)) { |
| 1157 mov(r0, value); | 1158 mov(r0, value); |
| 1158 } | 1159 } |
| 1159 | 1160 |
| 1160 // Drop sp to the top stack handler. | 1161 // Drop sp to the top stack handler. |
| 1161 mov(r3, Operand(ExternalReference(Top::k_handler_address))); | 1162 mov(r3, Operand(ExternalReference(Isolate::k_handler_address))); |
| 1162 ldr(sp, MemOperand(r3)); | 1163 ldr(sp, MemOperand(r3)); |
| 1163 | 1164 |
| 1164 // Unwind the handlers until the ENTRY handler is found. | 1165 // Unwind the handlers until the ENTRY handler is found. |
| 1165 Label loop, done; | 1166 Label loop, done; |
| 1166 bind(&loop); | 1167 bind(&loop); |
| 1167 // Load the type of the current stack handler. | 1168 // Load the type of the current stack handler. |
| 1168 const int kStateOffset = StackHandlerConstants::kStateOffset; | 1169 const int kStateOffset = StackHandlerConstants::kStateOffset; |
| 1169 ldr(r2, MemOperand(sp, kStateOffset)); | 1170 ldr(r2, MemOperand(sp, kStateOffset)); |
| 1170 cmp(r2, Operand(StackHandler::ENTRY)); | 1171 cmp(r2, Operand(StackHandler::ENTRY)); |
| 1171 b(eq, &done); | 1172 b(eq, &done); |
| 1172 // Fetch the next handler in the list. | 1173 // Fetch the next handler in the list. |
| 1173 const int kNextOffset = StackHandlerConstants::kNextOffset; | 1174 const int kNextOffset = StackHandlerConstants::kNextOffset; |
| 1174 ldr(sp, MemOperand(sp, kNextOffset)); | 1175 ldr(sp, MemOperand(sp, kNextOffset)); |
| 1175 jmp(&loop); | 1176 jmp(&loop); |
| 1176 bind(&done); | 1177 bind(&done); |
| 1177 | 1178 |
| 1178 // Set the top handler address to next handler past the current ENTRY handler. | 1179 // Set the top handler address to next handler past the current ENTRY handler. |
| 1179 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); | 1180 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); |
| 1180 pop(r2); | 1181 pop(r2); |
| 1181 str(r2, MemOperand(r3)); | 1182 str(r2, MemOperand(r3)); |
| 1182 | 1183 |
| 1183 if (type == OUT_OF_MEMORY) { | 1184 if (type == OUT_OF_MEMORY) { |
| 1184 // Set external caught exception to false. | 1185 // Set external caught exception to false. |
| 1185 ExternalReference external_caught(Top::k_external_caught_exception_address); | 1186 ExternalReference external_caught( |
| 1187 Isolate::k_external_caught_exception_address); |
| 1186 mov(r0, Operand(false, RelocInfo::NONE)); | 1188 mov(r0, Operand(false, RelocInfo::NONE)); |
| 1187 mov(r2, Operand(external_caught)); | 1189 mov(r2, Operand(external_caught)); |
| 1188 str(r0, MemOperand(r2)); | 1190 str(r0, MemOperand(r2)); |
| 1189 | 1191 |
| 1190 // Set pending exception and r0 to out of memory exception. | 1192 // Set pending exception and r0 to out of memory exception. |
| 1191 Failure* out_of_memory = Failure::OutOfMemoryException(); | 1193 Failure* out_of_memory = Failure::OutOfMemoryException(); |
| 1192 mov(r0, Operand(reinterpret_cast<int32_t>(out_of_memory))); | 1194 mov(r0, Operand(reinterpret_cast<int32_t>(out_of_memory))); |
| 1193 mov(r2, Operand(ExternalReference(Top::k_pending_exception_address))); | 1195 mov(r2, Operand(ExternalReference(Isolate::k_pending_exception_address))); |
| 1194 str(r0, MemOperand(r2)); | 1196 str(r0, MemOperand(r2)); |
| 1195 } | 1197 } |
| 1196 | 1198 |
| 1197 // Stack layout at this point. See also StackHandlerConstants. | 1199 // Stack layout at this point. See also StackHandlerConstants. |
| 1198 // sp -> state (ENTRY) | 1200 // sp -> state (ENTRY) |
| 1199 // fp | 1201 // fp |
| 1200 // lr | 1202 // lr |
| 1201 | 1203 |
| 1202 // Discard handler state (r2 is not used) and restore frame pointer. | 1204 // Discard handler state (r2 is not used) and restore frame pointer. |
| 1203 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 2 * kPointerSize); | 1205 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 2 * kPointerSize); |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1890 | 1892 |
| 1891 // Tries to get a signed int32 out of a double precision floating point heap | 1893 // Tries to get a signed int32 out of a double precision floating point heap |
| 1892 // number. Rounds towards 0. Branch to 'not_int32' if the double is out of the | 1894 // number. Rounds towards 0. Branch to 'not_int32' if the double is out of the |
| 1893 // 32bits signed integer range. | 1895 // 32bits signed integer range. |
| 1894 void MacroAssembler::ConvertToInt32(Register source, | 1896 void MacroAssembler::ConvertToInt32(Register source, |
| 1895 Register dest, | 1897 Register dest, |
| 1896 Register scratch, | 1898 Register scratch, |
| 1897 Register scratch2, | 1899 Register scratch2, |
| 1898 DwVfpRegister double_scratch, | 1900 DwVfpRegister double_scratch, |
| 1899 Label *not_int32) { | 1901 Label *not_int32) { |
| 1900 if (CpuFeatures::IsSupported(VFP3)) { | 1902 if (Isolate::Current()->cpu_features()->IsSupported(VFP3)) { |
| 1901 CpuFeatures::Scope scope(VFP3); | 1903 CpuFeatures::Scope scope(VFP3); |
| 1902 sub(scratch, source, Operand(kHeapObjectTag)); | 1904 sub(scratch, source, Operand(kHeapObjectTag)); |
| 1903 vldr(double_scratch, scratch, HeapNumber::kValueOffset); | 1905 vldr(double_scratch, scratch, HeapNumber::kValueOffset); |
| 1904 vcvt_s32_f64(double_scratch.low(), double_scratch); | 1906 vcvt_s32_f64(double_scratch.low(), double_scratch); |
| 1905 vmov(dest, double_scratch.low()); | 1907 vmov(dest, double_scratch.low()); |
| 1906 // Signed vcvt instruction will saturate to the minimum (0x80000000) or | 1908 // Signed vcvt instruction will saturate to the minimum (0x80000000) or |
| 1907 // maximun (0x7fffffff) signed 32bits integer when the double is out of | 1909 // maximun (0x7fffffff) signed 32bits integer when the double is out of |
| 1908 // range. When substracting one, the minimum signed integer becomes the | 1910 // range. When substracting one, the minimum signed integer becomes the |
| 1909 // maximun signed integer. | 1911 // maximun signed integer. |
| 1910 sub(scratch, dest, Operand(1)); | 1912 sub(scratch, dest, Operand(1)); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1986 } | 1988 } |
| 1987 } | 1989 } |
| 1988 | 1990 |
| 1989 | 1991 |
| 1990 void MacroAssembler::EmitVFPTruncate(VFPRoundingMode rounding_mode, | 1992 void MacroAssembler::EmitVFPTruncate(VFPRoundingMode rounding_mode, |
| 1991 SwVfpRegister result, | 1993 SwVfpRegister result, |
| 1992 DwVfpRegister double_input, | 1994 DwVfpRegister double_input, |
| 1993 Register scratch1, | 1995 Register scratch1, |
| 1994 Register scratch2, | 1996 Register scratch2, |
| 1995 CheckForInexactConversion check_inexact) { | 1997 CheckForInexactConversion check_inexact) { |
| 1996 ASSERT(CpuFeatures::IsSupported(VFP3)); | 1998 ASSERT(Isolate::Current()->cpu_features()->IsSupported(VFP3)); |
| 1997 CpuFeatures::Scope scope(VFP3); | 1999 CpuFeatures::Scope scope(VFP3); |
| 1998 Register prev_fpscr = scratch1; | 2000 Register prev_fpscr = scratch1; |
| 1999 Register scratch = scratch2; | 2001 Register scratch = scratch2; |
| 2000 | 2002 |
| 2001 int32_t check_inexact_conversion = | 2003 int32_t check_inexact_conversion = |
| 2002 (check_inexact == kCheckForInexactConversion) ? kVFPInexactExceptionBit : 0; | 2004 (check_inexact == kCheckForInexactConversion) ? kVFPInexactExceptionBit : 0; |
| 2003 | 2005 |
| 2004 // Set custom FPCSR: | 2006 // Set custom FPCSR: |
| 2005 // - Set rounding mode. | 2007 // - Set rounding mode. |
| 2006 // - Clear vfp cumulative exception flags. | 2008 // - Clear vfp cumulative exception flags. |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2144 input_high, | 2146 input_high, |
| 2145 input_low, | 2147 input_low, |
| 2146 scratch); | 2148 scratch); |
| 2147 bind(&done); | 2149 bind(&done); |
| 2148 } | 2150 } |
| 2149 | 2151 |
| 2150 | 2152 |
| 2151 void MacroAssembler::GetLeastBitsFromSmi(Register dst, | 2153 void MacroAssembler::GetLeastBitsFromSmi(Register dst, |
| 2152 Register src, | 2154 Register src, |
| 2153 int num_least_bits) { | 2155 int num_least_bits) { |
| 2154 if (CpuFeatures::IsSupported(ARMv7)) { | 2156 if (Isolate::Current()->cpu_features()->IsSupported(ARMv7)) { |
| 2155 ubfx(dst, src, kSmiTagSize, num_least_bits); | 2157 ubfx(dst, src, kSmiTagSize, num_least_bits); |
| 2156 } else { | 2158 } else { |
| 2157 mov(dst, Operand(src, ASR, kSmiTagSize)); | 2159 mov(dst, Operand(src, ASR, kSmiTagSize)); |
| 2158 and_(dst, dst, Operand((1 << num_least_bits) - 1)); | 2160 and_(dst, dst, Operand((1 << num_least_bits) - 1)); |
| 2159 } | 2161 } |
| 2160 } | 2162 } |
| 2161 | 2163 |
| 2162 | 2164 |
| 2163 void MacroAssembler::GetLeastBitsFromInt32(Register dst, | 2165 void MacroAssembler::GetLeastBitsFromInt32(Register dst, |
| 2164 Register src, | 2166 Register src, |
| 2165 int num_least_bits) { | 2167 int num_least_bits) { |
| 2166 and_(dst, src, Operand((1 << num_least_bits) - 1)); | 2168 and_(dst, src, Operand((1 << num_least_bits) - 1)); |
| 2167 } | 2169 } |
| 2168 | 2170 |
| 2169 | 2171 |
| 2170 void MacroAssembler::CallRuntime(Runtime::Function* f, int num_arguments) { | 2172 void MacroAssembler::CallRuntime(const Runtime::Function* f, |
| 2173 int num_arguments) { |
| 2171 // All parameters are on the stack. r0 has the return value after call. | 2174 // All parameters are on the stack. r0 has the return value after call. |
| 2172 | 2175 |
| 2173 // If the expected number of arguments of the runtime function is | 2176 // If the expected number of arguments of the runtime function is |
| 2174 // constant, we check that the actual number of arguments match the | 2177 // constant, we check that the actual number of arguments match the |
| 2175 // expectation. | 2178 // expectation. |
| 2176 if (f->nargs >= 0 && f->nargs != num_arguments) { | 2179 if (f->nargs >= 0 && f->nargs != num_arguments) { |
| 2177 IllegalOperation(num_arguments); | 2180 IllegalOperation(num_arguments); |
| 2178 return; | 2181 return; |
| 2179 } | 2182 } |
| 2180 | 2183 |
| 2181 // TODO(1236192): Most runtime routines don't need the number of | 2184 // TODO(1236192): Most runtime routines don't need the number of |
| 2182 // arguments passed in because it is constant. At some point we | 2185 // arguments passed in because it is constant. At some point we |
| 2183 // should remove this need and make the runtime routine entry code | 2186 // should remove this need and make the runtime routine entry code |
| 2184 // smarter. | 2187 // smarter. |
| 2185 mov(r0, Operand(num_arguments)); | 2188 mov(r0, Operand(num_arguments)); |
| 2186 mov(r1, Operand(ExternalReference(f))); | 2189 mov(r1, Operand(ExternalReference(f))); |
| 2187 CEntryStub stub(1); | 2190 CEntryStub stub(1); |
| 2188 CallStub(&stub); | 2191 CallStub(&stub); |
| 2189 } | 2192 } |
| 2190 | 2193 |
| 2191 | 2194 |
| 2192 void MacroAssembler::CallRuntime(Runtime::FunctionId fid, int num_arguments) { | 2195 void MacroAssembler::CallRuntime(Runtime::FunctionId fid, int num_arguments) { |
| 2193 CallRuntime(Runtime::FunctionForId(fid), num_arguments); | 2196 CallRuntime(Runtime::FunctionForId(fid), num_arguments); |
| 2194 } | 2197 } |
| 2195 | 2198 |
| 2196 | 2199 |
| 2197 void MacroAssembler::CallRuntimeSaveDoubles(Runtime::FunctionId id) { | 2200 void MacroAssembler::CallRuntimeSaveDoubles(Runtime::FunctionId id) { |
| 2198 Runtime::Function* function = Runtime::FunctionForId(id); | 2201 const Runtime::Function* function = Runtime::FunctionForId(id); |
| 2199 mov(r0, Operand(function->nargs)); | 2202 mov(r0, Operand(function->nargs)); |
| 2200 mov(r1, Operand(ExternalReference(function))); | 2203 mov(r1, Operand(ExternalReference(function))); |
| 2201 CEntryStub stub(1); | 2204 CEntryStub stub(1); |
| 2202 stub.SaveDoubles(); | 2205 stub.SaveDoubles(); |
| 2203 CallStub(&stub); | 2206 CallStub(&stub); |
| 2204 } | 2207 } |
| 2205 | 2208 |
| 2206 | 2209 |
| 2207 void MacroAssembler::CallExternalReference(const ExternalReference& ext, | 2210 void MacroAssembler::CallExternalReference(const ExternalReference& ext, |
| 2208 int num_arguments) { | 2211 int num_arguments) { |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2765 Register scratch, | 2768 Register scratch, |
| 2766 Label* failure) { | 2769 Label* failure) { |
| 2767 int kFlatAsciiStringMask = | 2770 int kFlatAsciiStringMask = |
| 2768 kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask; | 2771 kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask; |
| 2769 int kFlatAsciiStringTag = ASCII_STRING_TYPE; | 2772 int kFlatAsciiStringTag = ASCII_STRING_TYPE; |
| 2770 and_(scratch, type, Operand(kFlatAsciiStringMask)); | 2773 and_(scratch, type, Operand(kFlatAsciiStringMask)); |
| 2771 cmp(scratch, Operand(kFlatAsciiStringTag)); | 2774 cmp(scratch, Operand(kFlatAsciiStringTag)); |
| 2772 b(ne, failure); | 2775 b(ne, failure); |
| 2773 } | 2776 } |
| 2774 | 2777 |
| 2778 static const int kRegisterPassedArguments = 4; |
| 2775 | 2779 |
| 2776 void MacroAssembler::PrepareCallCFunction(int num_arguments, Register scratch) { | 2780 void MacroAssembler::PrepareCallCFunction(int num_arguments, Register scratch) { |
| 2777 int frame_alignment = ActivationFrameAlignment(); | 2781 int frame_alignment = ActivationFrameAlignment(); |
| 2782 |
| 2783 // Reserve space for Isolate address which is always passed as last parameter |
| 2784 num_arguments += 1; |
| 2785 |
| 2778 // Up to four simple arguments are passed in registers r0..r3. | 2786 // Up to four simple arguments are passed in registers r0..r3. |
| 2779 int stack_passed_arguments = (num_arguments <= 4) ? 0 : num_arguments - 4; | 2787 int stack_passed_arguments = (num_arguments <= kRegisterPassedArguments) ? |
| 2788 0 : num_arguments - kRegisterPassedArguments; |
| 2780 if (frame_alignment > kPointerSize) { | 2789 if (frame_alignment > kPointerSize) { |
| 2781 // Make stack end at alignment and make room for num_arguments - 4 words | 2790 // Make stack end at alignment and make room for num_arguments - 4 words |
| 2782 // and the original value of sp. | 2791 // and the original value of sp. |
| 2783 mov(scratch, sp); | 2792 mov(scratch, sp); |
| 2784 sub(sp, sp, Operand((stack_passed_arguments + 1) * kPointerSize)); | 2793 sub(sp, sp, Operand((stack_passed_arguments + 1) * kPointerSize)); |
| 2785 ASSERT(IsPowerOf2(frame_alignment)); | 2794 ASSERT(IsPowerOf2(frame_alignment)); |
| 2786 and_(sp, sp, Operand(-frame_alignment)); | 2795 and_(sp, sp, Operand(-frame_alignment)); |
| 2787 str(scratch, MemOperand(sp, stack_passed_arguments * kPointerSize)); | 2796 str(scratch, MemOperand(sp, stack_passed_arguments * kPointerSize)); |
| 2788 } else { | 2797 } else { |
| 2789 sub(sp, sp, Operand(stack_passed_arguments * kPointerSize)); | 2798 sub(sp, sp, Operand(stack_passed_arguments * kPointerSize)); |
| 2790 } | 2799 } |
| 2791 } | 2800 } |
| 2792 | 2801 |
| 2793 | 2802 |
| 2794 void MacroAssembler::CallCFunction(ExternalReference function, | 2803 void MacroAssembler::CallCFunction(ExternalReference function, |
| 2795 int num_arguments) { | 2804 int num_arguments) { |
| 2796 mov(ip, Operand(function)); | 2805 CallCFunctionHelper(no_reg, function, ip, num_arguments); |
| 2797 CallCFunction(ip, num_arguments); | 2806 } |
| 2807 |
| 2808 void MacroAssembler::CallCFunction(Register function, |
| 2809 Register scratch, |
| 2810 int num_arguments) { |
| 2811 CallCFunctionHelper(function, |
| 2812 ExternalReference::the_hole_value_location(), |
| 2813 scratch, |
| 2814 num_arguments); |
| 2798 } | 2815 } |
| 2799 | 2816 |
| 2800 | 2817 |
| 2801 void MacroAssembler::CallCFunction(Register function, int num_arguments) { | 2818 void MacroAssembler::CallCFunctionHelper(Register function, |
| 2819 ExternalReference function_reference, |
| 2820 Register scratch, |
| 2821 int num_arguments) { |
| 2822 // Push Isolate address as the last argument. |
| 2823 if (num_arguments < kRegisterPassedArguments) { |
| 2824 Register arg_to_reg[] = {r0, r1, r2, r3}; |
| 2825 Register r = arg_to_reg[num_arguments]; |
| 2826 mov(r, Operand(ExternalReference::isolate_address())); |
| 2827 } else { |
| 2828 int stack_passed_arguments = num_arguments - kRegisterPassedArguments; |
| 2829 // Push Isolate address on the stack after the arguments. |
| 2830 mov(scratch, Operand(ExternalReference::isolate_address())); |
| 2831 str(scratch, MemOperand(sp, stack_passed_arguments * kPointerSize)); |
| 2832 } |
| 2833 num_arguments += 1; |
| 2834 |
| 2802 // Make sure that the stack is aligned before calling a C function unless | 2835 // Make sure that the stack is aligned before calling a C function unless |
| 2803 // running in the simulator. The simulator has its own alignment check which | 2836 // running in the simulator. The simulator has its own alignment check which |
| 2804 // provides more information. | 2837 // provides more information. |
| 2805 #if defined(V8_HOST_ARCH_ARM) | 2838 #if defined(V8_HOST_ARCH_ARM) |
| 2806 if (emit_debug_code()) { | 2839 if (emit_debug_code()) { |
| 2807 int frame_alignment = OS::ActivationFrameAlignment(); | 2840 int frame_alignment = OS::ActivationFrameAlignment(); |
| 2808 int frame_alignment_mask = frame_alignment - 1; | 2841 int frame_alignment_mask = frame_alignment - 1; |
| 2809 if (frame_alignment > kPointerSize) { | 2842 if (frame_alignment > kPointerSize) { |
| 2810 ASSERT(IsPowerOf2(frame_alignment)); | 2843 ASSERT(IsPowerOf2(frame_alignment)); |
| 2811 Label alignment_as_expected; | 2844 Label alignment_as_expected; |
| 2812 tst(sp, Operand(frame_alignment_mask)); | 2845 tst(sp, Operand(frame_alignment_mask)); |
| 2813 b(eq, &alignment_as_expected); | 2846 b(eq, &alignment_as_expected); |
| 2814 // Don't use Check here, as it will call Runtime_Abort possibly | 2847 // Don't use Check here, as it will call Runtime_Abort possibly |
| 2815 // re-entering here. | 2848 // re-entering here. |
| 2816 stop("Unexpected alignment"); | 2849 stop("Unexpected alignment"); |
| 2817 bind(&alignment_as_expected); | 2850 bind(&alignment_as_expected); |
| 2818 } | 2851 } |
| 2819 } | 2852 } |
| 2820 #endif | 2853 #endif |
| 2821 | 2854 |
| 2822 // Just call directly. The function called cannot cause a GC, or | 2855 // Just call directly. The function called cannot cause a GC, or |
| 2823 // allow preemption, so the return address in the link register | 2856 // allow preemption, so the return address in the link register |
| 2824 // stays correct. | 2857 // stays correct. |
| 2858 if (function.is(no_reg)) { |
| 2859 mov(scratch, Operand(function_reference)); |
| 2860 function = scratch; |
| 2861 } |
| 2825 Call(function); | 2862 Call(function); |
| 2826 int stack_passed_arguments = (num_arguments <= 4) ? 0 : num_arguments - 4; | 2863 int stack_passed_arguments = (num_arguments <= kRegisterPassedArguments) ? |
| 2864 0 : num_arguments - kRegisterPassedArguments; |
| 2827 if (OS::ActivationFrameAlignment() > kPointerSize) { | 2865 if (OS::ActivationFrameAlignment() > kPointerSize) { |
| 2828 ldr(sp, MemOperand(sp, stack_passed_arguments * kPointerSize)); | 2866 ldr(sp, MemOperand(sp, stack_passed_arguments * kPointerSize)); |
| 2829 } else { | 2867 } else { |
| 2830 add(sp, sp, Operand(stack_passed_arguments * sizeof(kPointerSize))); | 2868 add(sp, sp, Operand(stack_passed_arguments * sizeof(kPointerSize))); |
| 2831 } | 2869 } |
| 2832 } | 2870 } |
| 2833 | 2871 |
| 2834 | 2872 |
| 2835 void MacroAssembler::GetRelocatedValueLocation(Register ldr_location, | 2873 void MacroAssembler::GetRelocatedValueLocation(Register ldr_location, |
| 2836 Register result) { | 2874 Register result) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2887 void CodePatcher::EmitCondition(Condition cond) { | 2925 void CodePatcher::EmitCondition(Condition cond) { |
| 2888 Instr instr = Assembler::instr_at(masm_.pc_); | 2926 Instr instr = Assembler::instr_at(masm_.pc_); |
| 2889 instr = (instr & ~kCondMask) | cond; | 2927 instr = (instr & ~kCondMask) | cond; |
| 2890 masm_.emit(instr); | 2928 masm_.emit(instr); |
| 2891 } | 2929 } |
| 2892 | 2930 |
| 2893 | 2931 |
| 2894 } } // namespace v8::internal | 2932 } } // namespace v8::internal |
| 2895 | 2933 |
| 2896 #endif // V8_TARGET_ARCH_ARM | 2934 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |