OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1209 | 1209 |
1210 | 1210 |
1211 MaybeObject* MacroAssembler::TryTailCallRuntime(Runtime::FunctionId fid, | 1211 MaybeObject* MacroAssembler::TryTailCallRuntime(Runtime::FunctionId fid, |
1212 int num_arguments, | 1212 int num_arguments, |
1213 int result_size) { | 1213 int result_size) { |
1214 return TryTailCallExternalReference( | 1214 return TryTailCallExternalReference( |
1215 ExternalReference(fid), num_arguments, result_size); | 1215 ExternalReference(fid), num_arguments, result_size); |
1216 } | 1216 } |
1217 | 1217 |
1218 | 1218 |
1219 // If true, a Handle<T> returned by value from a function with cdecl calling | 1219 // If true, a Handle<T> passed by value is passed and returned by |
1220 // convention will be returned directly as a value of location_ field in a | 1220 // using the location_ field directly. If false, it is passed and |
1221 // register eax. | 1221 // returned as a pointer to a handle. |
1222 // If false, it is returned as a pointer to a preallocated by caller memory | 1222 #ifdef USING_BSD_ABI |
1223 // region. Pointer to this region should be passed to a function as an | 1223 static const bool kPassHandlesDirectly = true; |
1224 // implicit first argument. | |
1225 #if defined(USING_BSD_ABI) || defined(__MINGW32__) | |
1226 static const bool kReturnHandlesDirectly = true; | |
1227 #else | 1224 #else |
1228 static const bool kReturnHandlesDirectly = false; | 1225 static const bool kPassHandlesDirectly = false; |
1229 #endif | 1226 #endif |
1230 | 1227 |
1231 | 1228 |
1232 Operand ApiParameterOperand(int index) { | 1229 Operand ApiParameterOperand(int index) { |
1233 return Operand( | 1230 return Operand(esp, (index + (kPassHandlesDirectly ? 0 : 1)) * kPointerSize); |
1234 esp, (index + (kReturnHandlesDirectly ? 0 : 1)) * kPointerSize); | |
1235 } | 1231 } |
1236 | 1232 |
1237 | 1233 |
1238 void MacroAssembler::PrepareCallApiFunction(int argc, Register scratch) { | 1234 void MacroAssembler::PrepareCallApiFunction(int argc, Register scratch) { |
1239 if (kReturnHandlesDirectly) { | 1235 if (kPassHandlesDirectly) { |
1240 EnterApiExitFrame(argc); | 1236 EnterApiExitFrame(argc); |
1241 // When handles are returned directly we don't have to allocate extra | 1237 // When handles as passed directly we don't have to allocate extra |
1242 // space for and pass an out parameter. | 1238 // space for and pass an out parameter. |
1243 } else { | 1239 } else { |
1244 // We allocate two additional slots: return value and pointer to it. | 1240 // We allocate two additional slots: return value and pointer to it. |
1245 EnterApiExitFrame(argc + 2); | 1241 EnterApiExitFrame(argc + 2); |
1246 | 1242 |
1247 // The argument slots are filled as follows: | 1243 // The argument slots are filled as follows: |
1248 // | 1244 // |
1249 // n + 1: output cell | 1245 // n + 1: output cell |
1250 // n: arg n | 1246 // n: arg n |
1251 // ... | 1247 // ... |
(...skipping 24 matching lines...) Expand all Loading... |
1276 ExternalReference::handle_scope_level_address(); | 1272 ExternalReference::handle_scope_level_address(); |
1277 | 1273 |
1278 // Allocate HandleScope in callee-save registers. | 1274 // Allocate HandleScope in callee-save registers. |
1279 mov(ebx, Operand::StaticVariable(next_address)); | 1275 mov(ebx, Operand::StaticVariable(next_address)); |
1280 mov(edi, Operand::StaticVariable(limit_address)); | 1276 mov(edi, Operand::StaticVariable(limit_address)); |
1281 add(Operand::StaticVariable(level_address), Immediate(1)); | 1277 add(Operand::StaticVariable(level_address), Immediate(1)); |
1282 | 1278 |
1283 // Call the api function! | 1279 // Call the api function! |
1284 call(function->address(), RelocInfo::RUNTIME_ENTRY); | 1280 call(function->address(), RelocInfo::RUNTIME_ENTRY); |
1285 | 1281 |
1286 if (!kReturnHandlesDirectly) { | 1282 if (!kPassHandlesDirectly) { |
1287 // The returned value is a pointer to the handle holding the result. | 1283 // The returned value is a pointer to the handle holding the result. |
1288 // Dereference this to get to the location. | 1284 // Dereference this to get to the location. |
1289 mov(eax, Operand(eax, 0)); | 1285 mov(eax, Operand(eax, 0)); |
1290 } | 1286 } |
1291 | 1287 |
1292 Label empty_handle; | 1288 Label empty_handle; |
1293 Label prologue; | 1289 Label prologue; |
1294 Label promote_scheduled_exception; | 1290 Label promote_scheduled_exception; |
1295 Label delete_allocated_handles; | 1291 Label delete_allocated_handles; |
1296 Label leave_exit_frame; | 1292 Label leave_exit_frame; |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1915 | 1911 |
1916 // Check that the code was patched as expected. | 1912 // Check that the code was patched as expected. |
1917 ASSERT(masm_.pc_ == address_ + size_); | 1913 ASSERT(masm_.pc_ == address_ + size_); |
1918 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 1914 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
1919 } | 1915 } |
1920 | 1916 |
1921 | 1917 |
1922 } } // namespace v8::internal | 1918 } } // namespace v8::internal |
1923 | 1919 |
1924 #endif // V8_TARGET_ARCH_IA32 | 1920 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |