blob: 04bcfeb04ce803e21ba62850f0e696b169131a76 [file] [log] [blame]
Andrei Popescu31002712010-02-23 13:46:05 +00001// Copyright 2010 the V8 project authors. All rights reserved.
2// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions are
4// met:
5//
6// * Redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer.
8// * Redistributions in binary form must reproduce the above
9// copyright notice, this list of conditions and the following
10// disclaimer in the documentation and/or other materials provided
11// with the distribution.
12// * Neither the name of Google Inc. nor the names of its
13// contributors may be used to endorse or promote products derived
14// from this software without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28
29
30#include "v8.h"
31
32#include "codegen-inl.h"
33#include "debug.h"
34#include "runtime.h"
35
36namespace v8 {
37namespace internal {
38
39
40#define __ ACCESS_MASM(masm)
41
42
43void Builtins::Generate_Adaptor(MacroAssembler* masm,
44 CFunctionId id,
45 BuiltinExtraArguments extra_args) {
46 UNIMPLEMENTED_MIPS();
47}
48
49
50void Builtins::Generate_ArrayCode(MacroAssembler* masm) {
51 UNIMPLEMENTED_MIPS();
52}
53
54
55void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) {
56 UNIMPLEMENTED_MIPS();
57}
58
59
60void Builtins::Generate_JSConstructCall(MacroAssembler* masm) {
61 UNIMPLEMENTED_MIPS();
62}
63
64
65void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) {
66 UNIMPLEMENTED_MIPS();
67}
68
69
70void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) {
71 UNIMPLEMENTED_MIPS();
72}
73
74
75static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
76 bool is_construct) {
Steve Block6ded16b2010-05-10 14:33:55 +010077 // Called from JSEntryStub::GenerateBody
78
79 // Registers:
80 // a0: entry_address
81 // a1: function
82 // a2: reveiver_pointer
83 // a3: argc
84 // s0: argv
85 //
86 // Stack:
87 // arguments slots
88 // handler frame
89 // entry frame
90 // callee saved registers + ra
91 // 4 args slots
92 // args
93
94 // Clear the context before we push it when entering the JS frame.
95 __ li(cp, Operand(0));
96
97 // Enter an internal frame.
98 __ EnterInternalFrame();
99
100 // Set up the context from the function argument.
101 __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset));
102
103 // Set up the roots register.
104 ExternalReference roots_address = ExternalReference::roots_address();
105 __ li(s6, Operand(roots_address));
106
107 // Push the function and the receiver onto the stack.
108 __ MultiPushReversed(a1.bit() | a2.bit());
109
110 // Copy arguments to the stack in a loop.
111 // a3: argc
112 // s0: argv, ie points to first arg
113 Label loop, entry;
114 __ sll(t0, a3, kPointerSizeLog2);
115 __ add(t2, s0, t0);
116 __ b(&entry);
117 __ nop(); // Branch delay slot nop.
118 // t2 points past last arg.
119 __ bind(&loop);
120 __ lw(t0, MemOperand(s0)); // Read next parameter.
121 __ addiu(s0, s0, kPointerSize);
122 __ lw(t0, MemOperand(t0)); // Dereference handle.
123 __ Push(t0); // Push parameter.
124 __ bind(&entry);
125 __ Branch(ne, &loop, s0, Operand(t2));
126
127 // Registers:
128 // a0: entry_address
129 // a1: function
130 // a2: reveiver_pointer
131 // a3: argc
132 // s0: argv
133 // s6: roots_address
134 //
135 // Stack:
136 // arguments
137 // receiver
138 // function
139 // arguments slots
140 // handler frame
141 // entry frame
142 // callee saved registers + ra
143 // 4 args slots
144 // args
145
146 // Initialize all JavaScript callee-saved registers, since they will be seen
147 // by the garbage collector as part of handlers.
148 __ LoadRoot(t4, Heap::kUndefinedValueRootIndex);
149 __ mov(s1, t4);
150 __ mov(s2, t4);
151 __ mov(s3, t4);
152 __ mov(s4, s4);
153 __ mov(s5, t4);
154 // s6 holds the root address. Do not clobber.
155 // s7 is cp. Do not init.
156
157 // Invoke the code and pass argc as a0.
158 __ mov(a0, a3);
159 if (is_construct) {
160 UNIMPLEMENTED_MIPS();
161 __ break_(0x164);
162 } else {
163 ParameterCount actual(a0);
164 __ InvokeFunction(a1, actual, CALL_FUNCTION);
165 }
166
167 __ LeaveInternalFrame();
168
169 __ Jump(ra);
Andrei Popescu31002712010-02-23 13:46:05 +0000170}
171
172
173void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) {
174 Generate_JSEntryTrampolineHelper(masm, false);
175}
176
177
178void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
179 Generate_JSEntryTrampolineHelper(masm, true);
180}
181
182
183void Builtins::Generate_FunctionCall(MacroAssembler* masm) {
184 UNIMPLEMENTED_MIPS();
185}
186
187
188void Builtins::Generate_FunctionApply(MacroAssembler* masm) {
189 UNIMPLEMENTED_MIPS();
190}
191
192
193void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
194 UNIMPLEMENTED_MIPS();
Steve Block6ded16b2010-05-10 14:33:55 +0100195 __ break_(0x201);
Andrei Popescu31002712010-02-23 13:46:05 +0000196}
197
198
199#undef __
200
201} } // namespace v8::internal
202