Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: src/arm/macro-assembler-arm.cc

Issue 1131783003: Embedded constant pools. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix debug-mode Arm issue. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/arm/macro-assembler-arm.h ('k') | src/arm64/assembler-arm64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <limits.h> // For LONG_MIN, LONG_MAX. 5 #include <limits.h> // For LONG_MIN, LONG_MAX.
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #if V8_TARGET_ARCH_ARM 9 #if V8_TARGET_ARCH_ARM
10 10
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 pop(lr); 684 pop(lr);
685 bind(&done); 685 bind(&done);
686 if (and_then == kReturnAtEnd) { 686 if (and_then == kReturnAtEnd) {
687 Ret(); 687 Ret();
688 } 688 }
689 } 689 }
690 690
691 691
692 void MacroAssembler::PushFixedFrame(Register marker_reg) { 692 void MacroAssembler::PushFixedFrame(Register marker_reg) {
693 DCHECK(!marker_reg.is_valid() || marker_reg.code() < cp.code()); 693 DCHECK(!marker_reg.is_valid() || marker_reg.code() < cp.code());
694 stm(db_w, sp, (marker_reg.is_valid() ? marker_reg.bit() : 0) | 694 stm(db_w, sp, (marker_reg.is_valid() ? marker_reg.bit() : 0) | cp.bit() |
695 cp.bit() | 695 (FLAG_enable_embedded_constant_pool ? pp.bit() : 0) |
696 (FLAG_enable_ool_constant_pool ? pp.bit() : 0) | 696 fp.bit() | lr.bit());
697 fp.bit() |
698 lr.bit());
699 } 697 }
700 698
701 699
702 void MacroAssembler::PopFixedFrame(Register marker_reg) { 700 void MacroAssembler::PopFixedFrame(Register marker_reg) {
703 DCHECK(!marker_reg.is_valid() || marker_reg.code() < cp.code()); 701 DCHECK(!marker_reg.is_valid() || marker_reg.code() < cp.code());
704 ldm(ia_w, sp, (marker_reg.is_valid() ? marker_reg.bit() : 0) | 702 ldm(ia_w, sp, (marker_reg.is_valid() ? marker_reg.bit() : 0) | cp.bit() |
705 cp.bit() | 703 (FLAG_enable_embedded_constant_pool ? pp.bit() : 0) |
706 (FLAG_enable_ool_constant_pool ? pp.bit() : 0) | 704 fp.bit() | lr.bit());
707 fp.bit() |
708 lr.bit());
709 } 705 }
710 706
711 707
712 // Push and pop all registers that can hold pointers. 708 // Push and pop all registers that can hold pointers.
713 void MacroAssembler::PushSafepointRegisters() { 709 void MacroAssembler::PushSafepointRegisters() {
714 // Safepoints expect a block of contiguous register values starting with r0: 710 // Safepoints expect a block of contiguous register values starting with r0:
715 DCHECK(((1 << kNumSafepointSavedRegisters) - 1) == kSafepointSavedRegisters); 711 DCHECK(((1 << kNumSafepointSavedRegisters) - 1) == kSafepointSavedRegisters);
716 // Safepoints expect a block of kNumSafepointRegisters values on the 712 // Safepoints expect a block of kNumSafepointRegisters values on the
717 // stack, so adjust the stack for unsaved registers. 713 // stack, so adjust the stack for unsaved registers.
718 const int num_unsaved = kNumSafepointRegisters - kNumSafepointSavedRegisters; 714 const int num_unsaved = kNumSafepointRegisters - kNumSafepointSavedRegisters;
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 void MacroAssembler::VmovLow(DwVfpRegister dst, Register src) { 974 void MacroAssembler::VmovLow(DwVfpRegister dst, Register src) {
979 if (dst.code() < 16) { 975 if (dst.code() < 16) {
980 const LowDwVfpRegister loc = LowDwVfpRegister::from_code(dst.code()); 976 const LowDwVfpRegister loc = LowDwVfpRegister::from_code(dst.code());
981 vmov(loc.low(), src); 977 vmov(loc.low(), src);
982 } else { 978 } else {
983 vmov(dst, VmovIndexLo, src); 979 vmov(dst, VmovIndexLo, src);
984 } 980 }
985 } 981 }
986 982
987 983
984 void MacroAssembler::LoadConstantPoolPointerRegisterFromCodeTargetAddress(
985 Register code_target_address) {
986 DCHECK(FLAG_enable_embedded_constant_pool);
987 ldr(pp, MemOperand(code_target_address,
988 Code::kConstantPoolOffset - Code::kHeaderSize));
989 add(pp, pp, code_target_address);
990 }
991
992
988 void MacroAssembler::LoadConstantPoolPointerRegister() { 993 void MacroAssembler::LoadConstantPoolPointerRegister() {
989 if (FLAG_enable_ool_constant_pool) { 994 DCHECK(FLAG_enable_embedded_constant_pool);
990 int constant_pool_offset = Code::kConstantPoolOffset - Code::kHeaderSize - 995 int entry_offset = pc_offset() + Instruction::kPCReadOffset;
991 pc_offset() - Instruction::kPCReadOffset; 996 sub(ip, pc, Operand(entry_offset));
992 DCHECK(ImmediateFitsAddrMode2Instruction(constant_pool_offset)); 997 LoadConstantPoolPointerRegisterFromCodeTargetAddress(ip);
993 ldr(pp, MemOperand(pc, constant_pool_offset));
994 }
995 } 998 }
996 999
997 1000
998 void MacroAssembler::StubPrologue() { 1001 void MacroAssembler::StubPrologue() {
999 PushFixedFrame(); 1002 PushFixedFrame();
1000 Push(Smi::FromInt(StackFrame::STUB)); 1003 Push(Smi::FromInt(StackFrame::STUB));
1001 // Adjust FP to point to saved FP. 1004 // Adjust FP to point to saved FP.
1002 add(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp)); 1005 add(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
1003 if (FLAG_enable_ool_constant_pool) { 1006 if (FLAG_enable_embedded_constant_pool) {
1004 LoadConstantPoolPointerRegister(); 1007 LoadConstantPoolPointerRegister();
1005 set_ool_constant_pool_available(true); 1008 set_constant_pool_available(true);
1006 } 1009 }
1007 } 1010 }
1008 1011
1009 1012
1010 void MacroAssembler::Prologue(bool code_pre_aging) { 1013 void MacroAssembler::Prologue(bool code_pre_aging) {
1011 { PredictableCodeSizeScope predictible_code_size_scope( 1014 { PredictableCodeSizeScope predictible_code_size_scope(
1012 this, kNoCodeAgeSequenceLength); 1015 this, kNoCodeAgeSequenceLength);
1013 // The following three instructions must remain together and unmodified 1016 // The following three instructions must remain together and unmodified
1014 // for code aging to work properly. 1017 // for code aging to work properly.
1015 if (code_pre_aging) { 1018 if (code_pre_aging) {
1016 // Pre-age the code. 1019 // Pre-age the code.
1017 Code* stub = Code::GetPreAgedCodeAgeStub(isolate()); 1020 Code* stub = Code::GetPreAgedCodeAgeStub(isolate());
1018 add(r0, pc, Operand(-8)); 1021 add(r0, pc, Operand(-8));
1019 ldr(pc, MemOperand(pc, -4)); 1022 ldr(pc, MemOperand(pc, -4));
1020 emit_code_stub_address(stub); 1023 emit_code_stub_address(stub);
1021 } else { 1024 } else {
1022 PushFixedFrame(r1); 1025 PushFixedFrame(r1);
1023 nop(ip.code()); 1026 nop(ip.code());
1024 // Adjust FP to point to saved FP. 1027 // Adjust FP to point to saved FP.
1025 add(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp)); 1028 add(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
1026 } 1029 }
1027 } 1030 }
1028 if (FLAG_enable_ool_constant_pool) { 1031 if (FLAG_enable_embedded_constant_pool) {
1029 LoadConstantPoolPointerRegister(); 1032 LoadConstantPoolPointerRegister();
1030 set_ool_constant_pool_available(true); 1033 set_constant_pool_available(true);
1031 } 1034 }
1032 } 1035 }
1033 1036
1034 1037
1035 void MacroAssembler::EnterFrame(StackFrame::Type type, 1038 void MacroAssembler::EnterFrame(StackFrame::Type type,
1036 bool load_constant_pool_pointer_reg) { 1039 bool load_constant_pool_pointer_reg) {
1037 // r0-r3: preserved 1040 // r0-r3: preserved
1038 PushFixedFrame(); 1041 PushFixedFrame();
1039 if (FLAG_enable_ool_constant_pool && load_constant_pool_pointer_reg) { 1042 if (FLAG_enable_embedded_constant_pool && load_constant_pool_pointer_reg) {
1040 LoadConstantPoolPointerRegister(); 1043 LoadConstantPoolPointerRegister();
1041 } 1044 }
1042 mov(ip, Operand(Smi::FromInt(type))); 1045 mov(ip, Operand(Smi::FromInt(type)));
1043 push(ip); 1046 push(ip);
1044 mov(ip, Operand(CodeObject())); 1047 mov(ip, Operand(CodeObject()));
1045 push(ip); 1048 push(ip);
1046 // Adjust FP to point to saved FP. 1049 // Adjust FP to point to saved FP.
1047 add(fp, sp, 1050 add(fp, sp,
1048 Operand(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize)); 1051 Operand(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize));
1049 } 1052 }
1050 1053
1051 1054
1052 int MacroAssembler::LeaveFrame(StackFrame::Type type) { 1055 int MacroAssembler::LeaveFrame(StackFrame::Type type) {
1053 // r0: preserved 1056 // r0: preserved
1054 // r1: preserved 1057 // r1: preserved
1055 // r2: preserved 1058 // r2: preserved
1056 1059
1057 // Drop the execution stack down to the frame pointer and restore 1060 // Drop the execution stack down to the frame pointer and restore
1058 // the caller frame pointer, return address and constant pool pointer 1061 // the caller frame pointer, return address and constant pool pointer
1059 // (if FLAG_enable_ool_constant_pool). 1062 // (if FLAG_enable_embedded_constant_pool).
1060 int frame_ends; 1063 int frame_ends;
1061 if (FLAG_enable_ool_constant_pool) { 1064 if (FLAG_enable_embedded_constant_pool) {
1062 add(sp, fp, Operand(StandardFrameConstants::kConstantPoolOffset)); 1065 add(sp, fp, Operand(StandardFrameConstants::kConstantPoolOffset));
1063 frame_ends = pc_offset(); 1066 frame_ends = pc_offset();
1064 ldm(ia_w, sp, pp.bit() | fp.bit() | lr.bit()); 1067 ldm(ia_w, sp, pp.bit() | fp.bit() | lr.bit());
1065 } else { 1068 } else {
1066 mov(sp, fp); 1069 mov(sp, fp);
1067 frame_ends = pc_offset(); 1070 frame_ends = pc_offset();
1068 ldm(ia_w, sp, fp.bit() | lr.bit()); 1071 ldm(ia_w, sp, fp.bit() | lr.bit());
1069 } 1072 }
1070 return frame_ends; 1073 return frame_ends;
1071 } 1074 }
1072 1075
1073 1076
1074 void MacroAssembler::EnterExitFrame(bool save_doubles, int stack_space) { 1077 void MacroAssembler::EnterExitFrame(bool save_doubles, int stack_space) {
1075 // Set up the frame structure on the stack. 1078 // Set up the frame structure on the stack.
1076 DCHECK_EQ(2 * kPointerSize, ExitFrameConstants::kCallerSPDisplacement); 1079 DCHECK_EQ(2 * kPointerSize, ExitFrameConstants::kCallerSPDisplacement);
1077 DCHECK_EQ(1 * kPointerSize, ExitFrameConstants::kCallerPCOffset); 1080 DCHECK_EQ(1 * kPointerSize, ExitFrameConstants::kCallerPCOffset);
1078 DCHECK_EQ(0 * kPointerSize, ExitFrameConstants::kCallerFPOffset); 1081 DCHECK_EQ(0 * kPointerSize, ExitFrameConstants::kCallerFPOffset);
1079 Push(lr, fp); 1082 Push(lr, fp);
1080 mov(fp, Operand(sp)); // Set up new frame pointer. 1083 mov(fp, Operand(sp)); // Set up new frame pointer.
1081 // Reserve room for saved entry sp and code object. 1084 // Reserve room for saved entry sp and code object.
1082 sub(sp, sp, Operand(ExitFrameConstants::kFrameSize)); 1085 sub(sp, sp, Operand(ExitFrameConstants::kFrameSize));
1083 if (emit_debug_code()) { 1086 if (emit_debug_code()) {
1084 mov(ip, Operand::Zero()); 1087 mov(ip, Operand::Zero());
1085 str(ip, MemOperand(fp, ExitFrameConstants::kSPOffset)); 1088 str(ip, MemOperand(fp, ExitFrameConstants::kSPOffset));
1086 } 1089 }
1087 if (FLAG_enable_ool_constant_pool) { 1090 if (FLAG_enable_embedded_constant_pool) {
1088 str(pp, MemOperand(fp, ExitFrameConstants::kConstantPoolOffset)); 1091 str(pp, MemOperand(fp, ExitFrameConstants::kConstantPoolOffset));
1089 } 1092 }
1090 mov(ip, Operand(CodeObject())); 1093 mov(ip, Operand(CodeObject()));
1091 str(ip, MemOperand(fp, ExitFrameConstants::kCodeOffset)); 1094 str(ip, MemOperand(fp, ExitFrameConstants::kCodeOffset));
1092 1095
1093 // Save the frame pointer and the context in top. 1096 // Save the frame pointer and the context in top.
1094 mov(ip, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); 1097 mov(ip, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate())));
1095 str(fp, MemOperand(ip)); 1098 str(fp, MemOperand(ip));
1096 mov(ip, Operand(ExternalReference(Isolate::kContextAddress, isolate()))); 1099 mov(ip, Operand(ExternalReference(Isolate::kContextAddress, isolate())));
1097 str(cp, MemOperand(ip)); 1100 str(cp, MemOperand(ip));
1098 1101
1099 // Optionally save all double registers. 1102 // Optionally save all double registers.
1100 if (save_doubles) { 1103 if (save_doubles) {
1101 SaveFPRegs(sp, ip); 1104 SaveFPRegs(sp, ip);
1102 // Note that d0 will be accessible at 1105 // Note that d0 will be accessible at
1103 // fp - ExitFrameConstants::kFrameSize - 1106 // fp - ExitFrameConstants::kFrameSize -
1104 // DwVfpRegister::kMaxNumRegisters * kDoubleSize, 1107 // DwVfpRegister::kMaxNumRegisters * kDoubleSize,
1105 // since the sp slot, code slot and constant pool slot (if 1108 // since the sp slot, code slot and constant pool slot (if
1106 // FLAG_enable_ool_constant_pool) were pushed after the fp. 1109 // FLAG_enable_embedded_constant_pool) were pushed after the fp.
1107 } 1110 }
1108 1111
1109 // Reserve place for the return address and stack space and align the frame 1112 // Reserve place for the return address and stack space and align the frame
1110 // preparing for calling the runtime function. 1113 // preparing for calling the runtime function.
1111 const int frame_alignment = MacroAssembler::ActivationFrameAlignment(); 1114 const int frame_alignment = MacroAssembler::ActivationFrameAlignment();
1112 sub(sp, sp, Operand((stack_space + 1) * kPointerSize)); 1115 sub(sp, sp, Operand((stack_space + 1) * kPointerSize));
1113 if (frame_alignment > 0) { 1116 if (frame_alignment > 0) {
1114 DCHECK(base::bits::IsPowerOfTwo32(frame_alignment)); 1117 DCHECK(base::bits::IsPowerOfTwo32(frame_alignment));
1115 and_(sp, sp, Operand(-frame_alignment)); 1118 and_(sp, sp, Operand(-frame_alignment));
1116 } 1119 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 if (restore_context) { 1179 if (restore_context) {
1177 mov(ip, Operand(ExternalReference(Isolate::kContextAddress, isolate()))); 1180 mov(ip, Operand(ExternalReference(Isolate::kContextAddress, isolate())));
1178 ldr(cp, MemOperand(ip)); 1181 ldr(cp, MemOperand(ip));
1179 } 1182 }
1180 #ifdef DEBUG 1183 #ifdef DEBUG
1181 mov(ip, Operand(ExternalReference(Isolate::kContextAddress, isolate()))); 1184 mov(ip, Operand(ExternalReference(Isolate::kContextAddress, isolate())));
1182 str(r3, MemOperand(ip)); 1185 str(r3, MemOperand(ip));
1183 #endif 1186 #endif
1184 1187
1185 // Tear down the exit frame, pop the arguments, and return. 1188 // Tear down the exit frame, pop the arguments, and return.
1186 if (FLAG_enable_ool_constant_pool) { 1189 if (FLAG_enable_embedded_constant_pool) {
1187 ldr(pp, MemOperand(fp, ExitFrameConstants::kConstantPoolOffset)); 1190 ldr(pp, MemOperand(fp, ExitFrameConstants::kConstantPoolOffset));
1188 } 1191 }
1189 mov(sp, Operand(fp)); 1192 mov(sp, Operand(fp));
1190 ldm(ia_w, sp, fp.bit() | lr.bit()); 1193 ldm(ia_w, sp, fp.bit() | lr.bit());
1191 if (argument_count.is_valid()) { 1194 if (argument_count.is_valid()) {
1192 if (argument_count_is_length) { 1195 if (argument_count_is_length) {
1193 add(sp, sp, argument_count); 1196 add(sp, sp, argument_count);
1194 } else { 1197 } else {
1195 add(sp, sp, Operand(argument_count, LSL, kPointerSizeLog2)); 1198 add(sp, sp, Operand(argument_count, LSL, kPointerSizeLog2));
1196 } 1199 }
(...skipping 2198 matching lines...) Expand 10 before | Expand all | Expand 10 after
3395 } 3398 }
3396 } 3399 }
3397 3400
3398 3401
3399 void MacroAssembler::GetRelocatedValueLocation(Register ldr_location, 3402 void MacroAssembler::GetRelocatedValueLocation(Register ldr_location,
3400 Register result, 3403 Register result,
3401 Register scratch) { 3404 Register scratch) {
3402 Label small_constant_pool_load, load_result; 3405 Label small_constant_pool_load, load_result;
3403 ldr(result, MemOperand(ldr_location)); 3406 ldr(result, MemOperand(ldr_location));
3404 3407
3405 if (FLAG_enable_ool_constant_pool) { 3408 if (FLAG_enable_embedded_constant_pool) {
3406 // Check if this is an extended constant pool load. 3409 // Check if this is an extended constant pool load.
3407 and_(scratch, result, Operand(GetConsantPoolLoadMask())); 3410 and_(scratch, result, Operand(GetConsantPoolLoadMask()));
3408 teq(scratch, Operand(GetConsantPoolLoadPattern())); 3411 teq(scratch, Operand(GetConsantPoolLoadPattern()));
3409 b(eq, &small_constant_pool_load); 3412 b(eq, &small_constant_pool_load);
3410 if (emit_debug_code()) { 3413 if (emit_debug_code()) {
3411 // Check that the instruction sequence is: 3414 // Check that the instruction sequence is:
3412 // movw reg, #offset_low 3415 // movw reg, #offset_low
3413 // movt reg, #offset_high 3416 // movt reg, #offset_high
3414 // ldr reg, [pp, reg] 3417 // ldr reg, [pp, reg]
3415 Instr patterns[] = {GetMovWPattern(), GetMovTPattern(), 3418 Instr patterns[] = {GetMovWPattern(), GetMovTPattern(),
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3449 // Result was clobbered. Restore it. 3452 // Result was clobbered. Restore it.
3450 ldr(result, MemOperand(ldr_location)); 3453 ldr(result, MemOperand(ldr_location));
3451 } 3454 }
3452 3455
3453 // Get the offset into the constant pool. 3456 // Get the offset into the constant pool.
3454 const uint32_t kLdrOffsetMask = (1 << 12) - 1; 3457 const uint32_t kLdrOffsetMask = (1 << 12) - 1;
3455 and_(result, result, Operand(kLdrOffsetMask)); 3458 and_(result, result, Operand(kLdrOffsetMask));
3456 3459
3457 bind(&load_result); 3460 bind(&load_result);
3458 // Get the address of the constant. 3461 // Get the address of the constant.
3459 if (FLAG_enable_ool_constant_pool) { 3462 if (FLAG_enable_embedded_constant_pool) {
3460 add(result, pp, Operand(result)); 3463 add(result, pp, Operand(result));
3461 } else { 3464 } else {
3462 add(result, ldr_location, Operand(result)); 3465 add(result, ldr_location, Operand(result));
3463 add(result, result, Operand(Instruction::kPCReadOffset)); 3466 add(result, result, Operand(Instruction::kPCReadOffset));
3464 } 3467 }
3465 } 3468 }
3466 3469
3467 3470
3468 void MacroAssembler::CheckPageFlag( 3471 void MacroAssembler::CheckPageFlag(
3469 Register object, 3472 Register object,
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
3909 } 3912 }
3910 } 3913 }
3911 if (mag.shift > 0) mov(result, Operand(result, ASR, mag.shift)); 3914 if (mag.shift > 0) mov(result, Operand(result, ASR, mag.shift));
3912 add(result, result, Operand(dividend, LSR, 31)); 3915 add(result, result, Operand(dividend, LSR, 31));
3913 } 3916 }
3914 3917
3915 } // namespace internal 3918 } // namespace internal
3916 } // namespace v8 3919 } // namespace v8
3917 3920
3918 #endif // V8_TARGET_ARCH_ARM 3921 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/macro-assembler-arm.h ('k') | src/arm64/assembler-arm64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698