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 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 | 1291 |
1292 | 1292 |
1293 void MacroAssembler::InvokeFunction(Register fun, | 1293 void MacroAssembler::InvokeFunction(Register fun, |
1294 const ParameterCount& actual, | 1294 const ParameterCount& actual, |
1295 InvokeFlag flag) { | 1295 InvokeFlag flag) { |
1296 ASSERT(fun.is(edi)); | 1296 ASSERT(fun.is(edi)); |
1297 mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | 1297 mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
1298 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); | 1298 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); |
1299 mov(ebx, FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset)); | 1299 mov(ebx, FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset)); |
1300 SmiUntag(ebx); | 1300 SmiUntag(ebx); |
1301 mov(edx, FieldOperand(edi, JSFunction::kCodeOffset)); | |
1302 lea(edx, FieldOperand(edx, Code::kHeaderSize)); | |
1303 | 1301 |
1304 ParameterCount expected(ebx); | 1302 ParameterCount expected(ebx); |
1305 InvokeCode(Operand(edx), expected, actual, flag); | 1303 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), |
| 1304 expected, actual, flag); |
1306 } | 1305 } |
1307 | 1306 |
1308 | 1307 |
1309 void MacroAssembler::InvokeFunction(JSFunction* function, | 1308 void MacroAssembler::InvokeFunction(JSFunction* function, |
1310 const ParameterCount& actual, | 1309 const ParameterCount& actual, |
1311 InvokeFlag flag) { | 1310 InvokeFlag flag) { |
1312 ASSERT(function->is_compiled()); | 1311 ASSERT(function->is_compiled()); |
1313 // Get the function and setup the context. | 1312 // Get the function and setup the context. |
1314 mov(edi, Immediate(Handle<JSFunction>(function))); | 1313 mov(edi, Immediate(Handle<JSFunction>(function))); |
1315 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); | 1314 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); |
1316 | |
1317 // Invoke the cached code. | 1315 // Invoke the cached code. |
1318 Handle<Code> code(function->code()); | 1316 Handle<Code> code(function->code()); |
1319 ParameterCount expected(function->shared()->formal_parameter_count()); | 1317 ParameterCount expected(function->shared()->formal_parameter_count()); |
1320 InvokeCode(code, expected, actual, RelocInfo::CODE_TARGET, flag); | 1318 InvokeCode(code, expected, actual, RelocInfo::CODE_TARGET, flag); |
1321 } | 1319 } |
1322 | 1320 |
1323 | 1321 |
1324 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, InvokeFlag flag) { | 1322 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, InvokeFlag flag) { |
1325 // Calls are not allowed in some stubs. | 1323 // Calls are not allowed in some stubs. |
1326 ASSERT(flag == JUMP_FUNCTION || allow_stub_calls()); | 1324 ASSERT(flag == JUMP_FUNCTION || allow_stub_calls()); |
1327 | 1325 |
1328 // Rely on the assertion to check that the number of provided | 1326 // Rely on the assertion to check that the number of provided |
1329 // arguments match the expected number of arguments. Fake a | 1327 // arguments match the expected number of arguments. Fake a |
1330 // parameter count to avoid emitting code to do the check. | 1328 // parameter count to avoid emitting code to do the check. |
1331 ParameterCount expected(0); | 1329 ParameterCount expected(0); |
1332 GetBuiltinEntry(edx, id); | 1330 GetBuiltinFunction(edi, id); |
1333 InvokeCode(Operand(edx), expected, expected, flag); | 1331 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), |
| 1332 expected, expected, flag); |
| 1333 } |
| 1334 |
| 1335 void MacroAssembler::GetBuiltinFunction(Register target, |
| 1336 Builtins::JavaScript id) { |
| 1337 // Load the JavaScript builtin function from the builtins object. |
| 1338 mov(target, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 1339 mov(target, FieldOperand(target, GlobalObject::kBuiltinsOffset)); |
| 1340 mov(target, FieldOperand(target, |
| 1341 JSBuiltinsObject::OffsetOfFunctionWithId(id))); |
| 1342 } |
| 1343 |
| 1344 void MacroAssembler::GetBuiltinEntry(Register target, Builtins::JavaScript id) { |
| 1345 ASSERT(!target.is(edi)); |
| 1346 // Load the JavaScript builtin function from the builtins object. |
| 1347 GetBuiltinFunction(edi, id); |
| 1348 // Load the code entry point from the function into the target register. |
| 1349 mov(target, FieldOperand(edi, JSFunction::kCodeEntryOffset)); |
1334 } | 1350 } |
1335 | 1351 |
1336 | 1352 |
1337 void MacroAssembler::GetBuiltinEntry(Register target, Builtins::JavaScript id) { | |
1338 ASSERT(!target.is(edi)); | |
1339 | |
1340 // Load the builtins object into target register. | |
1341 mov(target, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); | |
1342 mov(target, FieldOperand(target, GlobalObject::kBuiltinsOffset)); | |
1343 | |
1344 // Load the JavaScript builtin function from the builtins object. | |
1345 mov(edi, FieldOperand(target, JSBuiltinsObject::OffsetOfFunctionWithId(id))); | |
1346 | |
1347 // Load the code entry point from the builtins object. | |
1348 mov(target, FieldOperand(target, JSBuiltinsObject::OffsetOfCodeWithId(id))); | |
1349 if (FLAG_debug_code) { | |
1350 // Make sure the code objects in the builtins object and in the | |
1351 // builtin function are the same. | |
1352 push(target); | |
1353 mov(target, FieldOperand(edi, JSFunction::kCodeOffset)); | |
1354 cmp(target, Operand(esp, 0)); | |
1355 Assert(equal, "Builtin code object changed"); | |
1356 pop(target); | |
1357 } | |
1358 lea(target, FieldOperand(target, Code::kHeaderSize)); | |
1359 } | |
1360 | |
1361 | |
1362 void MacroAssembler::LoadContext(Register dst, int context_chain_length) { | 1353 void MacroAssembler::LoadContext(Register dst, int context_chain_length) { |
1363 if (context_chain_length > 0) { | 1354 if (context_chain_length > 0) { |
1364 // Move up the chain of contexts to the context containing the slot. | 1355 // Move up the chain of contexts to the context containing the slot. |
1365 mov(dst, Operand(esi, Context::SlotOffset(Context::CLOSURE_INDEX))); | 1356 mov(dst, Operand(esi, Context::SlotOffset(Context::CLOSURE_INDEX))); |
1366 // Load the function context (which is the incoming, outer context). | 1357 // Load the function context (which is the incoming, outer context). |
1367 mov(dst, FieldOperand(dst, JSFunction::kContextOffset)); | 1358 mov(dst, FieldOperand(dst, JSFunction::kContextOffset)); |
1368 for (int i = 1; i < context_chain_length; i++) { | 1359 for (int i = 1; i < context_chain_length; i++) { |
1369 mov(dst, Operand(dst, Context::SlotOffset(Context::CLOSURE_INDEX))); | 1360 mov(dst, Operand(dst, Context::SlotOffset(Context::CLOSURE_INDEX))); |
1370 mov(dst, FieldOperand(dst, JSFunction::kContextOffset)); | 1361 mov(dst, FieldOperand(dst, JSFunction::kContextOffset)); |
1371 } | 1362 } |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1684 | 1675 |
1685 // Check that the code was patched as expected. | 1676 // Check that the code was patched as expected. |
1686 ASSERT(masm_.pc_ == address_ + size_); | 1677 ASSERT(masm_.pc_ == address_ + size_); |
1687 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 1678 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
1688 } | 1679 } |
1689 | 1680 |
1690 | 1681 |
1691 } } // namespace v8::internal | 1682 } } // namespace v8::internal |
1692 | 1683 |
1693 #endif // V8_TARGET_ARCH_IA32 | 1684 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |