OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 22 matching lines...) Expand all Loading... |
33 #include "code-stubs.h" | 33 #include "code-stubs.h" |
34 #include "regexp-macro-assembler.h" | 34 #include "regexp-macro-assembler.h" |
35 #include "stub-cache.h" | 35 #include "stub-cache.h" |
36 #include "runtime.h" | 36 #include "runtime.h" |
37 | 37 |
38 namespace v8 { | 38 namespace v8 { |
39 namespace internal { | 39 namespace internal { |
40 | 40 |
41 | 41 |
42 void FastNewClosureStub::InitializeInterfaceDescriptor( | 42 void FastNewClosureStub::InitializeInterfaceDescriptor( |
43 Isolate* isolate, | |
44 CodeStubInterfaceDescriptor* descriptor) { | 43 CodeStubInterfaceDescriptor* descriptor) { |
45 static Register registers[] = { rbx }; | 44 static Register registers[] = { rbx }; |
46 descriptor->register_param_count_ = 1; | 45 descriptor->register_param_count_ = 1; |
47 descriptor->register_params_ = registers; | 46 descriptor->register_params_ = registers; |
48 descriptor->deoptimization_handler_ = | 47 descriptor->deoptimization_handler_ = |
49 Runtime::FunctionForId(Runtime::kHiddenNewClosureFromStubFailure)->entry; | 48 Runtime::FunctionForId(Runtime::kHiddenNewClosureFromStubFailure)->entry; |
50 } | 49 } |
51 | 50 |
52 | 51 |
53 void FastNewContextStub::InitializeInterfaceDescriptor( | 52 void FastNewContextStub::InitializeInterfaceDescriptor( |
54 Isolate* isolate, | |
55 CodeStubInterfaceDescriptor* descriptor) { | 53 CodeStubInterfaceDescriptor* descriptor) { |
56 static Register registers[] = { rdi }; | 54 static Register registers[] = { rdi }; |
57 descriptor->register_param_count_ = 1; | 55 descriptor->register_param_count_ = 1; |
58 descriptor->register_params_ = registers; | 56 descriptor->register_params_ = registers; |
59 descriptor->deoptimization_handler_ = NULL; | 57 descriptor->deoptimization_handler_ = NULL; |
60 } | 58 } |
61 | 59 |
62 | 60 |
63 void ToNumberStub::InitializeInterfaceDescriptor( | 61 void ToNumberStub::InitializeInterfaceDescriptor( |
64 Isolate* isolate, | |
65 CodeStubInterfaceDescriptor* descriptor) { | 62 CodeStubInterfaceDescriptor* descriptor) { |
66 static Register registers[] = { rax }; | 63 static Register registers[] = { rax }; |
67 descriptor->register_param_count_ = 1; | 64 descriptor->register_param_count_ = 1; |
68 descriptor->register_params_ = registers; | 65 descriptor->register_params_ = registers; |
69 descriptor->deoptimization_handler_ = NULL; | 66 descriptor->deoptimization_handler_ = NULL; |
70 } | 67 } |
71 | 68 |
72 | 69 |
73 void NumberToStringStub::InitializeInterfaceDescriptor( | 70 void NumberToStringStub::InitializeInterfaceDescriptor( |
74 Isolate* isolate, | |
75 CodeStubInterfaceDescriptor* descriptor) { | 71 CodeStubInterfaceDescriptor* descriptor) { |
76 static Register registers[] = { rax }; | 72 static Register registers[] = { rax }; |
77 descriptor->register_param_count_ = 1; | 73 descriptor->register_param_count_ = 1; |
78 descriptor->register_params_ = registers; | 74 descriptor->register_params_ = registers; |
79 descriptor->deoptimization_handler_ = | 75 descriptor->deoptimization_handler_ = |
80 Runtime::FunctionForId(Runtime::kHiddenNumberToString)->entry; | 76 Runtime::FunctionForId(Runtime::kHiddenNumberToString)->entry; |
81 } | 77 } |
82 | 78 |
83 | 79 |
84 void FastCloneShallowArrayStub::InitializeInterfaceDescriptor( | 80 void FastCloneShallowArrayStub::InitializeInterfaceDescriptor( |
85 Isolate* isolate, | |
86 CodeStubInterfaceDescriptor* descriptor) { | 81 CodeStubInterfaceDescriptor* descriptor) { |
87 static Register registers[] = { rax, rbx, rcx }; | 82 static Register registers[] = { rax, rbx, rcx }; |
88 descriptor->register_param_count_ = 3; | 83 descriptor->register_param_count_ = 3; |
89 descriptor->register_params_ = registers; | 84 descriptor->register_params_ = registers; |
90 descriptor->deoptimization_handler_ = | 85 descriptor->deoptimization_handler_ = |
91 Runtime::FunctionForId( | 86 Runtime::FunctionForId( |
92 Runtime::kHiddenCreateArrayLiteralStubBailout)->entry; | 87 Runtime::kHiddenCreateArrayLiteralStubBailout)->entry; |
93 } | 88 } |
94 | 89 |
95 | 90 |
96 void FastCloneShallowObjectStub::InitializeInterfaceDescriptor( | 91 void FastCloneShallowObjectStub::InitializeInterfaceDescriptor( |
97 Isolate* isolate, | |
98 CodeStubInterfaceDescriptor* descriptor) { | 92 CodeStubInterfaceDescriptor* descriptor) { |
99 static Register registers[] = { rax, rbx, rcx, rdx }; | 93 static Register registers[] = { rax, rbx, rcx, rdx }; |
100 descriptor->register_param_count_ = 4; | 94 descriptor->register_param_count_ = 4; |
101 descriptor->register_params_ = registers; | 95 descriptor->register_params_ = registers; |
102 descriptor->deoptimization_handler_ = | 96 descriptor->deoptimization_handler_ = |
103 Runtime::FunctionForId(Runtime::kHiddenCreateObjectLiteral)->entry; | 97 Runtime::FunctionForId(Runtime::kHiddenCreateObjectLiteral)->entry; |
104 } | 98 } |
105 | 99 |
106 | 100 |
107 void CreateAllocationSiteStub::InitializeInterfaceDescriptor( | 101 void CreateAllocationSiteStub::InitializeInterfaceDescriptor( |
108 Isolate* isolate, | |
109 CodeStubInterfaceDescriptor* descriptor) { | 102 CodeStubInterfaceDescriptor* descriptor) { |
110 static Register registers[] = { rbx, rdx }; | 103 static Register registers[] = { rbx, rdx }; |
111 descriptor->register_param_count_ = 2; | 104 descriptor->register_param_count_ = 2; |
112 descriptor->register_params_ = registers; | 105 descriptor->register_params_ = registers; |
113 descriptor->deoptimization_handler_ = NULL; | 106 descriptor->deoptimization_handler_ = NULL; |
114 } | 107 } |
115 | 108 |
116 | 109 |
117 void KeyedLoadFastElementStub::InitializeInterfaceDescriptor( | 110 void KeyedLoadFastElementStub::InitializeInterfaceDescriptor( |
118 Isolate* isolate, | |
119 CodeStubInterfaceDescriptor* descriptor) { | 111 CodeStubInterfaceDescriptor* descriptor) { |
120 static Register registers[] = { rdx, rax }; | 112 static Register registers[] = { rdx, rax }; |
121 descriptor->register_param_count_ = 2; | 113 descriptor->register_param_count_ = 2; |
122 descriptor->register_params_ = registers; | 114 descriptor->register_params_ = registers; |
123 descriptor->deoptimization_handler_ = | 115 descriptor->deoptimization_handler_ = |
124 FUNCTION_ADDR(KeyedLoadIC_MissFromStubFailure); | 116 FUNCTION_ADDR(KeyedLoadIC_MissFromStubFailure); |
125 } | 117 } |
126 | 118 |
127 | 119 |
128 void KeyedLoadDictionaryElementStub::InitializeInterfaceDescriptor( | 120 void KeyedLoadDictionaryElementStub::InitializeInterfaceDescriptor( |
129 Isolate* isolate, | |
130 CodeStubInterfaceDescriptor* descriptor) { | 121 CodeStubInterfaceDescriptor* descriptor) { |
131 static Register registers[] = { rdx, rax }; | 122 static Register registers[] = { rdx, rax }; |
132 descriptor->register_param_count_ = 2; | 123 descriptor->register_param_count_ = 2; |
133 descriptor->register_params_ = registers; | 124 descriptor->register_params_ = registers; |
134 descriptor->deoptimization_handler_ = | 125 descriptor->deoptimization_handler_ = |
135 FUNCTION_ADDR(KeyedLoadIC_MissFromStubFailure); | 126 FUNCTION_ADDR(KeyedLoadIC_MissFromStubFailure); |
136 } | 127 } |
137 | 128 |
138 | 129 |
139 void RegExpConstructResultStub::InitializeInterfaceDescriptor( | 130 void RegExpConstructResultStub::InitializeInterfaceDescriptor( |
140 Isolate* isolate, | |
141 CodeStubInterfaceDescriptor* descriptor) { | 131 CodeStubInterfaceDescriptor* descriptor) { |
142 static Register registers[] = { rcx, rbx, rax }; | 132 static Register registers[] = { rcx, rbx, rax }; |
143 descriptor->register_param_count_ = 3; | 133 descriptor->register_param_count_ = 3; |
144 descriptor->register_params_ = registers; | 134 descriptor->register_params_ = registers; |
145 descriptor->deoptimization_handler_ = | 135 descriptor->deoptimization_handler_ = |
146 Runtime::FunctionForId(Runtime::kHiddenRegExpConstructResult)->entry; | 136 Runtime::FunctionForId(Runtime::kHiddenRegExpConstructResult)->entry; |
147 } | 137 } |
148 | 138 |
149 | 139 |
150 void LoadFieldStub::InitializeInterfaceDescriptor( | 140 void LoadFieldStub::InitializeInterfaceDescriptor( |
151 Isolate* isolate, | |
152 CodeStubInterfaceDescriptor* descriptor) { | 141 CodeStubInterfaceDescriptor* descriptor) { |
153 static Register registers[] = { rax }; | 142 static Register registers[] = { rax }; |
154 descriptor->register_param_count_ = 1; | 143 descriptor->register_param_count_ = 1; |
155 descriptor->register_params_ = registers; | 144 descriptor->register_params_ = registers; |
156 descriptor->deoptimization_handler_ = NULL; | 145 descriptor->deoptimization_handler_ = NULL; |
157 } | 146 } |
158 | 147 |
159 | 148 |
160 void KeyedLoadFieldStub::InitializeInterfaceDescriptor( | 149 void KeyedLoadFieldStub::InitializeInterfaceDescriptor( |
161 Isolate* isolate, | |
162 CodeStubInterfaceDescriptor* descriptor) { | 150 CodeStubInterfaceDescriptor* descriptor) { |
163 static Register registers[] = { rdx }; | 151 static Register registers[] = { rdx }; |
164 descriptor->register_param_count_ = 1; | 152 descriptor->register_param_count_ = 1; |
165 descriptor->register_params_ = registers; | 153 descriptor->register_params_ = registers; |
166 descriptor->deoptimization_handler_ = NULL; | 154 descriptor->deoptimization_handler_ = NULL; |
167 } | 155 } |
168 | 156 |
169 | 157 |
170 void StringLengthStub::InitializeInterfaceDescriptor( | 158 void StringLengthStub::InitializeInterfaceDescriptor( |
171 Isolate* isolate, | |
172 CodeStubInterfaceDescriptor* descriptor) { | 159 CodeStubInterfaceDescriptor* descriptor) { |
173 static Register registers[] = { rax, rcx }; | 160 static Register registers[] = { rax, rcx }; |
174 descriptor->register_param_count_ = 2; | 161 descriptor->register_param_count_ = 2; |
175 descriptor->register_params_ = registers; | 162 descriptor->register_params_ = registers; |
176 descriptor->deoptimization_handler_ = NULL; | 163 descriptor->deoptimization_handler_ = NULL; |
177 } | 164 } |
178 | 165 |
179 | 166 |
180 void KeyedStringLengthStub::InitializeInterfaceDescriptor( | 167 void KeyedStringLengthStub::InitializeInterfaceDescriptor( |
181 Isolate* isolate, | |
182 CodeStubInterfaceDescriptor* descriptor) { | 168 CodeStubInterfaceDescriptor* descriptor) { |
183 static Register registers[] = { rdx, rax }; | 169 static Register registers[] = { rdx, rax }; |
184 descriptor->register_param_count_ = 2; | 170 descriptor->register_param_count_ = 2; |
185 descriptor->register_params_ = registers; | 171 descriptor->register_params_ = registers; |
186 descriptor->deoptimization_handler_ = NULL; | 172 descriptor->deoptimization_handler_ = NULL; |
187 } | 173 } |
188 | 174 |
189 | 175 |
190 void KeyedStoreFastElementStub::InitializeInterfaceDescriptor( | 176 void KeyedStoreFastElementStub::InitializeInterfaceDescriptor( |
191 Isolate* isolate, | |
192 CodeStubInterfaceDescriptor* descriptor) { | 177 CodeStubInterfaceDescriptor* descriptor) { |
193 static Register registers[] = { rdx, rcx, rax }; | 178 static Register registers[] = { rdx, rcx, rax }; |
194 descriptor->register_param_count_ = 3; | 179 descriptor->register_param_count_ = 3; |
195 descriptor->register_params_ = registers; | 180 descriptor->register_params_ = registers; |
196 descriptor->deoptimization_handler_ = | 181 descriptor->deoptimization_handler_ = |
197 FUNCTION_ADDR(KeyedStoreIC_MissFromStubFailure); | 182 FUNCTION_ADDR(KeyedStoreIC_MissFromStubFailure); |
198 } | 183 } |
199 | 184 |
200 | 185 |
201 void TransitionElementsKindStub::InitializeInterfaceDescriptor( | 186 void TransitionElementsKindStub::InitializeInterfaceDescriptor( |
202 Isolate* isolate, | |
203 CodeStubInterfaceDescriptor* descriptor) { | 187 CodeStubInterfaceDescriptor* descriptor) { |
204 static Register registers[] = { rax, rbx }; | 188 static Register registers[] = { rax, rbx }; |
205 descriptor->register_param_count_ = 2; | 189 descriptor->register_param_count_ = 2; |
206 descriptor->register_params_ = registers; | 190 descriptor->register_params_ = registers; |
207 descriptor->deoptimization_handler_ = | 191 descriptor->deoptimization_handler_ = |
208 Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry; | 192 Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry; |
209 } | 193 } |
210 | 194 |
211 | 195 |
212 static void InitializeArrayConstructorDescriptor( | 196 static void InitializeArrayConstructorDescriptor( |
213 Isolate* isolate, | |
214 CodeStubInterfaceDescriptor* descriptor, | 197 CodeStubInterfaceDescriptor* descriptor, |
215 int constant_stack_parameter_count) { | 198 int constant_stack_parameter_count) { |
216 // register state | 199 // register state |
217 // rax -- number of arguments | 200 // rax -- number of arguments |
218 // rdi -- function | 201 // rdi -- function |
219 // rbx -- allocation site with elements kind | 202 // rbx -- allocation site with elements kind |
220 static Register registers_variable_args[] = { rdi, rbx, rax }; | 203 static Register registers_variable_args[] = { rdi, rbx, rax }; |
221 static Register registers_no_args[] = { rdi, rbx }; | 204 static Register registers_no_args[] = { rdi, rbx }; |
222 | 205 |
223 if (constant_stack_parameter_count == 0) { | 206 if (constant_stack_parameter_count == 0) { |
224 descriptor->register_param_count_ = 2; | 207 descriptor->register_param_count_ = 2; |
225 descriptor->register_params_ = registers_no_args; | 208 descriptor->register_params_ = registers_no_args; |
226 } else { | 209 } else { |
227 // stack param count needs (constructor pointer, and single argument) | 210 // stack param count needs (constructor pointer, and single argument) |
228 descriptor->handler_arguments_mode_ = PASS_ARGUMENTS; | 211 descriptor->handler_arguments_mode_ = PASS_ARGUMENTS; |
229 descriptor->stack_parameter_count_ = rax; | 212 descriptor->stack_parameter_count_ = rax; |
230 descriptor->register_param_count_ = 3; | 213 descriptor->register_param_count_ = 3; |
231 descriptor->register_params_ = registers_variable_args; | 214 descriptor->register_params_ = registers_variable_args; |
232 } | 215 } |
233 | 216 |
234 descriptor->hint_stack_parameter_count_ = constant_stack_parameter_count; | 217 descriptor->hint_stack_parameter_count_ = constant_stack_parameter_count; |
235 descriptor->function_mode_ = JS_FUNCTION_STUB_MODE; | 218 descriptor->function_mode_ = JS_FUNCTION_STUB_MODE; |
236 descriptor->deoptimization_handler_ = | 219 descriptor->deoptimization_handler_ = |
237 Runtime::FunctionForId(Runtime::kHiddenArrayConstructor)->entry; | 220 Runtime::FunctionForId(Runtime::kHiddenArrayConstructor)->entry; |
238 } | 221 } |
239 | 222 |
240 | 223 |
241 static void InitializeInternalArrayConstructorDescriptor( | 224 static void InitializeInternalArrayConstructorDescriptor( |
242 Isolate* isolate, | |
243 CodeStubInterfaceDescriptor* descriptor, | 225 CodeStubInterfaceDescriptor* descriptor, |
244 int constant_stack_parameter_count) { | 226 int constant_stack_parameter_count) { |
245 // register state | 227 // register state |
246 // rax -- number of arguments | 228 // rax -- number of arguments |
247 // rdi -- constructor function | 229 // rdi -- constructor function |
248 static Register registers_variable_args[] = { rdi, rax }; | 230 static Register registers_variable_args[] = { rdi, rax }; |
249 static Register registers_no_args[] = { rdi }; | 231 static Register registers_no_args[] = { rdi }; |
250 | 232 |
251 if (constant_stack_parameter_count == 0) { | 233 if (constant_stack_parameter_count == 0) { |
252 descriptor->register_param_count_ = 1; | 234 descriptor->register_param_count_ = 1; |
253 descriptor->register_params_ = registers_no_args; | 235 descriptor->register_params_ = registers_no_args; |
254 } else { | 236 } else { |
255 // stack param count needs (constructor pointer, and single argument) | 237 // stack param count needs (constructor pointer, and single argument) |
256 descriptor->handler_arguments_mode_ = PASS_ARGUMENTS; | 238 descriptor->handler_arguments_mode_ = PASS_ARGUMENTS; |
257 descriptor->stack_parameter_count_ = rax; | 239 descriptor->stack_parameter_count_ = rax; |
258 descriptor->register_param_count_ = 2; | 240 descriptor->register_param_count_ = 2; |
259 descriptor->register_params_ = registers_variable_args; | 241 descriptor->register_params_ = registers_variable_args; |
260 } | 242 } |
261 | 243 |
262 descriptor->hint_stack_parameter_count_ = constant_stack_parameter_count; | 244 descriptor->hint_stack_parameter_count_ = constant_stack_parameter_count; |
263 descriptor->function_mode_ = JS_FUNCTION_STUB_MODE; | 245 descriptor->function_mode_ = JS_FUNCTION_STUB_MODE; |
264 descriptor->deoptimization_handler_ = | 246 descriptor->deoptimization_handler_ = |
265 Runtime::FunctionForId(Runtime::kHiddenInternalArrayConstructor)->entry; | 247 Runtime::FunctionForId(Runtime::kHiddenInternalArrayConstructor)->entry; |
266 } | 248 } |
267 | 249 |
268 | 250 |
269 void ArrayNoArgumentConstructorStub::InitializeInterfaceDescriptor( | 251 void ArrayNoArgumentConstructorStub::InitializeInterfaceDescriptor( |
270 Isolate* isolate, | |
271 CodeStubInterfaceDescriptor* descriptor) { | 252 CodeStubInterfaceDescriptor* descriptor) { |
272 InitializeArrayConstructorDescriptor(isolate, descriptor, 0); | 253 InitializeArrayConstructorDescriptor(descriptor, 0); |
273 } | 254 } |
274 | 255 |
275 | 256 |
276 void ArraySingleArgumentConstructorStub::InitializeInterfaceDescriptor( | 257 void ArraySingleArgumentConstructorStub::InitializeInterfaceDescriptor( |
277 Isolate* isolate, | |
278 CodeStubInterfaceDescriptor* descriptor) { | 258 CodeStubInterfaceDescriptor* descriptor) { |
279 InitializeArrayConstructorDescriptor(isolate, descriptor, 1); | 259 InitializeArrayConstructorDescriptor(descriptor, 1); |
280 } | 260 } |
281 | 261 |
282 | 262 |
283 void ArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor( | 263 void ArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor( |
284 Isolate* isolate, | |
285 CodeStubInterfaceDescriptor* descriptor) { | 264 CodeStubInterfaceDescriptor* descriptor) { |
286 InitializeArrayConstructorDescriptor(isolate, descriptor, -1); | 265 InitializeArrayConstructorDescriptor(descriptor, -1); |
287 } | 266 } |
288 | 267 |
289 | 268 |
290 void InternalArrayNoArgumentConstructorStub::InitializeInterfaceDescriptor( | 269 void InternalArrayNoArgumentConstructorStub::InitializeInterfaceDescriptor( |
291 Isolate* isolate, | |
292 CodeStubInterfaceDescriptor* descriptor) { | 270 CodeStubInterfaceDescriptor* descriptor) { |
293 InitializeInternalArrayConstructorDescriptor(isolate, descriptor, 0); | 271 InitializeInternalArrayConstructorDescriptor(descriptor, 0); |
294 } | 272 } |
295 | 273 |
296 | 274 |
297 void InternalArraySingleArgumentConstructorStub::InitializeInterfaceDescriptor( | 275 void InternalArraySingleArgumentConstructorStub::InitializeInterfaceDescriptor( |
298 Isolate* isolate, | |
299 CodeStubInterfaceDescriptor* descriptor) { | 276 CodeStubInterfaceDescriptor* descriptor) { |
300 InitializeInternalArrayConstructorDescriptor(isolate, descriptor, 1); | 277 InitializeInternalArrayConstructorDescriptor(descriptor, 1); |
301 } | 278 } |
302 | 279 |
303 | 280 |
304 void InternalArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor( | 281 void InternalArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor( |
305 Isolate* isolate, | |
306 CodeStubInterfaceDescriptor* descriptor) { | 282 CodeStubInterfaceDescriptor* descriptor) { |
307 InitializeInternalArrayConstructorDescriptor(isolate, descriptor, -1); | 283 InitializeInternalArrayConstructorDescriptor(descriptor, -1); |
308 } | 284 } |
309 | 285 |
310 | 286 |
311 void CompareNilICStub::InitializeInterfaceDescriptor( | 287 void CompareNilICStub::InitializeInterfaceDescriptor( |
312 Isolate* isolate, | |
313 CodeStubInterfaceDescriptor* descriptor) { | 288 CodeStubInterfaceDescriptor* descriptor) { |
314 static Register registers[] = { rax }; | 289 static Register registers[] = { rax }; |
315 descriptor->register_param_count_ = 1; | 290 descriptor->register_param_count_ = 1; |
316 descriptor->register_params_ = registers; | 291 descriptor->register_params_ = registers; |
317 descriptor->deoptimization_handler_ = | 292 descriptor->deoptimization_handler_ = |
318 FUNCTION_ADDR(CompareNilIC_Miss); | 293 FUNCTION_ADDR(CompareNilIC_Miss); |
319 descriptor->SetMissHandler( | 294 descriptor->SetMissHandler( |
320 ExternalReference(IC_Utility(IC::kCompareNilIC_Miss), isolate)); | 295 ExternalReference(IC_Utility(IC::kCompareNilIC_Miss), isolate())); |
321 } | 296 } |
322 | 297 |
323 | 298 |
324 void ToBooleanStub::InitializeInterfaceDescriptor( | 299 void ToBooleanStub::InitializeInterfaceDescriptor( |
325 Isolate* isolate, | |
326 CodeStubInterfaceDescriptor* descriptor) { | 300 CodeStubInterfaceDescriptor* descriptor) { |
327 static Register registers[] = { rax }; | 301 static Register registers[] = { rax }; |
328 descriptor->register_param_count_ = 1; | 302 descriptor->register_param_count_ = 1; |
329 descriptor->register_params_ = registers; | 303 descriptor->register_params_ = registers; |
330 descriptor->deoptimization_handler_ = | 304 descriptor->deoptimization_handler_ = |
331 FUNCTION_ADDR(ToBooleanIC_Miss); | 305 FUNCTION_ADDR(ToBooleanIC_Miss); |
332 descriptor->SetMissHandler( | 306 descriptor->SetMissHandler( |
333 ExternalReference(IC_Utility(IC::kToBooleanIC_Miss), isolate)); | 307 ExternalReference(IC_Utility(IC::kToBooleanIC_Miss), isolate())); |
334 } | 308 } |
335 | 309 |
336 | 310 |
337 void StoreGlobalStub::InitializeInterfaceDescriptor( | 311 void StoreGlobalStub::InitializeInterfaceDescriptor( |
338 Isolate* isolate, | |
339 CodeStubInterfaceDescriptor* descriptor) { | 312 CodeStubInterfaceDescriptor* descriptor) { |
340 static Register registers[] = { rdx, rcx, rax }; | 313 static Register registers[] = { rdx, rcx, rax }; |
341 descriptor->register_param_count_ = 3; | 314 descriptor->register_param_count_ = 3; |
342 descriptor->register_params_ = registers; | 315 descriptor->register_params_ = registers; |
343 descriptor->deoptimization_handler_ = | 316 descriptor->deoptimization_handler_ = |
344 FUNCTION_ADDR(StoreIC_MissFromStubFailure); | 317 FUNCTION_ADDR(StoreIC_MissFromStubFailure); |
345 } | 318 } |
346 | 319 |
347 | 320 |
348 void ElementsTransitionAndStoreStub::InitializeInterfaceDescriptor( | 321 void ElementsTransitionAndStoreStub::InitializeInterfaceDescriptor( |
349 Isolate* isolate, | |
350 CodeStubInterfaceDescriptor* descriptor) { | 322 CodeStubInterfaceDescriptor* descriptor) { |
351 static Register registers[] = { rax, rbx, rcx, rdx }; | 323 static Register registers[] = { rax, rbx, rcx, rdx }; |
352 descriptor->register_param_count_ = 4; | 324 descriptor->register_param_count_ = 4; |
353 descriptor->register_params_ = registers; | 325 descriptor->register_params_ = registers; |
354 descriptor->deoptimization_handler_ = | 326 descriptor->deoptimization_handler_ = |
355 FUNCTION_ADDR(ElementsTransitionAndStoreIC_Miss); | 327 FUNCTION_ADDR(ElementsTransitionAndStoreIC_Miss); |
356 } | 328 } |
357 | 329 |
358 | 330 |
359 void BinaryOpICStub::InitializeInterfaceDescriptor( | 331 void BinaryOpICStub::InitializeInterfaceDescriptor( |
360 Isolate* isolate, | |
361 CodeStubInterfaceDescriptor* descriptor) { | 332 CodeStubInterfaceDescriptor* descriptor) { |
362 static Register registers[] = { rdx, rax }; | 333 static Register registers[] = { rdx, rax }; |
363 descriptor->register_param_count_ = 2; | 334 descriptor->register_param_count_ = 2; |
364 descriptor->register_params_ = registers; | 335 descriptor->register_params_ = registers; |
365 descriptor->deoptimization_handler_ = FUNCTION_ADDR(BinaryOpIC_Miss); | 336 descriptor->deoptimization_handler_ = FUNCTION_ADDR(BinaryOpIC_Miss); |
366 descriptor->SetMissHandler( | 337 descriptor->SetMissHandler( |
367 ExternalReference(IC_Utility(IC::kBinaryOpIC_Miss), isolate)); | 338 ExternalReference(IC_Utility(IC::kBinaryOpIC_Miss), isolate())); |
368 } | 339 } |
369 | 340 |
370 | 341 |
371 void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor( | 342 void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor( |
372 Isolate* isolate, | |
373 CodeStubInterfaceDescriptor* descriptor) { | 343 CodeStubInterfaceDescriptor* descriptor) { |
374 static Register registers[] = { rcx, rdx, rax }; | 344 static Register registers[] = { rcx, rdx, rax }; |
375 descriptor->register_param_count_ = 3; | 345 descriptor->register_param_count_ = 3; |
376 descriptor->register_params_ = registers; | 346 descriptor->register_params_ = registers; |
377 descriptor->deoptimization_handler_ = | 347 descriptor->deoptimization_handler_ = |
378 FUNCTION_ADDR(BinaryOpIC_MissWithAllocationSite); | 348 FUNCTION_ADDR(BinaryOpIC_MissWithAllocationSite); |
379 } | 349 } |
380 | 350 |
381 | 351 |
382 void StringAddStub::InitializeInterfaceDescriptor( | 352 void StringAddStub::InitializeInterfaceDescriptor( |
383 Isolate* isolate, | |
384 CodeStubInterfaceDescriptor* descriptor) { | 353 CodeStubInterfaceDescriptor* descriptor) { |
385 static Register registers[] = { rdx, rax }; | 354 static Register registers[] = { rdx, rax }; |
386 descriptor->register_param_count_ = 2; | 355 descriptor->register_param_count_ = 2; |
387 descriptor->register_params_ = registers; | 356 descriptor->register_params_ = registers; |
388 descriptor->deoptimization_handler_ = | 357 descriptor->deoptimization_handler_ = |
389 Runtime::FunctionForId(Runtime::kHiddenStringAdd)->entry; | 358 Runtime::FunctionForId(Runtime::kHiddenStringAdd)->entry; |
390 } | 359 } |
391 | 360 |
392 | 361 |
393 void CallDescriptors::InitializeForIsolate(Isolate* isolate) { | 362 void CallDescriptors::InitializeForIsolate(Isolate* isolate) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 } | 443 } |
475 | 444 |
476 | 445 |
477 #define __ ACCESS_MASM(masm) | 446 #define __ ACCESS_MASM(masm) |
478 | 447 |
479 | 448 |
480 void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm) { | 449 void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm) { |
481 // Update the static counter each time a new code stub is generated. | 450 // Update the static counter each time a new code stub is generated. |
482 isolate()->counters()->code_stubs()->Increment(); | 451 isolate()->counters()->code_stubs()->Increment(); |
483 | 452 |
484 CodeStubInterfaceDescriptor* descriptor = GetInterfaceDescriptor(isolate()); | 453 CodeStubInterfaceDescriptor* descriptor = GetInterfaceDescriptor(); |
485 int param_count = descriptor->register_param_count_; | 454 int param_count = descriptor->register_param_count_; |
486 { | 455 { |
487 // Call the runtime system in a fresh internal frame. | 456 // Call the runtime system in a fresh internal frame. |
488 FrameScope scope(masm, StackFrame::INTERNAL); | 457 FrameScope scope(masm, StackFrame::INTERNAL); |
489 ASSERT(descriptor->register_param_count_ == 0 || | 458 ASSERT(descriptor->register_param_count_ == 0 || |
490 rax.is(descriptor->register_params_[param_count - 1])); | 459 rax.is(descriptor->register_params_[param_count - 1])); |
491 // Push arguments | 460 // Push arguments |
492 for (int i = 0; i < param_count; ++i) { | 461 for (int i = 0; i < param_count; ++i) { |
493 __ Push(descriptor->register_params_[i]); | 462 __ Push(descriptor->register_params_[i]); |
494 } | 463 } |
(...skipping 1897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2392 BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(isolate); | 2361 BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(isolate); |
2393 } | 2362 } |
2394 | 2363 |
2395 | 2364 |
2396 void CodeStub::GenerateFPStubs(Isolate* isolate) { | 2365 void CodeStub::GenerateFPStubs(Isolate* isolate) { |
2397 } | 2366 } |
2398 | 2367 |
2399 | 2368 |
2400 void CEntryStub::GenerateAheadOfTime(Isolate* isolate) { | 2369 void CEntryStub::GenerateAheadOfTime(Isolate* isolate) { |
2401 CEntryStub stub(isolate, 1, kDontSaveFPRegs); | 2370 CEntryStub stub(isolate, 1, kDontSaveFPRegs); |
2402 stub.GetCode(isolate); | 2371 stub.GetCode(); |
2403 CEntryStub save_doubles(isolate, 1, kSaveFPRegs); | 2372 CEntryStub save_doubles(isolate, 1, kSaveFPRegs); |
2404 save_doubles.GetCode(isolate); | 2373 save_doubles.GetCode(); |
2405 } | 2374 } |
2406 | 2375 |
2407 | 2376 |
2408 void CEntryStub::Generate(MacroAssembler* masm) { | 2377 void CEntryStub::Generate(MacroAssembler* masm) { |
2409 // rax: number of arguments including receiver | 2378 // rax: number of arguments including receiver |
2410 // rbx: pointer to C function (C callee-saved) | 2379 // rbx: pointer to C function (C callee-saved) |
2411 // rbp: frame pointer of calling JS frame (restored after C call) | 2380 // rbp: frame pointer of calling JS frame (restored after C call) |
2412 // rsp: stack pointer (restored after C call) | 2381 // rsp: stack pointer (restored after C call) |
2413 // rsi: current context (restored) | 2382 // rsi: current context (restored) |
2414 | 2383 |
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3640 __ movl(rax, Immediate(0)); | 3609 __ movl(rax, Immediate(0)); |
3641 __ movl(rcx, Immediate(0)); | 3610 __ movl(rcx, Immediate(0)); |
3642 __ setcc(above, rax); // Add one to zero if carry clear and not equal. | 3611 __ setcc(above, rax); // Add one to zero if carry clear and not equal. |
3643 __ sbbp(rax, rcx); // Subtract one if below (aka. carry set). | 3612 __ sbbp(rax, rcx); // Subtract one if below (aka. carry set). |
3644 __ ret(0); | 3613 __ ret(0); |
3645 | 3614 |
3646 __ bind(&unordered); | 3615 __ bind(&unordered); |
3647 __ bind(&generic_stub); | 3616 __ bind(&generic_stub); |
3648 ICCompareStub stub(isolate(), op_, CompareIC::GENERIC, CompareIC::GENERIC, | 3617 ICCompareStub stub(isolate(), op_, CompareIC::GENERIC, CompareIC::GENERIC, |
3649 CompareIC::GENERIC); | 3618 CompareIC::GENERIC); |
3650 __ jmp(stub.GetCode(isolate()), RelocInfo::CODE_TARGET); | 3619 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET); |
3651 | 3620 |
3652 __ bind(&maybe_undefined1); | 3621 __ bind(&maybe_undefined1); |
3653 if (Token::IsOrderedRelationalCompareOp(op_)) { | 3622 if (Token::IsOrderedRelationalCompareOp(op_)) { |
3654 __ Cmp(rax, isolate()->factory()->undefined_value()); | 3623 __ Cmp(rax, isolate()->factory()->undefined_value()); |
3655 __ j(not_equal, &miss); | 3624 __ j(not_equal, &miss); |
3656 __ JumpIfSmi(rdx, &unordered); | 3625 __ JumpIfSmi(rdx, &unordered); |
3657 __ CmpObjectType(rdx, HEAP_NUMBER_TYPE, rcx); | 3626 __ CmpObjectType(rdx, HEAP_NUMBER_TYPE, rcx); |
3658 __ j(not_equal, &maybe_undefined2, Label::kNear); | 3627 __ j(not_equal, &maybe_undefined2, Label::kNear); |
3659 __ jmp(&unordered); | 3628 __ jmp(&unordered); |
3660 } | 3629 } |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4110 __ bind(¬_in_dictionary); | 4079 __ bind(¬_in_dictionary); |
4111 __ movp(scratch, Immediate(0)); | 4080 __ movp(scratch, Immediate(0)); |
4112 __ Drop(1); | 4081 __ Drop(1); |
4113 __ ret(2 * kPointerSize); | 4082 __ ret(2 * kPointerSize); |
4114 } | 4083 } |
4115 | 4084 |
4116 | 4085 |
4117 void StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime( | 4086 void StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime( |
4118 Isolate* isolate) { | 4087 Isolate* isolate) { |
4119 StoreBufferOverflowStub stub1(isolate, kDontSaveFPRegs); | 4088 StoreBufferOverflowStub stub1(isolate, kDontSaveFPRegs); |
4120 stub1.GetCode(isolate); | 4089 stub1.GetCode(); |
4121 StoreBufferOverflowStub stub2(isolate, kSaveFPRegs); | 4090 StoreBufferOverflowStub stub2(isolate, kSaveFPRegs); |
4122 stub2.GetCode(isolate); | 4091 stub2.GetCode(); |
4123 } | 4092 } |
4124 | 4093 |
4125 | 4094 |
4126 bool CodeStub::CanUseFPRegisters() { | 4095 bool CodeStub::CanUseFPRegisters() { |
4127 return true; // Always have SSE2 on x64. | 4096 return true; // Always have SSE2 on x64. |
4128 } | 4097 } |
4129 | 4098 |
4130 | 4099 |
4131 // Takes the input in 3 registers: address_ value_ and object_. A pointer to | 4100 // Takes the input in 3 registers: address_ value_ and object_. A pointer to |
4132 // the value has just been written into the object, now this stub makes sure | 4101 // the value has just been written into the object, now this stub makes sure |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4396 r9, | 4365 r9, |
4397 r11, | 4366 r11, |
4398 xmm0, | 4367 xmm0, |
4399 &slow_elements); | 4368 &slow_elements); |
4400 __ ret(0); | 4369 __ ret(0); |
4401 } | 4370 } |
4402 | 4371 |
4403 | 4372 |
4404 void StubFailureTrampolineStub::Generate(MacroAssembler* masm) { | 4373 void StubFailureTrampolineStub::Generate(MacroAssembler* masm) { |
4405 CEntryStub ces(isolate(), 1, fp_registers_ ? kSaveFPRegs : kDontSaveFPRegs); | 4374 CEntryStub ces(isolate(), 1, fp_registers_ ? kSaveFPRegs : kDontSaveFPRegs); |
4406 __ Call(ces.GetCode(isolate()), RelocInfo::CODE_TARGET); | 4375 __ Call(ces.GetCode(), RelocInfo::CODE_TARGET); |
4407 int parameter_count_offset = | 4376 int parameter_count_offset = |
4408 StubFailureTrampolineFrame::kCallerStackParameterCountFrameOffset; | 4377 StubFailureTrampolineFrame::kCallerStackParameterCountFrameOffset; |
4409 __ movp(rbx, MemOperand(rbp, parameter_count_offset)); | 4378 __ movp(rbx, MemOperand(rbp, parameter_count_offset)); |
4410 masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE); | 4379 masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE); |
4411 __ PopReturnAddressTo(rcx); | 4380 __ PopReturnAddressTo(rcx); |
4412 int additional_offset = function_mode_ == JS_FUNCTION_STUB_MODE | 4381 int additional_offset = function_mode_ == JS_FUNCTION_STUB_MODE |
4413 ? kPointerSize | 4382 ? kPointerSize |
4414 : 0; | 4383 : 0; |
4415 __ leap(rsp, MemOperand(rsp, rbx, times_pointer_size, additional_offset)); | 4384 __ leap(rsp, MemOperand(rsp, rbx, times_pointer_size, additional_offset)); |
4416 __ jmp(rcx); // Return to IC Miss stub, continuation still on stack. | 4385 __ jmp(rcx); // Return to IC Miss stub, continuation still on stack. |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4575 } | 4544 } |
4576 | 4545 |
4577 | 4546 |
4578 template<class T> | 4547 template<class T> |
4579 static void ArrayConstructorStubAheadOfTimeHelper(Isolate* isolate) { | 4548 static void ArrayConstructorStubAheadOfTimeHelper(Isolate* isolate) { |
4580 int to_index = GetSequenceIndexFromFastElementsKind( | 4549 int to_index = GetSequenceIndexFromFastElementsKind( |
4581 TERMINAL_FAST_ELEMENTS_KIND); | 4550 TERMINAL_FAST_ELEMENTS_KIND); |
4582 for (int i = 0; i <= to_index; ++i) { | 4551 for (int i = 0; i <= to_index; ++i) { |
4583 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); | 4552 ElementsKind kind = GetFastElementsKindFromSequenceIndex(i); |
4584 T stub(isolate, kind); | 4553 T stub(isolate, kind); |
4585 stub.GetCode(isolate); | 4554 stub.GetCode(); |
4586 if (AllocationSite::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) { | 4555 if (AllocationSite::GetMode(kind) != DONT_TRACK_ALLOCATION_SITE) { |
4587 T stub1(isolate, kind, DISABLE_ALLOCATION_SITES); | 4556 T stub1(isolate, kind, DISABLE_ALLOCATION_SITES); |
4588 stub1.GetCode(isolate); | 4557 stub1.GetCode(); |
4589 } | 4558 } |
4590 } | 4559 } |
4591 } | 4560 } |
4592 | 4561 |
4593 | 4562 |
4594 void ArrayConstructorStubBase::GenerateStubsAheadOfTime(Isolate* isolate) { | 4563 void ArrayConstructorStubBase::GenerateStubsAheadOfTime(Isolate* isolate) { |
4595 ArrayConstructorStubAheadOfTimeHelper<ArrayNoArgumentConstructorStub>( | 4564 ArrayConstructorStubAheadOfTimeHelper<ArrayNoArgumentConstructorStub>( |
4596 isolate); | 4565 isolate); |
4597 ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>( | 4566 ArrayConstructorStubAheadOfTimeHelper<ArraySingleArgumentConstructorStub>( |
4598 isolate); | 4567 isolate); |
4599 ArrayConstructorStubAheadOfTimeHelper<ArrayNArgumentsConstructorStub>( | 4568 ArrayConstructorStubAheadOfTimeHelper<ArrayNArgumentsConstructorStub>( |
4600 isolate); | 4569 isolate); |
4601 } | 4570 } |
4602 | 4571 |
4603 | 4572 |
4604 void InternalArrayConstructorStubBase::GenerateStubsAheadOfTime( | 4573 void InternalArrayConstructorStubBase::GenerateStubsAheadOfTime( |
4605 Isolate* isolate) { | 4574 Isolate* isolate) { |
4606 ElementsKind kinds[2] = { FAST_ELEMENTS, FAST_HOLEY_ELEMENTS }; | 4575 ElementsKind kinds[2] = { FAST_ELEMENTS, FAST_HOLEY_ELEMENTS }; |
4607 for (int i = 0; i < 2; i++) { | 4576 for (int i = 0; i < 2; i++) { |
4608 // For internal arrays we only need a few things | 4577 // For internal arrays we only need a few things |
4609 InternalArrayNoArgumentConstructorStub stubh1(isolate, kinds[i]); | 4578 InternalArrayNoArgumentConstructorStub stubh1(isolate, kinds[i]); |
4610 stubh1.GetCode(isolate); | 4579 stubh1.GetCode(); |
4611 InternalArraySingleArgumentConstructorStub stubh2(isolate, kinds[i]); | 4580 InternalArraySingleArgumentConstructorStub stubh2(isolate, kinds[i]); |
4612 stubh2.GetCode(isolate); | 4581 stubh2.GetCode(); |
4613 InternalArrayNArgumentsConstructorStub stubh3(isolate, kinds[i]); | 4582 InternalArrayNArgumentsConstructorStub stubh3(isolate, kinds[i]); |
4614 stubh3.GetCode(isolate); | 4583 stubh3.GetCode(); |
4615 } | 4584 } |
4616 } | 4585 } |
4617 | 4586 |
4618 | 4587 |
4619 void ArrayConstructorStub::GenerateDispatchToArrayStub( | 4588 void ArrayConstructorStub::GenerateDispatchToArrayStub( |
4620 MacroAssembler* masm, | 4589 MacroAssembler* masm, |
4621 AllocationSiteOverrideMode mode) { | 4590 AllocationSiteOverrideMode mode) { |
4622 if (argument_count_ == ANY) { | 4591 if (argument_count_ == ANY) { |
4623 Label not_zero_case, not_one_case; | 4592 Label not_zero_case, not_one_case; |
4624 __ testp(rax, rax); | 4593 __ testp(rax, rax); |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4951 return_value_operand, | 4920 return_value_operand, |
4952 NULL); | 4921 NULL); |
4953 } | 4922 } |
4954 | 4923 |
4955 | 4924 |
4956 #undef __ | 4925 #undef __ |
4957 | 4926 |
4958 } } // namespace v8::internal | 4927 } } // namespace v8::internal |
4959 | 4928 |
4960 #endif // V8_TARGET_ARCH_X64 | 4929 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |