OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 Register scratch = ToRegister(instr->TempAt(0)); | |
Rico
2011/02/18 16:49:11
Can't we use our normal kScratchRegister here?
Mads Ager (chromium)
2011/02/21 07:38:35
Done.
| |
2035 ASSERT(receiver.is(rax)); // Used for parameter count. | |
2036 ASSERT(function.is(rdi)); // Required by InvokeFunction. | |
2037 ASSERT(ToRegister(instr->result()).is(rax)); | |
2038 | |
2039 // If the receiver is null or undefined, we have to pass the global object | |
2040 // as a receiver. | |
2041 NearLabel global_object, receiver_ok; | |
2042 __ CompareRoot(receiver, Heap::kNullValueRootIndex); | |
2043 __ j(equal, &global_object); | |
2044 __ CompareRoot(receiver, Heap::kUndefinedValueRootIndex); | |
2045 __ j(equal, &global_object); | |
2046 | |
2047 // The receiver should be a JS object. | |
2048 Condition is_smi = __ CheckSmi(receiver); | |
2049 DeoptimizeIf(is_smi, instr->environment()); | |
2050 __ CmpObjectType(receiver, FIRST_JS_OBJECT_TYPE, scratch); | |
2051 DeoptimizeIf(below, instr->environment()); | |
2052 __ jmp(&receiver_ok); | |
2053 | |
2054 __ bind(&global_object); | |
2055 // TODO(kmillikin): We have a hydrogen value for the global object. See | |
2056 // if it's better to use it than to explicitly fetch it from the context | |
2057 // here. | |
2058 __ movq(receiver, Operand(rbp, StandardFrameConstants::kContextOffset)); | |
2059 __ movq(receiver, ContextOperand(receiver, Context::GLOBAL_INDEX)); | |
2060 __ bind(&receiver_ok); | |
2061 | |
2062 // Copy the arguments to this function possibly from the | |
2063 // adaptor frame below it. | |
2064 const uint32_t kArgumentsLimit = 1 * KB; | |
2065 __ cmpq(length, Immediate(kArgumentsLimit)); | |
2066 DeoptimizeIf(above, instr->environment()); | |
2067 | |
2068 __ push(receiver); | |
2069 __ movq(receiver, length); | |
2070 | |
2071 // Loop through the arguments pushing them onto the execution | |
2072 // stack. | |
2073 NearLabel invoke, loop; | |
2074 // length is a small non-negative integer, due to the test above. | |
2075 __ testl(length, length); | |
2076 __ j(zero, &invoke); | |
2077 __ bind(&loop); | |
2078 __ push(Operand(elements, length, times_pointer_size, 1 * kPointerSize)); | |
2079 __ decl(length); | |
2080 __ j(not_zero, &loop); | |
2081 | |
2082 // Invoke the function. | |
2083 __ bind(&invoke); | |
2084 ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment()); | |
2085 LPointerMap* pointers = instr->pointer_map(); | |
2086 LEnvironment* env = instr->deoptimization_environment(); | |
2087 RecordPosition(pointers->position()); | |
2088 RegisterEnvironmentForDeoptimization(env); | |
2089 SafepointGenerator safepoint_generator(this, | |
2090 pointers, | |
2091 env->deoptimization_index(), | |
2092 true); | |
2093 v8::internal::ParameterCount actual(rax); | |
2094 __ InvokeFunction(function, actual, CALL_FUNCTION, &safepoint_generator); | |
2000 } | 2095 } |
2001 | 2096 |
2002 | 2097 |
2003 void LCodeGen::DoPushArgument(LPushArgument* instr) { | 2098 void LCodeGen::DoPushArgument(LPushArgument* instr) { |
2004 LOperand* argument = instr->InputAt(0); | 2099 LOperand* argument = instr->InputAt(0); |
2005 if (argument->IsConstantOperand()) { | 2100 if (argument->IsConstantOperand()) { |
2006 LConstantOperand* const_op = LConstantOperand::cast(argument); | 2101 LConstantOperand* const_op = LConstantOperand::cast(argument); |
2007 Handle<Object> literal = chunk_->LookupLiteral(const_op); | 2102 Handle<Object> literal = chunk_->LookupLiteral(const_op); |
2008 Representation r = chunk_->LookupLiteralRepresentation(const_op); | 2103 Representation r = chunk_->LookupLiteralRepresentation(const_op); |
2009 if (r.IsInteger32()) { | 2104 if (r.IsInteger32()) { |
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2869 RegisterEnvironmentForDeoptimization(environment); | 2964 RegisterEnvironmentForDeoptimization(environment); |
2870 ASSERT(osr_pc_offset_ == -1); | 2965 ASSERT(osr_pc_offset_ == -1); |
2871 osr_pc_offset_ = masm()->pc_offset(); | 2966 osr_pc_offset_ = masm()->pc_offset(); |
2872 } | 2967 } |
2873 | 2968 |
2874 #undef __ | 2969 #undef __ |
2875 | 2970 |
2876 } } // namespace v8::internal | 2971 } } // namespace v8::internal |
2877 | 2972 |
2878 #endif // V8_TARGET_ARCH_X64 | 2973 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |