| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 } | 226 } |
| 227 | 227 |
| 228 | 228 |
| 229 void MacroAssembler::Push(Handle<Object> handle) { | 229 void MacroAssembler::Push(Handle<Object> handle) { |
| 230 mov(ip, Operand(handle)); | 230 mov(ip, Operand(handle)); |
| 231 push(ip); | 231 push(ip); |
| 232 } | 232 } |
| 233 | 233 |
| 234 | 234 |
| 235 void MacroAssembler::Move(Register dst, Handle<Object> value) { | 235 void MacroAssembler::Move(Register dst, Handle<Object> value) { |
| 236 mov(dst, Operand(value)); | 236 AllowDeferredHandleDereference smi_check; |
| 237 if (value->IsSmi()) { |
| 238 mov(dst, Operand(value)); |
| 239 } else { |
| 240 ASSERT(value->IsHeapObject()); |
| 241 if (isolate()->heap()->InNewSpace(*value)) { |
| 242 Handle<Cell> cell = isolate()->factory()->NewCell(value); |
| 243 mov(dst, Operand(cell)); |
| 244 ldr(dst, FieldMemOperand(dst, Cell::kValueOffset)); |
| 245 } else { |
| 246 mov(dst, Operand(value)); |
| 247 } |
| 248 } |
| 237 } | 249 } |
| 238 | 250 |
| 239 | 251 |
| 240 void MacroAssembler::Move(Register dst, Register src, Condition cond) { | 252 void MacroAssembler::Move(Register dst, Register src, Condition cond) { |
| 241 if (!dst.is(src)) { | 253 if (!dst.is(src)) { |
| 242 mov(dst, src, LeaveCC, cond); | 254 mov(dst, src, LeaveCC, cond); |
| 243 } | 255 } |
| 244 } | 256 } |
| 245 | 257 |
| 246 | 258 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 } | 399 } |
| 388 | 400 |
| 389 | 401 |
| 390 void MacroAssembler::StoreRoot(Register source, | 402 void MacroAssembler::StoreRoot(Register source, |
| 391 Heap::RootListIndex index, | 403 Heap::RootListIndex index, |
| 392 Condition cond) { | 404 Condition cond) { |
| 393 str(source, MemOperand(kRootRegister, index << kPointerSizeLog2), cond); | 405 str(source, MemOperand(kRootRegister, index << kPointerSizeLog2), cond); |
| 394 } | 406 } |
| 395 | 407 |
| 396 | 408 |
| 397 void MacroAssembler::LoadHeapObject(Register result, | |
| 398 Handle<HeapObject> object) { | |
| 399 AllowDeferredHandleDereference using_raw_address; | |
| 400 if (isolate()->heap()->InNewSpace(*object)) { | |
| 401 Handle<Cell> cell = isolate()->factory()->NewCell(object); | |
| 402 mov(result, Operand(cell)); | |
| 403 ldr(result, FieldMemOperand(result, Cell::kValueOffset)); | |
| 404 } else { | |
| 405 mov(result, Operand(object)); | |
| 406 } | |
| 407 } | |
| 408 | |
| 409 | |
| 410 void MacroAssembler::InNewSpace(Register object, | 409 void MacroAssembler::InNewSpace(Register object, |
| 411 Register scratch, | 410 Register scratch, |
| 412 Condition cond, | 411 Condition cond, |
| 413 Label* branch) { | 412 Label* branch) { |
| 414 ASSERT(cond == eq || cond == ne); | 413 ASSERT(cond == eq || cond == ne); |
| 415 and_(scratch, object, Operand(ExternalReference::new_space_mask(isolate()))); | 414 and_(scratch, object, Operand(ExternalReference::new_space_mask(isolate()))); |
| 416 cmp(scratch, Operand(ExternalReference::new_space_start(isolate()))); | 415 cmp(scratch, Operand(ExternalReference::new_space_start(isolate()))); |
| 417 b(cond, branch); | 416 b(cond, branch); |
| 418 } | 417 } |
| 419 | 418 |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 CompareRoot(object, Heap::kUndefinedValueRootIndex); | 908 CompareRoot(object, Heap::kUndefinedValueRootIndex); |
| 910 b(ne, not_int32); | 909 b(ne, not_int32); |
| 911 // |undefined| is truncated to 0. | 910 // |undefined| is truncated to 0. |
| 912 mov(dst, Operand(Smi::FromInt(0))); | 911 mov(dst, Operand(Smi::FromInt(0))); |
| 913 // Fall through. | 912 // Fall through. |
| 914 | 913 |
| 915 bind(&done); | 914 bind(&done); |
| 916 } | 915 } |
| 917 | 916 |
| 918 | 917 |
| 918 void MacroAssembler::Prologue(PrologueFrameMode frame_mode) { |
| 919 if (frame_mode == BUILD_STUB_FRAME) { |
| 920 stm(db_w, sp, cp.bit() | fp.bit() | lr.bit()); |
| 921 Push(Smi::FromInt(StackFrame::STUB)); |
| 922 // Adjust FP to point to saved FP. |
| 923 add(fp, sp, Operand(2 * kPointerSize)); |
| 924 } else { |
| 925 PredictableCodeSizeScope predictible_code_size_scope( |
| 926 this, kNoCodeAgeSequenceLength * Assembler::kInstrSize); |
| 927 // The following three instructions must remain together and unmodified |
| 928 // for code aging to work properly. |
| 929 if (FLAG_optimize_for_size && FLAG_age_code) { |
| 930 // Pre-age the code. |
| 931 Code* stub = Code::GetPreAgedCodeAgeStub(isolate()); |
| 932 add(r0, pc, Operand(-8)); |
| 933 ldr(pc, MemOperand(pc, -4)); |
| 934 dd(reinterpret_cast<uint32_t>(stub->instruction_start())); |
| 935 } else { |
| 936 stm(db_w, sp, r1.bit() | cp.bit() | fp.bit() | lr.bit()); |
| 937 nop(ip.code()); |
| 938 // Adjust FP to point to saved FP. |
| 939 add(fp, sp, Operand(2 * kPointerSize)); |
| 940 } |
| 941 } |
| 942 } |
| 943 |
| 944 |
| 919 void MacroAssembler::EnterFrame(StackFrame::Type type) { | 945 void MacroAssembler::EnterFrame(StackFrame::Type type) { |
| 920 // r0-r3: preserved | 946 // r0-r3: preserved |
| 921 stm(db_w, sp, cp.bit() | fp.bit() | lr.bit()); | 947 stm(db_w, sp, cp.bit() | fp.bit() | lr.bit()); |
| 922 mov(ip, Operand(Smi::FromInt(type))); | 948 mov(ip, Operand(Smi::FromInt(type))); |
| 923 push(ip); | 949 push(ip); |
| 924 mov(ip, Operand(CodeObject())); | 950 mov(ip, Operand(CodeObject())); |
| 925 push(ip); | 951 push(ip); |
| 926 add(fp, sp, Operand(3 * kPointerSize)); // Adjust FP to point to saved FP. | 952 add(fp, sp, Operand(3 * kPointerSize)); // Adjust FP to point to saved FP. |
| 927 } | 953 } |
| 928 | 954 |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1251 void MacroAssembler::InvokeFunction(Handle<JSFunction> function, | 1277 void MacroAssembler::InvokeFunction(Handle<JSFunction> function, |
| 1252 const ParameterCount& expected, | 1278 const ParameterCount& expected, |
| 1253 const ParameterCount& actual, | 1279 const ParameterCount& actual, |
| 1254 InvokeFlag flag, | 1280 InvokeFlag flag, |
| 1255 const CallWrapper& call_wrapper, | 1281 const CallWrapper& call_wrapper, |
| 1256 CallKind call_kind) { | 1282 CallKind call_kind) { |
| 1257 // You can't call a function without a valid frame. | 1283 // You can't call a function without a valid frame. |
| 1258 ASSERT(flag == JUMP_FUNCTION || has_frame()); | 1284 ASSERT(flag == JUMP_FUNCTION || has_frame()); |
| 1259 | 1285 |
| 1260 // Get the function and setup the context. | 1286 // Get the function and setup the context. |
| 1261 LoadHeapObject(r1, function); | 1287 Move(r1, function); |
| 1262 ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); | 1288 ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); |
| 1263 | 1289 |
| 1264 // We call indirectly through the code field in the function to | 1290 // We call indirectly through the code field in the function to |
| 1265 // allow recompilation to take effect without changing any of the | 1291 // allow recompilation to take effect without changing any of the |
| 1266 // call sites. | 1292 // call sites. |
| 1267 ldr(r3, FieldMemOperand(r1, JSFunction::kCodeEntryOffset)); | 1293 ldr(r3, FieldMemOperand(r1, JSFunction::kCodeEntryOffset)); |
| 1268 InvokeCode(r3, expected, actual, flag, call_wrapper, call_kind); | 1294 InvokeCode(r3, expected, actual, flag, call_wrapper, call_kind); |
| 1269 } | 1295 } |
| 1270 | 1296 |
| 1271 | 1297 |
| (...skipping 2579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3851 b(ne, call_runtime); | 3877 b(ne, call_runtime); |
| 3852 | 3878 |
| 3853 ldr(r2, FieldMemOperand(r1, Map::kPrototypeOffset)); | 3879 ldr(r2, FieldMemOperand(r1, Map::kPrototypeOffset)); |
| 3854 cmp(r2, null_value); | 3880 cmp(r2, null_value); |
| 3855 b(ne, &next); | 3881 b(ne, &next); |
| 3856 } | 3882 } |
| 3857 | 3883 |
| 3858 | 3884 |
| 3859 void MacroAssembler::TestJSArrayForAllocationMemento( | 3885 void MacroAssembler::TestJSArrayForAllocationMemento( |
| 3860 Register receiver_reg, | 3886 Register receiver_reg, |
| 3861 Register scratch_reg) { | 3887 Register scratch_reg, |
| 3862 Label no_memento_available; | 3888 Label* no_memento_found) { |
| 3863 ExternalReference new_space_start = | 3889 ExternalReference new_space_start = |
| 3864 ExternalReference::new_space_start(isolate()); | 3890 ExternalReference::new_space_start(isolate()); |
| 3865 ExternalReference new_space_allocation_top = | 3891 ExternalReference new_space_allocation_top = |
| 3866 ExternalReference::new_space_allocation_top_address(isolate()); | 3892 ExternalReference::new_space_allocation_top_address(isolate()); |
| 3867 add(scratch_reg, receiver_reg, | 3893 add(scratch_reg, receiver_reg, |
| 3868 Operand(JSArray::kSize + AllocationMemento::kSize - kHeapObjectTag)); | 3894 Operand(JSArray::kSize + AllocationMemento::kSize - kHeapObjectTag)); |
| 3869 cmp(scratch_reg, Operand(new_space_start)); | 3895 cmp(scratch_reg, Operand(new_space_start)); |
| 3870 b(lt, &no_memento_available); | 3896 b(lt, no_memento_found); |
| 3871 mov(ip, Operand(new_space_allocation_top)); | 3897 mov(ip, Operand(new_space_allocation_top)); |
| 3872 ldr(ip, MemOperand(ip)); | 3898 ldr(ip, MemOperand(ip)); |
| 3873 cmp(scratch_reg, ip); | 3899 cmp(scratch_reg, ip); |
| 3874 b(gt, &no_memento_available); | 3900 b(gt, no_memento_found); |
| 3875 ldr(scratch_reg, MemOperand(scratch_reg, -AllocationMemento::kSize)); | 3901 ldr(scratch_reg, MemOperand(scratch_reg, -AllocationMemento::kSize)); |
| 3876 cmp(scratch_reg, | 3902 cmp(scratch_reg, |
| 3877 Operand(isolate()->factory()->allocation_memento_map())); | 3903 Operand(isolate()->factory()->allocation_memento_map())); |
| 3878 bind(&no_memento_available); | |
| 3879 } | 3904 } |
| 3880 | 3905 |
| 3881 | 3906 |
| 3882 Register GetRegisterThatIsNotOneOf(Register reg1, | 3907 Register GetRegisterThatIsNotOneOf(Register reg1, |
| 3883 Register reg2, | 3908 Register reg2, |
| 3884 Register reg3, | 3909 Register reg3, |
| 3885 Register reg4, | 3910 Register reg4, |
| 3886 Register reg5, | 3911 Register reg5, |
| 3887 Register reg6) { | 3912 Register reg6) { |
| 3888 RegList regs = 0; | 3913 RegList regs = 0; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3966 void CodePatcher::EmitCondition(Condition cond) { | 3991 void CodePatcher::EmitCondition(Condition cond) { |
| 3967 Instr instr = Assembler::instr_at(masm_.pc_); | 3992 Instr instr = Assembler::instr_at(masm_.pc_); |
| 3968 instr = (instr & ~kCondMask) | cond; | 3993 instr = (instr & ~kCondMask) | cond; |
| 3969 masm_.emit(instr); | 3994 masm_.emit(instr); |
| 3970 } | 3995 } |
| 3971 | 3996 |
| 3972 | 3997 |
| 3973 } } // namespace v8::internal | 3998 } } // namespace v8::internal |
| 3974 | 3999 |
| 3975 #endif // V8_TARGET_ARCH_ARM | 4000 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |