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

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

Issue 297203002: Skip write barriers in the fast case when setting up local context. (Closed) Base URL: git@github.com:v8/v8.git@master
Patch Set: Created 6 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
« no previous file with comments | « src/objects.h ('k') | src/x64/lithium-codegen-x64.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "v8.h" 5 #include "v8.h"
6 6
7 #if V8_TARGET_ARCH_X64 7 #if V8_TARGET_ARCH_X64
8 8
9 #include "code-stubs.h" 9 #include "code-stubs.h"
10 #include "codegen.h" 10 #include "codegen.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 192 }
193 } 193 }
194 } 194 }
195 195
196 bool function_in_register = true; 196 bool function_in_register = true;
197 197
198 // Possibly allocate a local context. 198 // Possibly allocate a local context.
199 int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; 199 int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
200 if (heap_slots > 0) { 200 if (heap_slots > 0) {
201 Comment cmnt(masm_, "[ Allocate context"); 201 Comment cmnt(masm_, "[ Allocate context");
202 bool need_write_barrier = true;
202 // Argument to NewContext is the function, which is still in rdi. 203 // Argument to NewContext is the function, which is still in rdi.
203 if (FLAG_harmony_scoping && info->scope()->is_global_scope()) { 204 if (FLAG_harmony_scoping && info->scope()->is_global_scope()) {
204 __ Push(rdi); 205 __ Push(rdi);
205 __ Push(info->scope()->GetScopeInfo()); 206 __ Push(info->scope()->GetScopeInfo());
206 __ CallRuntime(Runtime::kHiddenNewGlobalContext, 2); 207 __ CallRuntime(Runtime::kHiddenNewGlobalContext, 2);
207 } else if (heap_slots <= FastNewContextStub::kMaximumSlots) { 208 } else if (heap_slots <= FastNewContextStub::kMaximumSlots) {
208 FastNewContextStub stub(isolate(), heap_slots); 209 FastNewContextStub stub(isolate(), heap_slots);
209 __ CallStub(&stub); 210 __ CallStub(&stub);
211 // Result of FastNewContextStub is always in new space.
212 need_write_barrier = false;
210 } else { 213 } else {
211 __ Push(rdi); 214 __ Push(rdi);
212 __ CallRuntime(Runtime::kHiddenNewFunctionContext, 1); 215 __ CallRuntime(Runtime::kHiddenNewFunctionContext, 1);
213 } 216 }
214 function_in_register = false; 217 function_in_register = false;
215 // Context is returned in rax. It replaces the context passed to us. 218 // Context is returned in rax. It replaces the context passed to us.
216 // It's saved in the stack and kept live in rsi. 219 // It's saved in the stack and kept live in rsi.
217 __ movp(rsi, rax); 220 __ movp(rsi, rax);
218 __ movp(Operand(rbp, StandardFrameConstants::kContextOffset), rax); 221 __ movp(Operand(rbp, StandardFrameConstants::kContextOffset), rax);
219 222
220 // Copy any necessary parameters into the context. 223 // Copy any necessary parameters into the context.
221 int num_parameters = info->scope()->num_parameters(); 224 int num_parameters = info->scope()->num_parameters();
222 for (int i = 0; i < num_parameters; i++) { 225 for (int i = 0; i < num_parameters; i++) {
223 Variable* var = scope()->parameter(i); 226 Variable* var = scope()->parameter(i);
224 if (var->IsContextSlot()) { 227 if (var->IsContextSlot()) {
225 int parameter_offset = StandardFrameConstants::kCallerSPOffset + 228 int parameter_offset = StandardFrameConstants::kCallerSPOffset +
226 (num_parameters - 1 - i) * kPointerSize; 229 (num_parameters - 1 - i) * kPointerSize;
227 // Load parameter from stack. 230 // Load parameter from stack.
228 __ movp(rax, Operand(rbp, parameter_offset)); 231 __ movp(rax, Operand(rbp, parameter_offset));
229 // Store it in the context. 232 // Store it in the context.
230 int context_offset = Context::SlotOffset(var->index()); 233 int context_offset = Context::SlotOffset(var->index());
231 __ movp(Operand(rsi, context_offset), rax); 234 __ movp(Operand(rsi, context_offset), rax);
232 // Update the write barrier. This clobbers rax and rbx. 235 // Update the write barrier. This clobbers rax and rbx.
233 __ RecordWriteContextSlot( 236 if (need_write_barrier) {
234 rsi, context_offset, rax, rbx, kDontSaveFPRegs); 237 __ RecordWriteContextSlot(
238 rsi, context_offset, rax, rbx, kDontSaveFPRegs);
239 } else if (FLAG_debug_code) {
240 Label done;
241 __ JumpIfInNewSpace(rsi, rax, &done, Label::kNear);
242 __ Abort(kExpectedNewSpaceObject);
243 __ bind(&done);
244 }
235 } 245 }
236 } 246 }
237 } 247 }
238 248
239 // Possibly allocate an arguments object. 249 // Possibly allocate an arguments object.
240 Variable* arguments = scope()->arguments(); 250 Variable* arguments = scope()->arguments();
241 if (arguments != NULL) { 251 if (arguments != NULL) {
242 // Arguments object must be allocated after the context object, in 252 // Arguments object must be allocated after the context object, in
243 // case the "arguments" or ".arguments" variables are in the context. 253 // case the "arguments" or ".arguments" variables are in the context.
244 Comment cmnt(masm_, "[ Allocate arguments object"); 254 Comment cmnt(masm_, "[ Allocate arguments object");
(...skipping 4555 matching lines...) Expand 10 before | Expand all | Expand 10 after
4800 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 4810 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
4801 Assembler::target_address_at(call_target_address, 4811 Assembler::target_address_at(call_target_address,
4802 unoptimized_code)); 4812 unoptimized_code));
4803 return OSR_AFTER_STACK_CHECK; 4813 return OSR_AFTER_STACK_CHECK;
4804 } 4814 }
4805 4815
4806 4816
4807 } } // namespace v8::internal 4817 } } // namespace v8::internal
4808 4818
4809 #endif // V8_TARGET_ARCH_X64 4819 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698