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

Side by Side Diff: src/x64/full-codegen-x64.cc

Issue 8343054: Make eval consider anything on the form eval(args...) a potential direct cal (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments. Created 9 years, 1 month 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/variables.h ('k') | test/cctest/test-api.cc » ('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 2081 matching lines...) Expand 10 before | Expand all | Expand 10 after
2092 CallFunctionStub stub(arg_count, flags); 2092 CallFunctionStub stub(arg_count, flags);
2093 __ CallStub(&stub); 2093 __ CallStub(&stub);
2094 RecordJSReturnSite(expr); 2094 RecordJSReturnSite(expr);
2095 // Restore context register. 2095 // Restore context register.
2096 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); 2096 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2097 // Discard the function left on TOS. 2097 // Discard the function left on TOS.
2098 context()->DropAndPlug(1, rax); 2098 context()->DropAndPlug(1, rax);
2099 } 2099 }
2100 2100
2101 2101
2102 void FullCodeGenerator::EmitResolvePossiblyDirectEval(ResolveEvalFlag flag, 2102 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) {
2103 int arg_count) {
2104 // Push copy of the first argument or undefined if it doesn't exist. 2103 // Push copy of the first argument or undefined if it doesn't exist.
2105 if (arg_count > 0) { 2104 if (arg_count > 0) {
2106 __ push(Operand(rsp, arg_count * kPointerSize)); 2105 __ push(Operand(rsp, arg_count * kPointerSize));
2107 } else { 2106 } else {
2108 __ PushRoot(Heap::kUndefinedValueRootIndex); 2107 __ PushRoot(Heap::kUndefinedValueRootIndex);
2109 } 2108 }
2110 2109
2111 // Push the receiver of the enclosing function and do runtime call. 2110 // Push the receiver of the enclosing function and do runtime call.
2112 __ push(Operand(rbp, (2 + info_->scope()->num_parameters()) * kPointerSize)); 2111 __ push(Operand(rbp, (2 + info_->scope()->num_parameters()) * kPointerSize));
2113 2112
2114 // Push the strict mode flag. In harmony mode every eval call 2113 // Push the strict mode flag. In harmony mode every eval call
2115 // is a strict mode eval call. 2114 // is a strict mode eval call.
2116 StrictModeFlag strict_mode = 2115 StrictModeFlag strict_mode =
2117 FLAG_harmony_scoping ? kStrictMode : strict_mode_flag(); 2116 FLAG_harmony_scoping ? kStrictMode : strict_mode_flag();
2118 __ Push(Smi::FromInt(strict_mode)); 2117 __ Push(Smi::FromInt(strict_mode));
2119 2118
2120 __ CallRuntime(flag == SKIP_CONTEXT_LOOKUP 2119 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 4);
2121 ? Runtime::kResolvePossiblyDirectEvalNoLookup
2122 : Runtime::kResolvePossiblyDirectEval, 4);
2123 } 2120 }
2124 2121
2125 2122
2126 void FullCodeGenerator::VisitCall(Call* expr) { 2123 void FullCodeGenerator::VisitCall(Call* expr) {
2127 #ifdef DEBUG 2124 #ifdef DEBUG
2128 // We want to verify that RecordJSReturnSite gets called on all paths 2125 // We want to verify that RecordJSReturnSite gets called on all paths
2129 // through this function. Avoid early returns. 2126 // through this function. Avoid early returns.
2130 expr->return_is_recorded_ = false; 2127 expr->return_is_recorded_ = false;
2131 #endif 2128 #endif
2132 2129
(...skipping 10 matching lines...) Expand all
2143 int arg_count = args->length(); 2140 int arg_count = args->length();
2144 { PreservePositionScope pos_scope(masm()->positions_recorder()); 2141 { PreservePositionScope pos_scope(masm()->positions_recorder());
2145 VisitForStackValue(callee); 2142 VisitForStackValue(callee);
2146 __ PushRoot(Heap::kUndefinedValueRootIndex); // Reserved receiver slot. 2143 __ PushRoot(Heap::kUndefinedValueRootIndex); // Reserved receiver slot.
2147 2144
2148 // Push the arguments. 2145 // Push the arguments.
2149 for (int i = 0; i < arg_count; i++) { 2146 for (int i = 0; i < arg_count; i++) {
2150 VisitForStackValue(args->at(i)); 2147 VisitForStackValue(args->at(i));
2151 } 2148 }
2152 2149
2153 // If we know that eval can only be shadowed by eval-introduced
2154 // variables we attempt to load the global eval function directly in
2155 // generated code. If we succeed, there is no need to perform a
2156 // context lookup in the runtime system.
2157 Label done;
2158 Variable* var = proxy->var();
2159 if (!var->IsUnallocated() && var->mode() == DYNAMIC_GLOBAL) {
2160 Label slow;
2161 EmitLoadGlobalCheckExtensions(var, NOT_INSIDE_TYPEOF, &slow);
2162 // Push the function and resolve eval.
2163 __ push(rax);
2164 EmitResolvePossiblyDirectEval(SKIP_CONTEXT_LOOKUP, arg_count);
2165 __ jmp(&done);
2166 __ bind(&slow);
2167 }
2168
2169 // Push a copy of the function (found below the arguments) and resolve 2150 // Push a copy of the function (found below the arguments) and resolve
2170 // eval. 2151 // eval.
2171 __ push(Operand(rsp, (arg_count + 1) * kPointerSize)); 2152 __ push(Operand(rsp, (arg_count + 1) * kPointerSize));
2172 EmitResolvePossiblyDirectEval(PERFORM_CONTEXT_LOOKUP, arg_count); 2153 EmitResolvePossiblyDirectEval(arg_count);
2173 __ bind(&done);
2174 2154
2175 // The runtime call returns a pair of values in rax (function) and 2155 // The runtime call returns a pair of values in rax (function) and
2176 // rdx (receiver). Touch up the stack with the right values. 2156 // rdx (receiver). Touch up the stack with the right values.
2177 __ movq(Operand(rsp, (arg_count + 0) * kPointerSize), rdx); 2157 __ movq(Operand(rsp, (arg_count + 0) * kPointerSize), rdx);
2178 __ movq(Operand(rsp, (arg_count + 1) * kPointerSize), rax); 2158 __ movq(Operand(rsp, (arg_count + 1) * kPointerSize), rax);
2179 } 2159 }
2180 // Record source position for debugger. 2160 // Record source position for debugger.
2181 SetSourcePosition(expr->position()); 2161 SetSourcePosition(expr->position());
2182 CallFunctionStub stub(arg_count, RECEIVER_MIGHT_BE_IMPLICIT); 2162 CallFunctionStub stub(arg_count, RECEIVER_MIGHT_BE_IMPLICIT);
2183 __ CallStub(&stub); 2163 __ CallStub(&stub);
(...skipping 2090 matching lines...) Expand 10 before | Expand all | Expand 10 after
4274 *context_length = 0; 4254 *context_length = 0;
4275 return previous_; 4255 return previous_;
4276 } 4256 }
4277 4257
4278 4258
4279 #undef __ 4259 #undef __
4280 4260
4281 } } // namespace v8::internal 4261 } } // namespace v8::internal
4282 4262
4283 #endif // V8_TARGET_ARCH_X64 4263 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/variables.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698