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

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

Issue 6869005: Land Kevin's patch for supporting %_CallFunction in Crankshaft. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: 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
« no previous file with comments | « src/x64/lithium-codegen-x64.h ('k') | src/x64/lithium-x64.h » ('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 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 EmitPushTaggedOperand(argument); 2516 EmitPushTaggedOperand(argument);
2516 } 2517 }
2517 2518
2518 2519
2519 void LCodeGen::DoContext(LContext* instr) { 2520 void LCodeGen::DoContext(LContext* instr) {
2520 Register result = ToRegister(instr->result()); 2521 Register result = ToRegister(instr->result());
2521 __ movq(result, Operand(rbp, StandardFrameConstants::kContextOffset)); 2522 __ movq(result, rsi);
2522 } 2523 }
2523 2524
2524 2525
2525 void LCodeGen::DoOuterContext(LOuterContext* instr) { 2526 void LCodeGen::DoOuterContext(LOuterContext* instr) {
2526 Register context = ToRegister(instr->context()); 2527 Register context = ToRegister(instr->context());
2527 Register result = ToRegister(instr->result()); 2528 Register result = ToRegister(instr->result());
2528 __ movq(result, 2529 __ movq(result,
2529 Operand(context, Context::SlotOffset(Context::CLOSURE_INDEX))); 2530 Operand(context, Context::SlotOffset(Context::CLOSURE_INDEX)));
2530 __ movq(result, FieldOperand(result, JSFunction::kContextOffset)); 2531 __ movq(result, FieldOperand(result, JSFunction::kContextOffset));
2531 } 2532 }
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
2893 case kMathLog: 2894 case kMathLog:
2894 DoMathLog(instr); 2895 DoMathLog(instr);
2895 break; 2896 break;
2896 2897
2897 default: 2898 default:
2898 UNREACHABLE(); 2899 UNREACHABLE();
2899 } 2900 }
2900 } 2901 }
2901 2902
2902 2903
2904 void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) {
2905 ASSERT(ToRegister(instr->function()).is(rdi));
2906 ASSERT(instr->HasPointerMap());
2907 ASSERT(instr->HasDeoptimizationEnvironment());
2908 LPointerMap* pointers = instr->pointer_map();
2909 LEnvironment* env = instr->deoptimization_environment();
2910 RecordPosition(pointers->position());
2911 RegisterEnvironmentForDeoptimization(env);
2912 SafepointGenerator generator(this, pointers, env->deoptimization_index());
2913 ParameterCount count(instr->arity());
2914 __ InvokeFunction(rdi, count, CALL_FUNCTION, &generator);
2915 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2916 }
2917
2918
2903 void LCodeGen::DoCallKeyed(LCallKeyed* instr) { 2919 void LCodeGen::DoCallKeyed(LCallKeyed* instr) {
2904 ASSERT(ToRegister(instr->key()).is(rcx)); 2920 ASSERT(ToRegister(instr->key()).is(rcx));
2905 ASSERT(ToRegister(instr->result()).is(rax)); 2921 ASSERT(ToRegister(instr->result()).is(rax));
2906 2922
2907 int arity = instr->arity(); 2923 int arity = instr->arity();
2908 Handle<Code> ic = isolate()->stub_cache()->ComputeKeyedCallInitialize( 2924 Handle<Code> ic = isolate()->stub_cache()->ComputeKeyedCallInitialize(
2909 arity, NOT_IN_LOOP); 2925 arity, NOT_IN_LOOP);
2910 CallCode(ic, RelocInfo::CODE_TARGET, instr); 2926 CallCode(ic, RelocInfo::CODE_TARGET, instr);
2911 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); 2927 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2912 } 2928 }
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after
3998 RegisterEnvironmentForDeoptimization(environment); 4014 RegisterEnvironmentForDeoptimization(environment);
3999 ASSERT(osr_pc_offset_ == -1); 4015 ASSERT(osr_pc_offset_ == -1);
4000 osr_pc_offset_ = masm()->pc_offset(); 4016 osr_pc_offset_ = masm()->pc_offset();
4001 } 4017 }
4002 4018
4003 #undef __ 4019 #undef __
4004 4020
4005 } } // namespace v8::internal 4021 } } // namespace v8::internal
4006 4022
4007 #endif // V8_TARGET_ARCH_X64 4023 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « 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