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

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

Issue 157503002: A64: Synchronize with r18444. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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/frames-x64.cc ('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 // 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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 303
304 void FullCodeGenerator::EmitProfilingCounterDecrement(int delta) { 304 void FullCodeGenerator::EmitProfilingCounterDecrement(int delta) {
305 __ movq(rbx, profiling_counter_, RelocInfo::EMBEDDED_OBJECT); 305 __ movq(rbx, profiling_counter_, RelocInfo::EMBEDDED_OBJECT);
306 __ SmiAddConstant(FieldOperand(rbx, Cell::kValueOffset), 306 __ SmiAddConstant(FieldOperand(rbx, Cell::kValueOffset),
307 Smi::FromInt(-delta)); 307 Smi::FromInt(-delta));
308 } 308 }
309 309
310 310
311 void FullCodeGenerator::EmitProfilingCounterReset() { 311 void FullCodeGenerator::EmitProfilingCounterReset() {
312 int reset_value = FLAG_interrupt_budget; 312 int reset_value = FLAG_interrupt_budget;
313 if (info_->ShouldSelfOptimize() && !FLAG_retry_self_opt) {
314 // Self-optimization is a one-off thing; if it fails, don't try again.
315 reset_value = Smi::kMaxValue;
316 }
317 __ movq(rbx, profiling_counter_, RelocInfo::EMBEDDED_OBJECT); 313 __ movq(rbx, profiling_counter_, RelocInfo::EMBEDDED_OBJECT);
318 __ Move(kScratchRegister, Smi::FromInt(reset_value)); 314 __ Move(kScratchRegister, Smi::FromInt(reset_value));
319 __ movq(FieldOperand(rbx, Cell::kValueOffset), kScratchRegister); 315 __ movq(FieldOperand(rbx, Cell::kValueOffset), kScratchRegister);
320 } 316 }
321 317
322 318
323 void FullCodeGenerator::EmitBackEdgeBookkeeping(IterationStatement* stmt, 319 void FullCodeGenerator::EmitBackEdgeBookkeeping(IterationStatement* stmt,
324 Label* back_edge_target) { 320 Label* back_edge_target) {
325 Comment cmnt(masm_, "[ Back edge bookkeeping"); 321 Comment cmnt(masm_, "[ Back edge bookkeeping");
326 Label ok; 322 Label ok;
327 323
328 int weight = 1; 324 ASSERT(back_edge_target->is_bound());
329 if (FLAG_weighted_back_edges) { 325 int distance = masm_->SizeOfCodeGeneratedSince(back_edge_target);
330 ASSERT(back_edge_target->is_bound()); 326 int weight = Min(kMaxBackEdgeWeight,
331 int distance = masm_->SizeOfCodeGeneratedSince(back_edge_target); 327 Max(1, distance / kCodeSizeMultiplier));
332 weight = Min(kMaxBackEdgeWeight,
333 Max(1, distance / kCodeSizeMultiplier));
334 }
335 EmitProfilingCounterDecrement(weight); 328 EmitProfilingCounterDecrement(weight);
336 __ j(positive, &ok, Label::kNear); 329 __ j(positive, &ok, Label::kNear);
337 __ call(isolate()->builtins()->InterruptCheck(), RelocInfo::CODE_TARGET); 330 __ call(isolate()->builtins()->InterruptCheck(), RelocInfo::CODE_TARGET);
338 331
339 // Record a mapping of this PC offset to the OSR id. This is used to find 332 // Record a mapping of this PC offset to the OSR id. This is used to find
340 // the AST id from the unoptimized code in order to use it as a key into 333 // the AST id from the unoptimized code in order to use it as a key into
341 // the deoptimization input data found in the optimized code. 334 // the deoptimization input data found in the optimized code.
342 RecordBackEdge(stmt->OsrEntryId()); 335 RecordBackEdge(stmt->OsrEntryId());
343 336
344 EmitProfilingCounterReset(); 337 EmitProfilingCounterReset();
(...skipping 10 matching lines...) Expand all
355 void FullCodeGenerator::EmitReturnSequence() { 348 void FullCodeGenerator::EmitReturnSequence() {
356 Comment cmnt(masm_, "[ Return sequence"); 349 Comment cmnt(masm_, "[ Return sequence");
357 if (return_label_.is_bound()) { 350 if (return_label_.is_bound()) {
358 __ jmp(&return_label_); 351 __ jmp(&return_label_);
359 } else { 352 } else {
360 __ bind(&return_label_); 353 __ bind(&return_label_);
361 if (FLAG_trace) { 354 if (FLAG_trace) {
362 __ push(rax); 355 __ push(rax);
363 __ CallRuntime(Runtime::kTraceExit, 1); 356 __ CallRuntime(Runtime::kTraceExit, 1);
364 } 357 }
365 if (FLAG_interrupt_at_exit || FLAG_self_optimization) { 358 // Pretend that the exit is a backwards jump to the entry.
366 // Pretend that the exit is a backwards jump to the entry. 359 int weight = 1;
367 int weight = 1; 360 if (info_->ShouldSelfOptimize()) {
368 if (info_->ShouldSelfOptimize()) { 361 weight = FLAG_interrupt_budget / FLAG_self_opt_count;
369 weight = FLAG_interrupt_budget / FLAG_self_opt_count; 362 } else {
370 } else if (FLAG_weighted_back_edges) { 363 int distance = masm_->pc_offset();
371 int distance = masm_->pc_offset(); 364 weight = Min(kMaxBackEdgeWeight,
372 weight = Min(kMaxBackEdgeWeight, 365 Max(1, distance / kCodeSizeMultiplier));
373 Max(1, distance / kCodeSizeMultiplier));
374 }
375 EmitProfilingCounterDecrement(weight);
376 Label ok;
377 __ j(positive, &ok, Label::kNear);
378 __ push(rax);
379 if (info_->ShouldSelfOptimize() && FLAG_direct_self_opt) {
380 __ push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
381 __ CallRuntime(Runtime::kOptimizeFunctionOnNextCall, 1);
382 } else {
383 __ call(isolate()->builtins()->InterruptCheck(),
384 RelocInfo::CODE_TARGET);
385 }
386 __ pop(rax);
387 EmitProfilingCounterReset();
388 __ bind(&ok);
389 } 366 }
367 EmitProfilingCounterDecrement(weight);
368 Label ok;
369 __ j(positive, &ok, Label::kNear);
370 __ push(rax);
371 __ call(isolate()->builtins()->InterruptCheck(),
372 RelocInfo::CODE_TARGET);
373 __ pop(rax);
374 EmitProfilingCounterReset();
375 __ bind(&ok);
390 #ifdef DEBUG 376 #ifdef DEBUG
391 // Add a label for checking the size of the code used for returning. 377 // Add a label for checking the size of the code used for returning.
392 Label check_exit_codesize; 378 Label check_exit_codesize;
393 masm_->bind(&check_exit_codesize); 379 masm_->bind(&check_exit_codesize);
394 #endif 380 #endif
395 CodeGenerator::RecordPositions(masm_, function()->end_position() - 1); 381 CodeGenerator::RecordPositions(masm_, function()->end_position() - 1);
396 __ RecordJSReturn(); 382 __ RecordJSReturn();
397 // Do not use the leave instruction here because it is too short to 383 // Do not use the leave instruction here because it is too short to
398 // patch with the code required by the debugger. 384 // patch with the code required by the debugger.
399 __ movq(rsp, rbp); 385 __ movq(rsp, rbp);
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 __ jmp(clause->body_target()); 979 __ jmp(clause->body_target());
994 __ bind(&slow_case); 980 __ bind(&slow_case);
995 } 981 }
996 982
997 // Record position before stub call for type feedback. 983 // Record position before stub call for type feedback.
998 SetSourcePosition(clause->position()); 984 SetSourcePosition(clause->position());
999 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), Token::EQ_STRICT); 985 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), Token::EQ_STRICT);
1000 CallIC(ic, RelocInfo::CODE_TARGET, clause->CompareId()); 986 CallIC(ic, RelocInfo::CODE_TARGET, clause->CompareId());
1001 patch_site.EmitPatchInfo(); 987 patch_site.EmitPatchInfo();
1002 988
989 Label skip;
990 __ jmp(&skip, Label::kNear);
991 PrepareForBailout(clause, TOS_REG);
992 __ CompareRoot(rax, Heap::kTrueValueRootIndex);
993 __ j(not_equal, &next_test);
994 __ Drop(1);
995 __ jmp(clause->body_target());
996 __ bind(&skip);
997
1003 __ testq(rax, rax); 998 __ testq(rax, rax);
1004 __ j(not_equal, &next_test); 999 __ j(not_equal, &next_test);
1005 __ Drop(1); // Switch value is no longer needed. 1000 __ Drop(1); // Switch value is no longer needed.
1006 __ jmp(clause->body_target()); 1001 __ jmp(clause->body_target());
1007 } 1002 }
1008 1003
1009 // Discard the test value and jump to the default if present, otherwise to 1004 // Discard the test value and jump to the default if present, otherwise to
1010 // the end of the statement. 1005 // the end of the statement.
1011 __ bind(&next_test); 1006 __ bind(&next_test);
1012 __ Drop(1); // Switch value is no longer needed. 1007 __ Drop(1); // Switch value is no longer needed.
(...skipping 2622 matching lines...) Expand 10 before | Expand all | Expand 10 after
3635 VisitForStackValue(args->at(0)); 3630 VisitForStackValue(args->at(0));
3636 VisitForStackValue(args->at(1)); 3631 VisitForStackValue(args->at(1));
3637 3632
3638 StringCompareStub stub; 3633 StringCompareStub stub;
3639 __ CallStub(&stub); 3634 __ CallStub(&stub);
3640 context()->Plug(rax); 3635 context()->Plug(rax);
3641 } 3636 }
3642 3637
3643 3638
3644 void FullCodeGenerator::EmitMathLog(CallRuntime* expr) { 3639 void FullCodeGenerator::EmitMathLog(CallRuntime* expr) {
3645 // Load the argument on the stack and call the stub. 3640 // Load the argument on the stack and call the runtime function.
3646 TranscendentalCacheStub stub(TranscendentalCache::LOG,
3647 TranscendentalCacheStub::TAGGED);
3648 ZoneList<Expression*>* args = expr->arguments(); 3641 ZoneList<Expression*>* args = expr->arguments();
3649 ASSERT(args->length() == 1); 3642 ASSERT(args->length() == 1);
3650 VisitForStackValue(args->at(0)); 3643 VisitForStackValue(args->at(0));
3651 __ CallStub(&stub); 3644 __ CallRuntime(Runtime::kMath_log, 1);
3652 context()->Plug(rax); 3645 context()->Plug(rax);
3653 } 3646 }
3654 3647
3655 3648
3656 void FullCodeGenerator::EmitMathSqrt(CallRuntime* expr) { 3649 void FullCodeGenerator::EmitMathSqrt(CallRuntime* expr) {
3657 // Load the argument on the stack and call the runtime function. 3650 // Load the argument on the stack and call the runtime function.
3658 ZoneList<Expression*>* args = expr->arguments(); 3651 ZoneList<Expression*>* args = expr->arguments();
3659 ASSERT(args->length() == 1); 3652 ASSERT(args->length() == 1);
3660 VisitForStackValue(args->at(0)); 3653 VisitForStackValue(args->at(0));
3661 __ CallRuntime(Runtime::kMath_sqrt, 1); 3654 __ CallRuntime(Runtime::kMath_sqrt, 1);
(...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after
4833 *context_length = 0; 4826 *context_length = 0;
4834 return previous_; 4827 return previous_;
4835 } 4828 }
4836 4829
4837 4830
4838 #undef __ 4831 #undef __
4839 4832
4840 4833
4841 static const byte kJnsInstruction = 0x79; 4834 static const byte kJnsInstruction = 0x79;
4842 static const byte kJnsOffset = 0x1d; 4835 static const byte kJnsOffset = 0x1d;
4843 static const byte kCallInstruction = 0xe8;
4844 static const byte kNopByteOne = 0x66; 4836 static const byte kNopByteOne = 0x66;
4845 static const byte kNopByteTwo = 0x90; 4837 static const byte kNopByteTwo = 0x90;
4838 #ifdef DEBUG
4839 static const byte kCallInstruction = 0xe8;
4840 #endif
4846 4841
4847 4842
4848 void BackEdgeTable::PatchAt(Code* unoptimized_code, 4843 void BackEdgeTable::PatchAt(Code* unoptimized_code,
4849 Address pc, 4844 Address pc,
4850 BackEdgeState target_state, 4845 BackEdgeState target_state,
4851 Code* replacement_code) { 4846 Code* replacement_code) {
4852 Address call_target_address = pc - kIntSize; 4847 Address call_target_address = pc - kIntSize;
4853 Address jns_instr_address = call_target_address - 3; 4848 Address jns_instr_address = call_target_address - 3;
4854 Address jns_offset_address = call_target_address - 2; 4849 Address jns_offset_address = call_target_address - 2;
4855 4850
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
4906 4901
4907 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 4902 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
4908 Assembler::target_address_at(call_target_address)); 4903 Assembler::target_address_at(call_target_address));
4909 return OSR_AFTER_STACK_CHECK; 4904 return OSR_AFTER_STACK_CHECK;
4910 } 4905 }
4911 4906
4912 4907
4913 } } // namespace v8::internal 4908 } } // namespace v8::internal
4914 4909
4915 #endif // V8_TARGET_ARCH_X64 4910 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/frames-x64.cc ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698