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

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

Issue 6893156: Unified CallWrapper and PostCallGenerator classes, the former is a (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 7 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
« no previous file with comments | « src/ia32/macro-assembler-ia32.h ('k') | src/mips/macro-assembler-mips.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 return TryTailCallStub(&ces); 1428 return TryTailCallStub(&ces);
1429 } 1429 }
1430 1430
1431 1431
1432 void MacroAssembler::InvokePrologue(const ParameterCount& expected, 1432 void MacroAssembler::InvokePrologue(const ParameterCount& expected,
1433 const ParameterCount& actual, 1433 const ParameterCount& actual,
1434 Handle<Code> code_constant, 1434 Handle<Code> code_constant,
1435 const Operand& code_operand, 1435 const Operand& code_operand,
1436 NearLabel* done, 1436 NearLabel* done,
1437 InvokeFlag flag, 1437 InvokeFlag flag,
1438 PostCallGenerator* post_call_generator) { 1438 CallWrapper* call_wrapper) {
1439 bool definitely_matches = false; 1439 bool definitely_matches = false;
1440 Label invoke; 1440 Label invoke;
1441 if (expected.is_immediate()) { 1441 if (expected.is_immediate()) {
1442 ASSERT(actual.is_immediate()); 1442 ASSERT(actual.is_immediate());
1443 if (expected.immediate() == actual.immediate()) { 1443 if (expected.immediate() == actual.immediate()) {
1444 definitely_matches = true; 1444 definitely_matches = true;
1445 } else { 1445 } else {
1446 mov(eax, actual.immediate()); 1446 mov(eax, actual.immediate());
1447 const int sentinel = SharedFunctionInfo::kDontAdaptArgumentsSentinel; 1447 const int sentinel = SharedFunctionInfo::kDontAdaptArgumentsSentinel;
1448 if (expected.immediate() == sentinel) { 1448 if (expected.immediate() == sentinel) {
(...skipping 29 matching lines...) Expand all
1478 Handle<Code> adaptor = 1478 Handle<Code> adaptor =
1479 isolate()->builtins()->ArgumentsAdaptorTrampoline(); 1479 isolate()->builtins()->ArgumentsAdaptorTrampoline();
1480 if (!code_constant.is_null()) { 1480 if (!code_constant.is_null()) {
1481 mov(edx, Immediate(code_constant)); 1481 mov(edx, Immediate(code_constant));
1482 add(Operand(edx), Immediate(Code::kHeaderSize - kHeapObjectTag)); 1482 add(Operand(edx), Immediate(Code::kHeaderSize - kHeapObjectTag));
1483 } else if (!code_operand.is_reg(edx)) { 1483 } else if (!code_operand.is_reg(edx)) {
1484 mov(edx, code_operand); 1484 mov(edx, code_operand);
1485 } 1485 }
1486 1486
1487 if (flag == CALL_FUNCTION) { 1487 if (flag == CALL_FUNCTION) {
1488 if (call_wrapper != NULL) {
1489 call_wrapper->BeforeCall(CallSize(adaptor, RelocInfo::CODE_TARGET));
1490 }
1488 call(adaptor, RelocInfo::CODE_TARGET); 1491 call(adaptor, RelocInfo::CODE_TARGET);
1489 if (post_call_generator != NULL) post_call_generator->Generate(); 1492 if (call_wrapper != NULL) call_wrapper->AfterCall();
1490 jmp(done); 1493 jmp(done);
1491 } else { 1494 } else {
1492 jmp(adaptor, RelocInfo::CODE_TARGET); 1495 jmp(adaptor, RelocInfo::CODE_TARGET);
1493 } 1496 }
1494 bind(&invoke); 1497 bind(&invoke);
1495 } 1498 }
1496 } 1499 }
1497 1500
1498 1501
1499 void MacroAssembler::InvokeCode(const Operand& code, 1502 void MacroAssembler::InvokeCode(const Operand& code,
1500 const ParameterCount& expected, 1503 const ParameterCount& expected,
1501 const ParameterCount& actual, 1504 const ParameterCount& actual,
1502 InvokeFlag flag, 1505 InvokeFlag flag,
1503 PostCallGenerator* post_call_generator) { 1506 CallWrapper* call_wrapper) {
1504 NearLabel done; 1507 NearLabel done;
1505 InvokePrologue(expected, actual, Handle<Code>::null(), code, 1508 InvokePrologue(expected, actual, Handle<Code>::null(), code,
1506 &done, flag, post_call_generator); 1509 &done, flag, call_wrapper);
1507 if (flag == CALL_FUNCTION) { 1510 if (flag == CALL_FUNCTION) {
1511 if (call_wrapper != NULL) call_wrapper->BeforeCall(CallSize(code));
1508 call(code); 1512 call(code);
1509 if (post_call_generator != NULL) post_call_generator->Generate(); 1513 if (call_wrapper != NULL) call_wrapper->AfterCall();
1510 } else { 1514 } else {
1511 ASSERT(flag == JUMP_FUNCTION); 1515 ASSERT(flag == JUMP_FUNCTION);
1512 jmp(code); 1516 jmp(code);
1513 } 1517 }
1514 bind(&done); 1518 bind(&done);
1515 } 1519 }
1516 1520
1517 1521
1518 void MacroAssembler::InvokeCode(Handle<Code> code, 1522 void MacroAssembler::InvokeCode(Handle<Code> code,
1519 const ParameterCount& expected, 1523 const ParameterCount& expected,
1520 const ParameterCount& actual, 1524 const ParameterCount& actual,
1521 RelocInfo::Mode rmode, 1525 RelocInfo::Mode rmode,
1522 InvokeFlag flag, 1526 InvokeFlag flag,
1523 PostCallGenerator* post_call_generator) { 1527 CallWrapper* call_wrapper) {
1524 NearLabel done; 1528 NearLabel done;
1525 Operand dummy(eax); 1529 Operand dummy(eax);
1526 InvokePrologue(expected, actual, code, dummy, &done, 1530 InvokePrologue(expected, actual, code, dummy, &done, flag, call_wrapper);
1527 flag, post_call_generator);
1528 if (flag == CALL_FUNCTION) { 1531 if (flag == CALL_FUNCTION) {
1532 if (call_wrapper != NULL) call_wrapper->BeforeCall(CallSize(code, rmode));
1529 call(code, rmode); 1533 call(code, rmode);
1530 if (post_call_generator != NULL) post_call_generator->Generate(); 1534 if (call_wrapper != NULL) call_wrapper->AfterCall();
1531 } else { 1535 } else {
1532 ASSERT(flag == JUMP_FUNCTION); 1536 ASSERT(flag == JUMP_FUNCTION);
1533 jmp(code, rmode); 1537 jmp(code, rmode);
1534 } 1538 }
1535 bind(&done); 1539 bind(&done);
1536 } 1540 }
1537 1541
1538 1542
1539 void MacroAssembler::InvokeFunction(Register fun, 1543 void MacroAssembler::InvokeFunction(Register fun,
1540 const ParameterCount& actual, 1544 const ParameterCount& actual,
1541 InvokeFlag flag, 1545 InvokeFlag flag,
1542 PostCallGenerator* post_call_generator) { 1546 CallWrapper* call_wrapper) {
1543 ASSERT(fun.is(edi)); 1547 ASSERT(fun.is(edi));
1544 mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); 1548 mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
1545 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); 1549 mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
1546 mov(ebx, FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset)); 1550 mov(ebx, FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset));
1547 SmiUntag(ebx); 1551 SmiUntag(ebx);
1548 1552
1549 ParameterCount expected(ebx); 1553 ParameterCount expected(ebx);
1550 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), 1554 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset),
1551 expected, actual, flag, post_call_generator); 1555 expected, actual, flag, call_wrapper);
1552 } 1556 }
1553 1557
1554 1558
1555 void MacroAssembler::InvokeFunction(JSFunction* function, 1559 void MacroAssembler::InvokeFunction(JSFunction* function,
1556 const ParameterCount& actual, 1560 const ParameterCount& actual,
1557 InvokeFlag flag, 1561 InvokeFlag flag,
1558 PostCallGenerator* post_call_generator) { 1562 CallWrapper* call_wrapper) {
1559 ASSERT(function->is_compiled()); 1563 ASSERT(function->is_compiled());
1560 // Get the function and setup the context. 1564 // Get the function and setup the context.
1561 mov(edi, Immediate(Handle<JSFunction>(function))); 1565 mov(edi, Immediate(Handle<JSFunction>(function)));
1562 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); 1566 mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
1563 1567
1564 ParameterCount expected(function->shared()->formal_parameter_count()); 1568 ParameterCount expected(function->shared()->formal_parameter_count());
1565 if (V8::UseCrankshaft()) { 1569 if (V8::UseCrankshaft()) {
1566 // TODO(kasperl): For now, we always call indirectly through the 1570 // TODO(kasperl): For now, we always call indirectly through the
1567 // code field in the function to allow recompilation to take effect 1571 // code field in the function to allow recompilation to take effect
1568 // without changing any of the call sites. 1572 // without changing any of the call sites.
1569 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), 1573 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset),
1570 expected, actual, flag, post_call_generator); 1574 expected, actual, flag, call_wrapper);
1571 } else { 1575 } else {
1572 Handle<Code> code(function->code()); 1576 Handle<Code> code(function->code());
1573 InvokeCode(code, expected, actual, RelocInfo::CODE_TARGET, 1577 InvokeCode(code, expected, actual, RelocInfo::CODE_TARGET,
1574 flag, post_call_generator); 1578 flag, call_wrapper);
1575 } 1579 }
1576 } 1580 }
1577 1581
1578 1582
1579 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, 1583 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id,
1580 InvokeFlag flag, 1584 InvokeFlag flag,
1581 PostCallGenerator* post_call_generator) { 1585 CallWrapper* call_wrapper) {
1582 // Calls are not allowed in some stubs. 1586 // Calls are not allowed in some stubs.
1583 ASSERT(flag == JUMP_FUNCTION || allow_stub_calls()); 1587 ASSERT(flag == JUMP_FUNCTION || allow_stub_calls());
1584 1588
1585 // Rely on the assertion to check that the number of provided 1589 // Rely on the assertion to check that the number of provided
1586 // arguments match the expected number of arguments. Fake a 1590 // arguments match the expected number of arguments. Fake a
1587 // parameter count to avoid emitting code to do the check. 1591 // parameter count to avoid emitting code to do the check.
1588 ParameterCount expected(0); 1592 ParameterCount expected(0);
1589 GetBuiltinFunction(edi, id); 1593 GetBuiltinFunction(edi, id);
1590 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), 1594 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset),
1591 expected, expected, flag, post_call_generator); 1595 expected, expected, flag, call_wrapper);
1592 } 1596 }
1593 1597
1594 void MacroAssembler::GetBuiltinFunction(Register target, 1598 void MacroAssembler::GetBuiltinFunction(Register target,
1595 Builtins::JavaScript id) { 1599 Builtins::JavaScript id) {
1596 // Load the JavaScript builtin function from the builtins object. 1600 // Load the JavaScript builtin function from the builtins object.
1597 mov(target, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); 1601 mov(target, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX)));
1598 mov(target, FieldOperand(target, GlobalObject::kBuiltinsOffset)); 1602 mov(target, FieldOperand(target, GlobalObject::kBuiltinsOffset));
1599 mov(target, FieldOperand(target, 1603 mov(target, FieldOperand(target,
1600 JSBuiltinsObject::OffsetOfFunctionWithId(id))); 1604 JSBuiltinsObject::OffsetOfFunctionWithId(id)));
1601 } 1605 }
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
2034 2038
2035 // Check that the code was patched as expected. 2039 // Check that the code was patched as expected.
2036 ASSERT(masm_.pc_ == address_ + size_); 2040 ASSERT(masm_.pc_ == address_ + size_);
2037 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); 2041 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
2038 } 2042 }
2039 2043
2040 2044
2041 } } // namespace v8::internal 2045 } } // namespace v8::internal
2042 2046
2043 #endif // V8_TARGET_ARCH_IA32 2047 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/macro-assembler-ia32.h ('k') | src/mips/macro-assembler-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698