Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 19 matching lines...) Expand all Loading... | |
| 30 #include "bootstrapper.h" | 30 #include "bootstrapper.h" |
| 31 #include "codegen-inl.h" | 31 #include "codegen-inl.h" |
| 32 #include "debug.h" | 32 #include "debug.h" |
| 33 #include "runtime.h" | 33 #include "runtime.h" |
| 34 | 34 |
| 35 namespace v8 { | 35 namespace v8 { |
| 36 namespace internal { | 36 namespace internal { |
| 37 | 37 |
| 38 MacroAssembler::MacroAssembler(void* buffer, int size) | 38 MacroAssembler::MacroAssembler(void* buffer, int size) |
| 39 : Assembler(buffer, size), | 39 : Assembler(buffer, size), |
| 40 unresolved_(0), | |
| 41 generating_stub_(false), | 40 generating_stub_(false), |
| 42 allow_stub_calls_(true), | 41 allow_stub_calls_(true), |
| 43 code_object_(Heap::undefined_value()) { | 42 code_object_(Heap::undefined_value()) { |
| 44 } | 43 } |
| 45 | 44 |
| 46 | 45 |
| 47 // We always generate arm code, never thumb code, even if V8 is compiled to | 46 // We always generate arm code, never thumb code, even if V8 is compiled to |
| 48 // thumb, so we require inter-working support | 47 // thumb, so we require inter-working support |
| 49 #if defined(__thumb__) && !defined(USE_THUMB_INTERWORK) | 48 #if defined(__thumb__) && !defined(USE_THUMB_INTERWORK) |
| 50 #error "flag -mthumb-interwork missing" | 49 #error "flag -mthumb-interwork missing" |
| (...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1226 #if defined(__thumb__) | 1225 #if defined(__thumb__) |
| 1227 // Thumb mode builtin. | 1226 // Thumb mode builtin. |
| 1228 ASSERT((reinterpret_cast<intptr_t>(builtin.address()) & 1) == 1); | 1227 ASSERT((reinterpret_cast<intptr_t>(builtin.address()) & 1) == 1); |
| 1229 #endif | 1228 #endif |
| 1230 mov(r1, Operand(builtin)); | 1229 mov(r1, Operand(builtin)); |
| 1231 CEntryStub stub(1); | 1230 CEntryStub stub(1); |
| 1232 Jump(stub.GetCode(), RelocInfo::CODE_TARGET); | 1231 Jump(stub.GetCode(), RelocInfo::CODE_TARGET); |
| 1233 } | 1232 } |
| 1234 | 1233 |
| 1235 | 1234 |
| 1236 Handle<Code> MacroAssembler::ResolveBuiltin(Builtins::JavaScript id, | |
| 1237 bool* resolved) { | |
| 1238 // Contract with compiled functions is that the function is passed in r1. | |
| 1239 int builtins_offset = | |
| 1240 JSBuiltinsObject::kJSBuiltinsOffset + (id * kPointerSize); | |
| 1241 ldr(r1, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX))); | |
| 1242 ldr(r1, FieldMemOperand(r1, GlobalObject::kBuiltinsOffset)); | |
| 1243 ldr(r1, FieldMemOperand(r1, builtins_offset)); | |
| 1244 | |
| 1245 return Builtins::GetCode(id, resolved); | |
| 1246 } | |
| 1247 | |
| 1248 | |
| 1249 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, | 1235 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, |
| 1250 InvokeJSFlags flags) { | 1236 InvokeJSFlags flags) { |
| 1251 bool resolved; | 1237 GetBuiltinEntry(r2, id); |
| 1252 Handle<Code> code = ResolveBuiltin(id, &resolved); | |
| 1253 | |
| 1254 if (flags == CALL_JS) { | 1238 if (flags == CALL_JS) { |
| 1255 Call(code, RelocInfo::CODE_TARGET); | 1239 Call(r2); |
| 1256 } else { | 1240 } else { |
| 1257 ASSERT(flags == JUMP_JS); | 1241 ASSERT(flags == JUMP_JS); |
| 1258 Jump(code, RelocInfo::CODE_TARGET); | 1242 Jump(r2); |
| 1259 } | |
| 1260 | |
| 1261 if (!resolved) { | |
| 1262 const char* name = Builtins::GetName(id); | |
| 1263 int argc = Builtins::GetArgumentsCount(id); | |
| 1264 uint32_t flags = | |
| 1265 Bootstrapper::FixupFlagsArgumentsCount::encode(argc) | | |
| 1266 Bootstrapper::FixupFlagsUseCodeObject::encode(false); | |
| 1267 Unresolved entry = { pc_offset() - kInstrSize, flags, name }; | |
| 1268 unresolved_.Add(entry); | |
| 1269 } | 1243 } |
| 1270 } | 1244 } |
| 1271 | 1245 |
| 1272 | 1246 |
| 1273 void MacroAssembler::GetBuiltinEntry(Register target, Builtins::JavaScript id) { | 1247 void MacroAssembler::GetBuiltinEntry(Register target, Builtins::JavaScript id) { |
| 1274 bool resolved; | 1248 // Load the JavaScript builtin function from the builtins object |
| 1275 Handle<Code> code = ResolveBuiltin(id, &resolved); | 1249 // using the target register as a scratch register. |
| 1276 | 1250 ldr(target, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 1277 mov(target, Operand(code)); | 1251 ldr(target, FieldMemOperand(target, GlobalObject::kBuiltinsOffset)); |
| 1278 if (!resolved) { | 1252 int builtins_offset = |
| 1279 const char* name = Builtins::GetName(id); | 1253 JSBuiltinsObject::kJSBuiltinsOffset + (id * kPointerSize); |
| 1280 int argc = Builtins::GetArgumentsCount(id); | 1254 ldr(r1, FieldMemOperand(target, builtins_offset)); |
|
Erik Corry
2010/02/10 17:22:49
Seems like you might as well just use r1 throughou
Mads Ager (chromium)
2010/02/11 07:58:30
Yes, done on all platforms.
| |
| 1281 uint32_t flags = | 1255 // Load the code entry point from the function into the target register. |
| 1282 Bootstrapper::FixupFlagsArgumentsCount::encode(argc) | | 1256 ldr(target, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); |
| 1283 Bootstrapper::FixupFlagsUseCodeObject::encode(true); | 1257 ldr(target, FieldMemOperand(target, SharedFunctionInfo::kCodeOffset)); |
|
Erik Corry
2010/02/10 17:22:49
A chain of 5 dependent loads! If this turns out t
| |
| 1284 Unresolved entry = { pc_offset() - kInstrSize, flags, name }; | |
| 1285 unresolved_.Add(entry); | |
| 1286 } | |
| 1287 | |
| 1288 add(target, target, Operand(Code::kHeaderSize - kHeapObjectTag)); | 1258 add(target, target, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 1289 } | 1259 } |
| 1290 | 1260 |
| 1291 | 1261 |
| 1292 void MacroAssembler::SetCounter(StatsCounter* counter, int value, | 1262 void MacroAssembler::SetCounter(StatsCounter* counter, int value, |
| 1293 Register scratch1, Register scratch2) { | 1263 Register scratch1, Register scratch2) { |
| 1294 if (FLAG_native_code_counters && counter->Enabled()) { | 1264 if (FLAG_native_code_counters && counter->Enabled()) { |
| 1295 mov(scratch1, Operand(value)); | 1265 mov(scratch1, Operand(value)); |
| 1296 mov(scratch2, Operand(ExternalReference(counter))); | 1266 mov(scratch2, Operand(ExternalReference(counter))); |
| 1297 str(scratch1, MemOperand(scratch2)); | 1267 str(scratch1, MemOperand(scratch2)); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1473 } | 1443 } |
| 1474 | 1444 |
| 1475 | 1445 |
| 1476 void CodePatcher::Emit(Address addr) { | 1446 void CodePatcher::Emit(Address addr) { |
| 1477 masm()->emit(reinterpret_cast<Instr>(addr)); | 1447 masm()->emit(reinterpret_cast<Instr>(addr)); |
| 1478 } | 1448 } |
| 1479 #endif // ENABLE_DEBUGGER_SUPPORT | 1449 #endif // ENABLE_DEBUGGER_SUPPORT |
| 1480 | 1450 |
| 1481 | 1451 |
| 1482 } } // namespace v8::internal | 1452 } } // namespace v8::internal |
| OLD | NEW |