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

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

Issue 6469053: x64: implement apply with arguments in lithium backend. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments. Created 9 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/assembler-x64.cc ('k') | src/x64/lithium-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 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 19 matching lines...) Expand all
30 #if defined(V8_TARGET_ARCH_X64) 30 #if defined(V8_TARGET_ARCH_X64)
31 31
32 #include "x64/lithium-codegen-x64.h" 32 #include "x64/lithium-codegen-x64.h"
33 #include "code-stubs.h" 33 #include "code-stubs.h"
34 #include "stub-cache.h" 34 #include "stub-cache.h"
35 35
36 namespace v8 { 36 namespace v8 {
37 namespace internal { 37 namespace internal {
38 38
39 39
40 // When invoking builtins, we need to record the safepoint in the middle of
41 // the invoke instruction sequence generated by the macro assembler.
42 class SafepointGenerator : public PostCallGenerator {
43 public:
44 SafepointGenerator(LCodeGen* codegen,
45 LPointerMap* pointers,
46 int deoptimization_index,
47 bool ensure_reloc_space = false)
48 : codegen_(codegen),
49 pointers_(pointers),
50 deoptimization_index_(deoptimization_index),
51 ensure_reloc_space_(ensure_reloc_space) { }
52 virtual ~SafepointGenerator() { }
53
54 virtual void Generate() {
55 // Ensure that we have enough space in the reloc info to patch
56 // this with calls when doing deoptimization.
57 if (ensure_reloc_space_) {
58 codegen_->masm()->RecordComment(RelocInfo::kFillerCommentString, true);
59 }
60 codegen_->RecordSafepoint(pointers_, deoptimization_index_);
61 }
62
63 private:
64 LCodeGen* codegen_;
65 LPointerMap* pointers_;
66 int deoptimization_index_;
67 bool ensure_reloc_space_;
68 };
69
70
40 #define __ masm()-> 71 #define __ masm()->
41 72
42 bool LCodeGen::GenerateCode() { 73 bool LCodeGen::GenerateCode() {
43 HPhase phase("Code generation", chunk()); 74 HPhase phase("Code generation", chunk());
44 ASSERT(is_unused()); 75 ASSERT(is_unused());
45 status_ = GENERATING; 76 status_ = GENERATING;
46 return GeneratePrologue() && 77 return GeneratePrologue() &&
47 GenerateBody() && 78 GenerateBody() &&
48 GenerateDeferredCode() && 79 GenerateDeferredCode() &&
49 GenerateSafepointTable(); 80 GenerateSafepointTable();
(...skipping 1939 matching lines...) Expand 10 before | Expand all | Expand 10 after
1989 __ movq(result, Operand(result, 2020 __ movq(result, Operand(result,
1990 ArgumentsAdaptorFrameConstants::kLengthOffset)); 2021 ArgumentsAdaptorFrameConstants::kLengthOffset));
1991 __ SmiToInteger32(result, result); 2022 __ SmiToInteger32(result, result);
1992 2023
1993 // Argument length is in result register. 2024 // Argument length is in result register.
1994 __ bind(&done); 2025 __ bind(&done);
1995 } 2026 }
1996 2027
1997 2028
1998 void LCodeGen::DoApplyArguments(LApplyArguments* instr) { 2029 void LCodeGen::DoApplyArguments(LApplyArguments* instr) {
1999 Abort("Unimplemented: %s", "DoApplyArguments"); 2030 Register receiver = ToRegister(instr->receiver());
2031 Register function = ToRegister(instr->function());
2032 Register length = ToRegister(instr->length());
2033 Register elements = ToRegister(instr->elements());
2034 ASSERT(receiver.is(rax)); // Used for parameter count.
2035 ASSERT(function.is(rdi)); // Required by InvokeFunction.
2036 ASSERT(ToRegister(instr->result()).is(rax));
2037
2038 // If the receiver is null or undefined, we have to pass the global object
2039 // as a receiver.
2040 NearLabel global_object, receiver_ok;
2041 __ CompareRoot(receiver, Heap::kNullValueRootIndex);
2042 __ j(equal, &global_object);
2043 __ CompareRoot(receiver, Heap::kUndefinedValueRootIndex);
2044 __ j(equal, &global_object);
2045
2046 // The receiver should be a JS object.
2047 Condition is_smi = __ CheckSmi(receiver);
2048 DeoptimizeIf(is_smi, instr->environment());
2049 __ CmpObjectType(receiver, FIRST_JS_OBJECT_TYPE, kScratchRegister);
2050 DeoptimizeIf(below, instr->environment());
2051 __ jmp(&receiver_ok);
2052
2053 __ bind(&global_object);
2054 // TODO(kmillikin): We have a hydrogen value for the global object. See
2055 // if it's better to use it than to explicitly fetch it from the context
2056 // here.
2057 __ movq(receiver, Operand(rbp, StandardFrameConstants::kContextOffset));
2058 __ movq(receiver, ContextOperand(receiver, Context::GLOBAL_INDEX));
2059 __ bind(&receiver_ok);
2060
2061 // Copy the arguments to this function possibly from the
2062 // adaptor frame below it.
2063 const uint32_t kArgumentsLimit = 1 * KB;
2064 __ cmpq(length, Immediate(kArgumentsLimit));
2065 DeoptimizeIf(above, instr->environment());
2066
2067 __ push(receiver);
2068 __ movq(receiver, length);
2069
2070 // Loop through the arguments pushing them onto the execution
2071 // stack.
2072 NearLabel invoke, loop;
2073 // length is a small non-negative integer, due to the test above.
2074 __ testl(length, length);
2075 __ j(zero, &invoke);
2076 __ bind(&loop);
2077 __ push(Operand(elements, length, times_pointer_size, 1 * kPointerSize));
2078 __ decl(length);
2079 __ j(not_zero, &loop);
2080
2081 // Invoke the function.
2082 __ bind(&invoke);
2083 ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment());
2084 LPointerMap* pointers = instr->pointer_map();
2085 LEnvironment* env = instr->deoptimization_environment();
2086 RecordPosition(pointers->position());
2087 RegisterEnvironmentForDeoptimization(env);
2088 SafepointGenerator safepoint_generator(this,
2089 pointers,
2090 env->deoptimization_index(),
2091 true);
2092 v8::internal::ParameterCount actual(rax);
2093 __ InvokeFunction(function, actual, CALL_FUNCTION, &safepoint_generator);
2000 } 2094 }
2001 2095
2002 2096
2003 void LCodeGen::DoPushArgument(LPushArgument* instr) { 2097 void LCodeGen::DoPushArgument(LPushArgument* instr) {
2004 LOperand* argument = instr->InputAt(0); 2098 LOperand* argument = instr->InputAt(0);
2005 if (argument->IsConstantOperand()) { 2099 if (argument->IsConstantOperand()) {
2006 LConstantOperand* const_op = LConstantOperand::cast(argument); 2100 LConstantOperand* const_op = LConstantOperand::cast(argument);
2007 Handle<Object> literal = chunk_->LookupLiteral(const_op); 2101 Handle<Object> literal = chunk_->LookupLiteral(const_op);
2008 Representation r = chunk_->LookupLiteralRepresentation(const_op); 2102 Representation r = chunk_->LookupLiteralRepresentation(const_op);
2009 if (r.IsInteger32()) { 2103 if (r.IsInteger32()) {
(...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after
3139 RegisterEnvironmentForDeoptimization(environment); 3233 RegisterEnvironmentForDeoptimization(environment);
3140 ASSERT(osr_pc_offset_ == -1); 3234 ASSERT(osr_pc_offset_ == -1);
3141 osr_pc_offset_ = masm()->pc_offset(); 3235 osr_pc_offset_ = masm()->pc_offset();
3142 } 3236 }
3143 3237
3144 #undef __ 3238 #undef __
3145 3239
3146 } } // namespace v8::internal 3240 } } // namespace v8::internal
3147 3241
3148 #endif // V8_TARGET_ARCH_X64 3242 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/assembler-x64.cc ('k') | src/x64/lithium-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698