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

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

Issue 6838018: Support %_CallFunction in optimized code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Include regression test. Created 9 years, 8 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
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 return GeneratePrologue() && 84 return GeneratePrologue() &&
85 GenerateBody() && 85 GenerateBody() &&
86 GenerateDeferredCode() && 86 GenerateDeferredCode() &&
87 GenerateJumpTable() && 87 GenerateJumpTable() &&
88 GenerateSafepointTable(); 88 GenerateSafepointTable();
89 } 89 }
90 90
91 91
92 void LCodeGen::FinishCode(Handle<Code> code) { 92 void LCodeGen::FinishCode(Handle<Code> code) {
93 ASSERT(is_done()); 93 ASSERT(is_done());
94 code->set_stack_slots(StackSlotCount()); 94 code->set_stack_slots(GetStackSlotCount());
95 code->set_safepoint_table_offset(safepoints_.GetCodeOffset()); 95 code->set_safepoint_table_offset(safepoints_.GetCodeOffset());
96 PopulateDeoptimizationData(code); 96 PopulateDeoptimizationData(code);
97 Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(code); 97 Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(code);
98 } 98 }
99 99
100 100
101 void LCodeGen::Abort(const char* format, ...) { 101 void LCodeGen::Abort(const char* format, ...) {
102 if (FLAG_trace_bailout) { 102 if (FLAG_trace_bailout) {
103 SmartPointer<char> name(info()->shared_info()->DebugName()->ToCString()); 103 SmartPointer<char> name(info()->shared_info()->DebugName()->ToCString());
104 PrintF("Aborting LCodeGen in @\"%s\": ", *name); 104 PrintF("Aborting LCodeGen in @\"%s\": ", *name);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 __ int3(); 139 __ int3();
140 } 140 }
141 #endif 141 #endif
142 142
143 __ push(rbp); // Caller's frame pointer. 143 __ push(rbp); // Caller's frame pointer.
144 __ movq(rbp, rsp); 144 __ movq(rbp, rsp);
145 __ push(rsi); // Callee's context. 145 __ push(rsi); // Callee's context.
146 __ push(rdi); // Callee's JS function. 146 __ push(rdi); // Callee's JS function.
147 147
148 // Reserve space for the stack slots needed by the code. 148 // Reserve space for the stack slots needed by the code.
149 int slots = StackSlotCount(); 149 int slots = GetStackSlotCount();
150 if (slots > 0) { 150 if (slots > 0) {
151 if (FLAG_debug_code) { 151 if (FLAG_debug_code) {
152 __ Set(rax, slots); 152 __ Set(rax, slots);
153 __ movq(kScratchRegister, kSlotsZapValue, RelocInfo::NONE); 153 __ movq(kScratchRegister, kSlotsZapValue, RelocInfo::NONE);
154 Label loop; 154 Label loop;
155 __ bind(&loop); 155 __ bind(&loop);
156 __ push(kScratchRegister); 156 __ push(kScratchRegister);
157 __ decl(rax); 157 __ decl(rax);
158 __ j(not_zero, &loop); 158 __ j(not_zero, &loop);
159 } else { 159 } else {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 // a long call instruction. Instead it writes a shorter call to a 283 // a long call instruction. Instead it writes a shorter call to a
284 // jump instruction in the same code object. 284 // jump instruction in the same code object.
285 // The calls are used when lazy deoptimizing a function and calls to a 285 // The calls are used when lazy deoptimizing a function and calls to a
286 // deoptimization function. 286 // deoptimization function.
287 int short_deopts = safepoints_.CountShortDeoptimizationIntervals( 287 int short_deopts = safepoints_.CountShortDeoptimizationIntervals(
288 static_cast<unsigned>(MacroAssembler::kJumpInstructionLength)); 288 static_cast<unsigned>(MacroAssembler::kJumpInstructionLength));
289 int byte_count = (short_deopts) * MacroAssembler::kJumpInstructionLength; 289 int byte_count = (short_deopts) * MacroAssembler::kJumpInstructionLength;
290 while (byte_count-- > 0) { 290 while (byte_count-- > 0) {
291 __ int3(); 291 __ int3();
292 } 292 }
293 safepoints_.Emit(masm(), StackSlotCount()); 293 safepoints_.Emit(masm(), GetStackSlotCount());
294 return !is_aborted(); 294 return !is_aborted();
295 } 295 }
296 296
297 297
298 Register LCodeGen::ToRegister(int index) const { 298 Register LCodeGen::ToRegister(int index) const {
299 return Register::FromAllocationIndex(index); 299 return Register::FromAllocationIndex(index);
300 } 300 }
301 301
302 302
303 XMMRegister LCodeGen::ToDoubleRegister(int index) const { 303 XMMRegister LCodeGen::ToDoubleRegister(int index) const {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 } else if (op->IsStackSlot()) { 411 } else if (op->IsStackSlot()) {
412 if (is_tagged) { 412 if (is_tagged) {
413 translation->StoreStackSlot(op->index()); 413 translation->StoreStackSlot(op->index());
414 } else { 414 } else {
415 translation->StoreInt32StackSlot(op->index()); 415 translation->StoreInt32StackSlot(op->index());
416 } 416 }
417 } else if (op->IsDoubleStackSlot()) { 417 } else if (op->IsDoubleStackSlot()) {
418 translation->StoreDoubleStackSlot(op->index()); 418 translation->StoreDoubleStackSlot(op->index());
419 } else if (op->IsArgument()) { 419 } else if (op->IsArgument()) {
420 ASSERT(is_tagged); 420 ASSERT(is_tagged);
421 int src_index = StackSlotCount() + op->index(); 421 int src_index = GetStackSlotCount() + op->index();
422 translation->StoreStackSlot(src_index); 422 translation->StoreStackSlot(src_index);
423 } else if (op->IsRegister()) { 423 } else if (op->IsRegister()) {
424 Register reg = ToRegister(op); 424 Register reg = ToRegister(op);
425 if (is_tagged) { 425 if (is_tagged) {
426 translation->StoreRegister(reg); 426 translation->StoreRegister(reg);
427 } else { 427 } else {
428 translation->StoreInt32Register(reg); 428 translation->StoreInt32Register(reg);
429 } 429 }
430 } else if (op->IsDoubleRegister()) { 430 } else if (op->IsDoubleRegister()) {
431 XMMRegister reg = ToDoubleRegister(op); 431 XMMRegister reg = ToDoubleRegister(op);
(...skipping 1619 matching lines...) Expand 10 before | Expand all | Expand 10 after
2051 2051
2052 void LCodeGen::DoReturn(LReturn* instr) { 2052 void LCodeGen::DoReturn(LReturn* instr) {
2053 if (FLAG_trace) { 2053 if (FLAG_trace) {
2054 // Preserve the return value on the stack and rely on the runtime 2054 // Preserve the return value on the stack and rely on the runtime
2055 // call to return the value in the same register. 2055 // call to return the value in the same register.
2056 __ push(rax); 2056 __ push(rax);
2057 __ CallRuntime(Runtime::kTraceExit, 1); 2057 __ CallRuntime(Runtime::kTraceExit, 1);
2058 } 2058 }
2059 __ movq(rsp, rbp); 2059 __ movq(rsp, rbp);
2060 __ pop(rbp); 2060 __ pop(rbp);
2061 __ Ret((ParameterCount() + 1) * kPointerSize, rcx); 2061 __ Ret((GetParameterCount() + 1) * kPointerSize, rcx);
2062 } 2062 }
2063 2063
2064 2064
2065 void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) { 2065 void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) {
2066 Register result = ToRegister(instr->result()); 2066 Register result = ToRegister(instr->result());
2067 if (result.is(rax)) { 2067 if (result.is(rax)) {
2068 __ load_rax(instr->hydrogen()->cell().location(), 2068 __ load_rax(instr->hydrogen()->cell().location(),
2069 RelocInfo::GLOBAL_PROPERTY_CELL); 2069 RelocInfo::GLOBAL_PROPERTY_CELL);
2070 } else { 2070 } else {
2071 __ movq(result, instr->hydrogen()->cell(), RelocInfo::GLOBAL_PROPERTY_CELL); 2071 __ movq(result, instr->hydrogen()->cell(), RelocInfo::GLOBAL_PROPERTY_CELL);
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
2500 ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment()); 2500 ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment());
2501 LPointerMap* pointers = instr->pointer_map(); 2501 LPointerMap* pointers = instr->pointer_map();
2502 LEnvironment* env = instr->deoptimization_environment(); 2502 LEnvironment* env = instr->deoptimization_environment();
2503 RecordPosition(pointers->position()); 2503 RecordPosition(pointers->position());
2504 RegisterEnvironmentForDeoptimization(env); 2504 RegisterEnvironmentForDeoptimization(env);
2505 SafepointGenerator safepoint_generator(this, 2505 SafepointGenerator safepoint_generator(this,
2506 pointers, 2506 pointers,
2507 env->deoptimization_index()); 2507 env->deoptimization_index());
2508 v8::internal::ParameterCount actual(rax); 2508 v8::internal::ParameterCount actual(rax);
2509 __ InvokeFunction(function, actual, CALL_FUNCTION, &safepoint_generator); 2509 __ InvokeFunction(function, actual, CALL_FUNCTION, &safepoint_generator);
2510 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2510 } 2511 }
2511 2512
2512 2513
2513 void LCodeGen::DoPushArgument(LPushArgument* instr) { 2514 void LCodeGen::DoPushArgument(LPushArgument* instr) {
2514 LOperand* argument = instr->InputAt(0); 2515 LOperand* argument = instr->InputAt(0);
2515 if (argument->IsConstantOperand()) { 2516 if (argument->IsConstantOperand()) {
2516 EmitPushConstantOperand(argument); 2517 EmitPushConstantOperand(argument);
2517 } else if (argument->IsRegister()) { 2518 } else if (argument->IsRegister()) {
2518 __ push(ToRegister(argument)); 2519 __ push(ToRegister(argument));
2519 } else { 2520 } else {
2520 ASSERT(!argument->IsDoubleRegister()); 2521 ASSERT(!argument->IsDoubleRegister());
2521 __ push(ToOperand(argument)); 2522 __ push(ToOperand(argument));
2522 } 2523 }
2523 } 2524 }
2524 2525
2525 2526
2526 void LCodeGen::DoContext(LContext* instr) { 2527 void LCodeGen::DoContext(LContext* instr) {
2527 Register result = ToRegister(instr->result()); 2528 Register result = ToRegister(instr->result());
2528 __ movq(result, Operand(rbp, StandardFrameConstants::kContextOffset)); 2529 __ movq(result, rsi);
2529 } 2530 }
2530 2531
2531 2532
2532 void LCodeGen::DoOuterContext(LOuterContext* instr) { 2533 void LCodeGen::DoOuterContext(LOuterContext* instr) {
2533 Register context = ToRegister(instr->context()); 2534 Register context = ToRegister(instr->context());
2534 Register result = ToRegister(instr->result()); 2535 Register result = ToRegister(instr->result());
2535 __ movq(result, 2536 __ movq(result,
2536 Operand(context, Context::SlotOffset(Context::CLOSURE_INDEX))); 2537 Operand(context, Context::SlotOffset(Context::CLOSURE_INDEX)));
2537 __ movq(result, FieldOperand(result, JSFunction::kContextOffset)); 2538 __ movq(result, FieldOperand(result, JSFunction::kContextOffset));
2538 } 2539 }
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
2885 case kMathLog: 2886 case kMathLog:
2886 DoMathLog(instr); 2887 DoMathLog(instr);
2887 break; 2888 break;
2888 2889
2889 default: 2890 default:
2890 UNREACHABLE(); 2891 UNREACHABLE();
2891 } 2892 }
2892 } 2893 }
2893 2894
2894 2895
2896 void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) {
2897 ASSERT(ToRegister(instr->function()).is(rdi));
2898 ASSERT(instr->HasPointerMap());
2899 ASSERT(instr->HasDeoptimizationEnvironment());
2900 LPointerMap* pointers = instr->pointer_map();
2901 LEnvironment* env = instr->deoptimization_environment();
2902 RecordPosition(pointers->position());
2903 RegisterEnvironmentForDeoptimization(env);
2904 SafepointGenerator generator(this, pointers, env->deoptimization_index());
2905 ParameterCount count(instr->arity());
2906 __ InvokeFunction(rdi, count, CALL_FUNCTION, &generator);
2907 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2908 }
2909
2910
2895 void LCodeGen::DoCallKeyed(LCallKeyed* instr) { 2911 void LCodeGen::DoCallKeyed(LCallKeyed* instr) {
2896 ASSERT(ToRegister(instr->key()).is(rcx)); 2912 ASSERT(ToRegister(instr->key()).is(rcx));
2897 ASSERT(ToRegister(instr->result()).is(rax)); 2913 ASSERT(ToRegister(instr->result()).is(rax));
2898 2914
2899 int arity = instr->arity(); 2915 int arity = instr->arity();
2900 Handle<Code> ic = isolate()->stub_cache()->ComputeKeyedCallInitialize( 2916 Handle<Code> ic = isolate()->stub_cache()->ComputeKeyedCallInitialize(
2901 arity, NOT_IN_LOOP); 2917 arity, NOT_IN_LOOP);
2902 CallCode(ic, RelocInfo::CODE_TARGET, instr); 2918 CallCode(ic, RelocInfo::CODE_TARGET, instr);
2903 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); 2919 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2904 } 2920 }
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after
4006 RegisterEnvironmentForDeoptimization(environment); 4022 RegisterEnvironmentForDeoptimization(environment);
4007 ASSERT(osr_pc_offset_ == -1); 4023 ASSERT(osr_pc_offset_ == -1);
4008 osr_pc_offset_ = masm()->pc_offset(); 4024 osr_pc_offset_ = masm()->pc_offset();
4009 } 4025 }
4010 4026
4011 #undef __ 4027 #undef __
4012 4028
4013 } } // namespace v8::internal 4029 } } // namespace v8::internal
4014 4030
4015 #endif // V8_TARGET_ARCH_X64 4031 #endif // V8_TARGET_ARCH_X64
OLDNEW
« src/hydrogen.cc ('K') | « src/x64/lithium-codegen-x64.h ('k') | src/x64/lithium-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698