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

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

Issue 7307004: Fix ABI for API calls on ia32. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: make it more portable Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 EnterApiExitFrame(argc + 2); 1422 EnterApiExitFrame(argc + 2);
1423 1423
1424 // The argument slots are filled as follows: 1424 // The argument slots are filled as follows:
1425 // 1425 //
1426 // n + 1: output cell 1426 // n + 1: output cell
1427 // n: arg n 1427 // n: arg n
1428 // ... 1428 // ...
1429 // 1: arg1 1429 // 1: arg1
1430 // 0: pointer to the output cell 1430 // 0: pointer to the output cell
1431 // 1431 //
1432 // Note that this is one more "argument" than the function expects
1433 // so the out cell will have to be popped explicitly after returning
1434 // from the function. The out cell contains Handle.
1435 1432
1436 // pointer to out cell. 1433 // pointer to out cell.
1437 lea(scratch, Operand(esp, (argc + 1) * kPointerSize)); 1434 lea(scratch, Operand(esp, (argc + 1) * kPointerSize));
1438 mov(Operand(esp, 0 * kPointerSize), scratch); // output. 1435 mov(Operand(esp, 0 * kPointerSize), scratch); // output.
1439 if (emit_debug_code()) { 1436 if (emit_debug_code()) {
1440 mov(Operand(esp, (argc + 1) * kPointerSize), Immediate(0)); // out cell. 1437 mov(Operand(esp, (argc + 1) * kPointerSize), Immediate(0)); // out cell.
1441 } 1438 }
1442 } 1439 }
1443 } 1440 }
1444 1441
1445 1442
1446 MaybeObject* MacroAssembler::TryCallApiFunctionAndReturn(ApiFunction* function, 1443 MaybeObject* MacroAssembler::TryCallApiFunctionAndReturn(ApiFunction* function,
1444 int argc,
1447 int stack_space) { 1445 int stack_space) {
1448 ExternalReference next_address = 1446 ExternalReference next_address =
1449 ExternalReference::handle_scope_next_address(); 1447 ExternalReference::handle_scope_next_address();
1450 ExternalReference limit_address = 1448 ExternalReference limit_address =
1451 ExternalReference::handle_scope_limit_address(); 1449 ExternalReference::handle_scope_limit_address();
1452 ExternalReference level_address = 1450 ExternalReference level_address =
1453 ExternalReference::handle_scope_level_address(); 1451 ExternalReference::handle_scope_level_address();
1454 1452
1453 // Save out slot address in the callee-save register.
Vitaly Repeshko 2011/07/04 22:41:36 Let's be consistent with "slot" vs. "cell" here in
Vyacheslav Egorov (Chromium) 2011/07/05 11:03:50 Done.
1454 if (!kReturnHandlesDirectly) {
1455 lea(esi, Operand(esp, (argc + 1) * kPointerSize));
Vitaly Repeshko 2011/07/04 22:41:36 This is tightly coupled to PrepareCallApiFunction.
Vyacheslav Egorov (Chromium) 2011/07/05 11:03:50 I though about that but did not want to prolong es
1456 }
1457
1455 // Allocate HandleScope in callee-save registers. 1458 // Allocate HandleScope in callee-save registers.
1456 mov(ebx, Operand::StaticVariable(next_address)); 1459 mov(ebx, Operand::StaticVariable(next_address));
1457 mov(edi, Operand::StaticVariable(limit_address)); 1460 mov(edi, Operand::StaticVariable(limit_address));
1458 add(Operand::StaticVariable(level_address), Immediate(1)); 1461 add(Operand::StaticVariable(level_address), Immediate(1));
1459 1462
1460 // Call the api function! 1463 // Call the api function!
1461 call(function->address(), RelocInfo::RUNTIME_ENTRY); 1464 call(function->address(), RelocInfo::RUNTIME_ENTRY);
1462 1465
1463 if (!kReturnHandlesDirectly) { 1466 if (!kReturnHandlesDirectly) {
1464 // The returned value is a pointer to the handle holding the result. 1467 mov(eax, Operand(esi, 0));
Vitaly Repeshko 2011/07/04 22:41:36 Some comment here would be helpful.
Vyacheslav Egorov (Chromium) 2011/07/05 11:03:50 Done.
1465 // Dereference this to get to the location.
1466 mov(eax, Operand(eax, 0));
1467 } 1468 }
1468 1469
1469 Label empty_handle; 1470 Label empty_handle;
1470 Label prologue; 1471 Label prologue;
1471 Label promote_scheduled_exception; 1472 Label promote_scheduled_exception;
1472 Label delete_allocated_handles; 1473 Label delete_allocated_handles;
1473 Label leave_exit_frame; 1474 Label leave_exit_frame;
1474 1475
1475 // Check if the result handle holds 0. 1476 // Check if the result handle holds 0.
1476 test(eax, Operand(eax)); 1477 test(eax, Operand(eax));
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
2131 2132
2132 // Check that the code was patched as expected. 2133 // Check that the code was patched as expected.
2133 ASSERT(masm_.pc_ == address_ + size_); 2134 ASSERT(masm_.pc_ == address_ + size_);
2134 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); 2135 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
2135 } 2136 }
2136 2137
2137 2138
2138 } } // namespace v8::internal 2139 } } // namespace v8::internal
2139 2140
2140 #endif // V8_TARGET_ARCH_IA32 2141 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698