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

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

Issue 6909026: Additional minor cleanup regarding CallWrapper: Use the null object pattern. (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/x64/macro-assembler-x64.h ('k') | no next file » | 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 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 const ExternalReference& ext, int result_size) { 748 const ExternalReference& ext, int result_size) {
749 // Set the entry point and jump to the C entry runtime stub. 749 // Set the entry point and jump to the C entry runtime stub.
750 LoadAddress(rbx, ext); 750 LoadAddress(rbx, ext);
751 CEntryStub ces(result_size); 751 CEntryStub ces(result_size);
752 return TryTailCallStub(&ces); 752 return TryTailCallStub(&ces);
753 } 753 }
754 754
755 755
756 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, 756 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id,
757 InvokeFlag flag, 757 InvokeFlag flag,
758 CallWrapper* call_wrapper) { 758 const CallWrapper& call_wrapper) {
759 // Calls are not allowed in some stubs. 759 // Calls are not allowed in some stubs.
760 ASSERT(flag == JUMP_FUNCTION || allow_stub_calls()); 760 ASSERT(flag == JUMP_FUNCTION || allow_stub_calls());
761 761
762 // Rely on the assertion to check that the number of provided 762 // Rely on the assertion to check that the number of provided
763 // arguments match the expected number of arguments. Fake a 763 // arguments match the expected number of arguments. Fake a
764 // parameter count to avoid emitting code to do the check. 764 // parameter count to avoid emitting code to do the check.
765 ParameterCount expected(0); 765 ParameterCount expected(0);
766 GetBuiltinEntry(rdx, id); 766 GetBuiltinEntry(rdx, id);
767 InvokeCode(rdx, expected, expected, flag, call_wrapper); 767 InvokeCode(rdx, expected, expected, flag, call_wrapper);
768 } 768 }
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after
2049 CEntryStub ces(1); 2049 CEntryStub ces(1);
2050 Call(ces.GetCode(), RelocInfo::DEBUG_BREAK); 2050 Call(ces.GetCode(), RelocInfo::DEBUG_BREAK);
2051 } 2051 }
2052 #endif // ENABLE_DEBUGGER_SUPPORT 2052 #endif // ENABLE_DEBUGGER_SUPPORT
2053 2053
2054 2054
2055 void MacroAssembler::InvokeCode(Register code, 2055 void MacroAssembler::InvokeCode(Register code,
2056 const ParameterCount& expected, 2056 const ParameterCount& expected,
2057 const ParameterCount& actual, 2057 const ParameterCount& actual,
2058 InvokeFlag flag, 2058 InvokeFlag flag,
2059 CallWrapper* call_wrapper) { 2059 const CallWrapper& call_wrapper) {
2060 NearLabel done; 2060 NearLabel done;
2061 InvokePrologue(expected, 2061 InvokePrologue(expected,
2062 actual, 2062 actual,
2063 Handle<Code>::null(), 2063 Handle<Code>::null(),
2064 code, 2064 code,
2065 &done, 2065 &done,
2066 flag, 2066 flag,
2067 call_wrapper); 2067 call_wrapper);
2068 if (flag == CALL_FUNCTION) { 2068 if (flag == CALL_FUNCTION) {
2069 if (call_wrapper != NULL) call_wrapper->BeforeCall(CallSize(code)); 2069 call_wrapper.BeforeCall(CallSize(code));
2070 call(code); 2070 call(code);
2071 if (call_wrapper != NULL) call_wrapper->AfterCall(); 2071 call_wrapper.AfterCall();
2072 } else { 2072 } else {
2073 ASSERT(flag == JUMP_FUNCTION); 2073 ASSERT(flag == JUMP_FUNCTION);
2074 jmp(code); 2074 jmp(code);
2075 } 2075 }
2076 bind(&done); 2076 bind(&done);
2077 } 2077 }
2078 2078
2079 2079
2080 void MacroAssembler::InvokeCode(Handle<Code> code, 2080 void MacroAssembler::InvokeCode(Handle<Code> code,
2081 const ParameterCount& expected, 2081 const ParameterCount& expected,
2082 const ParameterCount& actual, 2082 const ParameterCount& actual,
2083 RelocInfo::Mode rmode, 2083 RelocInfo::Mode rmode,
2084 InvokeFlag flag, 2084 InvokeFlag flag,
2085 CallWrapper* call_wrapper) { 2085 const CallWrapper& call_wrapper) {
2086 NearLabel done; 2086 NearLabel done;
2087 Register dummy = rax; 2087 Register dummy = rax;
2088 InvokePrologue(expected, 2088 InvokePrologue(expected,
2089 actual, 2089 actual,
2090 code, 2090 code,
2091 dummy, 2091 dummy,
2092 &done, 2092 &done,
2093 flag, 2093 flag,
2094 call_wrapper); 2094 call_wrapper);
2095 if (flag == CALL_FUNCTION) { 2095 if (flag == CALL_FUNCTION) {
2096 if (call_wrapper != NULL) call_wrapper->BeforeCall(CallSize(code)); 2096 call_wrapper.BeforeCall(CallSize(code));
2097 Call(code, rmode); 2097 Call(code, rmode);
2098 if (call_wrapper != NULL) call_wrapper->AfterCall(); 2098 call_wrapper.AfterCall();
2099 } else { 2099 } else {
2100 ASSERT(flag == JUMP_FUNCTION); 2100 ASSERT(flag == JUMP_FUNCTION);
2101 Jump(code, rmode); 2101 Jump(code, rmode);
2102 } 2102 }
2103 bind(&done); 2103 bind(&done);
2104 } 2104 }
2105 2105
2106 2106
2107 void MacroAssembler::InvokeFunction(Register function, 2107 void MacroAssembler::InvokeFunction(Register function,
2108 const ParameterCount& actual, 2108 const ParameterCount& actual,
2109 InvokeFlag flag, 2109 InvokeFlag flag,
2110 CallWrapper* call_wrapper) { 2110 const CallWrapper& call_wrapper) {
2111 ASSERT(function.is(rdi)); 2111 ASSERT(function.is(rdi));
2112 movq(rdx, FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); 2112 movq(rdx, FieldOperand(function, JSFunction::kSharedFunctionInfoOffset));
2113 movq(rsi, FieldOperand(function, JSFunction::kContextOffset)); 2113 movq(rsi, FieldOperand(function, JSFunction::kContextOffset));
2114 movsxlq(rbx, 2114 movsxlq(rbx,
2115 FieldOperand(rdx, SharedFunctionInfo::kFormalParameterCountOffset)); 2115 FieldOperand(rdx, SharedFunctionInfo::kFormalParameterCountOffset));
2116 // Advances rdx to the end of the Code object header, to the start of 2116 // Advances rdx to the end of the Code object header, to the start of
2117 // the executable code. 2117 // the executable code.
2118 movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); 2118 movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset));
2119 2119
2120 ParameterCount expected(rbx); 2120 ParameterCount expected(rbx);
2121 InvokeCode(rdx, expected, actual, flag, call_wrapper); 2121 InvokeCode(rdx, expected, actual, flag, call_wrapper);
2122 } 2122 }
2123 2123
2124 2124
2125 void MacroAssembler::InvokeFunction(JSFunction* function, 2125 void MacroAssembler::InvokeFunction(JSFunction* function,
2126 const ParameterCount& actual, 2126 const ParameterCount& actual,
2127 InvokeFlag flag, 2127 InvokeFlag flag,
2128 CallWrapper* call_wrapper) { 2128 const CallWrapper& call_wrapper) {
2129 ASSERT(function->is_compiled()); 2129 ASSERT(function->is_compiled());
2130 // Get the function and setup the context. 2130 // Get the function and setup the context.
2131 Move(rdi, Handle<JSFunction>(function)); 2131 Move(rdi, Handle<JSFunction>(function));
2132 movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); 2132 movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
2133 2133
2134 if (V8::UseCrankshaft()) { 2134 if (V8::UseCrankshaft()) {
2135 // Since Crankshaft can recompile a function, we need to load 2135 // Since Crankshaft can recompile a function, we need to load
2136 // the Code object every time we call the function. 2136 // the Code object every time we call the function.
2137 movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); 2137 movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset));
2138 ParameterCount expected(function->shared()->formal_parameter_count()); 2138 ParameterCount expected(function->shared()->formal_parameter_count());
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
2912 CPU::FlushICache(address_, size_); 2912 CPU::FlushICache(address_, size_);
2913 2913
2914 // Check that the code was patched as expected. 2914 // Check that the code was patched as expected.
2915 ASSERT(masm_.pc_ == address_ + size_); 2915 ASSERT(masm_.pc_ == address_ + size_);
2916 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); 2916 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
2917 } 2917 }
2918 2918
2919 } } // namespace v8::internal 2919 } } // namespace v8::internal
2920 2920
2921 #endif // V8_TARGET_ARCH_X64 2921 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698