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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 Code::Flags flags = | 139 Code::Flags flags = |
140 Code::ComputeMonomorphicFlags(Code::LOAD_IC, NONEXISTENT); | 140 Code::ComputeMonomorphicFlags(Code::LOAD_IC, NONEXISTENT); |
141 Handle<Object> probe(receiver->map()->FindInCodeCache(*cache_name, flags)); | 141 Handle<Object> probe(receiver->map()->FindInCodeCache(*cache_name, flags)); |
142 if (probe->IsCode()) return Handle<Code>::cast(probe); | 142 if (probe->IsCode()) return Handle<Code>::cast(probe); |
143 | 143 |
144 LoadStubCompiler compiler(isolate_); | 144 LoadStubCompiler compiler(isolate_); |
145 Handle<Code> code = | 145 Handle<Code> code = |
146 compiler.CompileLoadNonexistent(cache_name, receiver, last); | 146 compiler.CompileLoadNonexistent(cache_name, receiver, last); |
147 PROFILE(isolate_, CodeCreateEvent(Logger::LOAD_IC_TAG, *code, *cache_name)); | 147 PROFILE(isolate_, CodeCreateEvent(Logger::LOAD_IC_TAG, *code, *cache_name)); |
148 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *cache_name, *code)); | 148 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *cache_name, *code)); |
149 JSObject::UpdateMapCodeCache(isolate_, receiver, cache_name, code); | 149 JSObject::UpdateMapCodeCache(receiver, cache_name, code); |
150 return code; | 150 return code; |
151 } | 151 } |
152 | 152 |
153 | 153 |
154 Handle<Code> LoadStubCompiler::CompileLoadField(Handle<JSObject> object, | 154 Handle<Code> LoadStubCompiler::CompileLoadField(Handle<JSObject> object, |
155 Handle<JSObject> holder, | 155 Handle<JSObject> holder, |
156 int index, | 156 int index, |
157 Handle<String> name) { | 157 Handle<String> name) { |
158 CALL_HEAP_FUNCTION(isolate(), | 158 CALL_HEAP_FUNCTION(isolate(), |
159 CompileLoadField(*object, *holder, index, *name), | 159 CompileLoadField(*object, *holder, index, *name), |
160 Code); | 160 Code); |
161 } | 161 } |
162 | 162 |
163 | 163 |
164 Handle<Code> StubCache::ComputeLoadField(Handle<String> name, | 164 Handle<Code> StubCache::ComputeLoadField(Handle<String> name, |
165 Handle<JSObject> receiver, | 165 Handle<JSObject> receiver, |
166 Handle<JSObject> holder, | 166 Handle<JSObject> holder, |
167 int field_index) { | 167 int field_index) { |
168 ASSERT(IC::GetCodeCacheForObject(*receiver, *holder) == OWN_MAP); | 168 ASSERT(IC::GetCodeCacheForObject(*receiver, *holder) == OWN_MAP); |
169 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, FIELD); | 169 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, FIELD); |
170 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); | 170 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); |
171 if (probe->IsCode()) return Handle<Code>::cast(probe); | 171 if (probe->IsCode()) return Handle<Code>::cast(probe); |
172 | 172 |
173 LoadStubCompiler compiler(isolate_); | 173 LoadStubCompiler compiler(isolate_); |
174 Handle<Code> code = | 174 Handle<Code> code = |
175 compiler.CompileLoadField(receiver, holder, field_index, name); | 175 compiler.CompileLoadField(receiver, holder, field_index, name); |
176 PROFILE(isolate_, CodeCreateEvent(Logger::LOAD_IC_TAG, *code, *name)); | 176 PROFILE(isolate_, CodeCreateEvent(Logger::LOAD_IC_TAG, *code, *name)); |
177 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *name, *code)); | 177 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *name, *code)); |
178 JSObject::UpdateMapCodeCache(isolate_, receiver, name, code); | 178 JSObject::UpdateMapCodeCache(receiver, name, code); |
179 return code; | 179 return code; |
180 } | 180 } |
181 | 181 |
182 | 182 |
183 Handle<Code> LoadStubCompiler::CompileLoadCallback( | 183 Handle<Code> LoadStubCompiler::CompileLoadCallback( |
184 Handle<String> name, | 184 Handle<String> name, |
185 Handle<JSObject> object, | 185 Handle<JSObject> object, |
186 Handle<JSObject> holder, | 186 Handle<JSObject> holder, |
187 Handle<AccessorInfo> callback) { | 187 Handle<AccessorInfo> callback) { |
188 CALL_HEAP_FUNCTION(isolate(), | 188 CALL_HEAP_FUNCTION(isolate(), |
(...skipping 10 matching lines...) Expand all Loading... |
199 ASSERT(IC::GetCodeCacheForObject(*receiver, *holder) == OWN_MAP); | 199 ASSERT(IC::GetCodeCacheForObject(*receiver, *holder) == OWN_MAP); |
200 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, CALLBACKS); | 200 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, CALLBACKS); |
201 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); | 201 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); |
202 if (probe->IsCode()) return Handle<Code>::cast(probe); | 202 if (probe->IsCode()) return Handle<Code>::cast(probe); |
203 | 203 |
204 LoadStubCompiler compiler(isolate_); | 204 LoadStubCompiler compiler(isolate_); |
205 Handle<Code> code = | 205 Handle<Code> code = |
206 compiler.CompileLoadCallback(name, receiver, holder, callback); | 206 compiler.CompileLoadCallback(name, receiver, holder, callback); |
207 PROFILE(isolate_, CodeCreateEvent(Logger::LOAD_IC_TAG, *code, *name)); | 207 PROFILE(isolate_, CodeCreateEvent(Logger::LOAD_IC_TAG, *code, *name)); |
208 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *name, *code)); | 208 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *name, *code)); |
209 JSObject::UpdateMapCodeCache(isolate_, receiver, name, code); | 209 JSObject::UpdateMapCodeCache(receiver, name, code); |
210 return code; | 210 return code; |
211 } | 211 } |
212 | 212 |
213 | 213 |
214 Handle<Code> LoadStubCompiler::CompileLoadConstant(Handle<JSObject> object, | 214 Handle<Code> LoadStubCompiler::CompileLoadConstant(Handle<JSObject> object, |
215 Handle<JSObject> holder, | 215 Handle<JSObject> holder, |
216 Handle<Object> value, | 216 Handle<Object> value, |
217 Handle<String> name) { | 217 Handle<String> name) { |
218 CALL_HEAP_FUNCTION(isolate(), | 218 CALL_HEAP_FUNCTION(isolate(), |
219 CompileLoadConstant(*object, *holder, *value, *name), | 219 CompileLoadConstant(*object, *holder, *value, *name), |
220 Code); | 220 Code); |
221 } | 221 } |
222 | 222 |
223 | 223 |
224 Handle<Code> StubCache::ComputeLoadConstant(Handle<String> name, | 224 Handle<Code> StubCache::ComputeLoadConstant(Handle<String> name, |
225 Handle<JSObject> receiver, | 225 Handle<JSObject> receiver, |
226 Handle<JSObject> holder, | 226 Handle<JSObject> holder, |
227 Handle<Object> value) { | 227 Handle<Object> value) { |
228 ASSERT(IC::GetCodeCacheForObject(*receiver, *holder) == OWN_MAP); | 228 ASSERT(IC::GetCodeCacheForObject(*receiver, *holder) == OWN_MAP); |
229 Code::Flags flags = | 229 Code::Flags flags = |
230 Code::ComputeMonomorphicFlags(Code::LOAD_IC, CONSTANT_FUNCTION); | 230 Code::ComputeMonomorphicFlags(Code::LOAD_IC, CONSTANT_FUNCTION); |
231 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); | 231 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); |
232 if (probe->IsCode()) return Handle<Code>::cast(probe); | 232 if (probe->IsCode()) return Handle<Code>::cast(probe); |
233 | 233 |
234 LoadStubCompiler compiler(isolate_); | 234 LoadStubCompiler compiler(isolate_); |
235 Handle<Code> code = | 235 Handle<Code> code = |
236 compiler.CompileLoadConstant(receiver, holder, value, name); | 236 compiler.CompileLoadConstant(receiver, holder, value, name); |
237 PROFILE(isolate_, CodeCreateEvent(Logger::LOAD_IC_TAG, *code, *name)); | 237 PROFILE(isolate_, CodeCreateEvent(Logger::LOAD_IC_TAG, *code, *name)); |
238 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *name, *code)); | 238 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *name, *code)); |
239 JSObject::UpdateMapCodeCache(isolate_, receiver, name, code); | 239 JSObject::UpdateMapCodeCache(receiver, name, code); |
240 return code; | 240 return code; |
241 } | 241 } |
242 | 242 |
243 | 243 |
244 Handle<Code> LoadStubCompiler::CompileLoadInterceptor(Handle<JSObject> object, | 244 Handle<Code> LoadStubCompiler::CompileLoadInterceptor(Handle<JSObject> object, |
245 Handle<JSObject> holder, | 245 Handle<JSObject> holder, |
246 Handle<String> name) { | 246 Handle<String> name) { |
247 CALL_HEAP_FUNCTION(isolate(), | 247 CALL_HEAP_FUNCTION(isolate(), |
248 CompileLoadInterceptor(*object, *holder, *name), | 248 CompileLoadInterceptor(*object, *holder, *name), |
249 Code); | 249 Code); |
250 } | 250 } |
251 | 251 |
252 | 252 |
253 Handle<Code> StubCache::ComputeLoadInterceptor(Handle<String> name, | 253 Handle<Code> StubCache::ComputeLoadInterceptor(Handle<String> name, |
254 Handle<JSObject> receiver, | 254 Handle<JSObject> receiver, |
255 Handle<JSObject> holder) { | 255 Handle<JSObject> holder) { |
256 ASSERT(IC::GetCodeCacheForObject(*receiver, *holder) == OWN_MAP); | 256 ASSERT(IC::GetCodeCacheForObject(*receiver, *holder) == OWN_MAP); |
257 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, INTERCEPTOR); | 257 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, INTERCEPTOR); |
258 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); | 258 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); |
259 if (probe->IsCode()) return Handle<Code>::cast(probe); | 259 if (probe->IsCode()) return Handle<Code>::cast(probe); |
260 | 260 |
261 LoadStubCompiler compiler(isolate_); | 261 LoadStubCompiler compiler(isolate_); |
262 Handle<Code> code = | 262 Handle<Code> code = |
263 compiler.CompileLoadInterceptor(receiver, holder, name); | 263 compiler.CompileLoadInterceptor(receiver, holder, name); |
264 PROFILE(isolate_, CodeCreateEvent(Logger::LOAD_IC_TAG, *code, *name)); | 264 PROFILE(isolate_, CodeCreateEvent(Logger::LOAD_IC_TAG, *code, *name)); |
265 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *name, *code)); | 265 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *name, *code)); |
266 JSObject::UpdateMapCodeCache(isolate_, receiver, name, code); | 266 JSObject::UpdateMapCodeCache(receiver, name, code); |
267 return code; | 267 return code; |
268 } | 268 } |
269 | 269 |
270 | 270 |
271 Handle<Code> StubCache::ComputeLoadNormal() { | 271 Handle<Code> StubCache::ComputeLoadNormal() { |
272 return isolate_->builtins()->LoadIC_Normal(); | 272 return isolate_->builtins()->LoadIC_Normal(); |
273 } | 273 } |
274 | 274 |
275 Handle<Code> LoadStubCompiler::CompileLoadGlobal( | 275 Handle<Code> LoadStubCompiler::CompileLoadGlobal( |
276 Handle<JSObject> object, | 276 Handle<JSObject> object, |
(...skipping 17 matching lines...) Expand all Loading... |
294 ASSERT(IC::GetCodeCacheForObject(*receiver, *holder) == OWN_MAP); | 294 ASSERT(IC::GetCodeCacheForObject(*receiver, *holder) == OWN_MAP); |
295 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, NORMAL); | 295 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, NORMAL); |
296 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); | 296 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); |
297 if (probe->IsCode()) return Handle<Code>::cast(probe); | 297 if (probe->IsCode()) return Handle<Code>::cast(probe); |
298 | 298 |
299 LoadStubCompiler compiler(isolate_); | 299 LoadStubCompiler compiler(isolate_); |
300 Handle<Code> code = | 300 Handle<Code> code = |
301 compiler.CompileLoadGlobal(receiver, holder, cell, name, is_dont_delete); | 301 compiler.CompileLoadGlobal(receiver, holder, cell, name, is_dont_delete); |
302 PROFILE(isolate_, CodeCreateEvent(Logger::LOAD_IC_TAG, *code, *name)); | 302 PROFILE(isolate_, CodeCreateEvent(Logger::LOAD_IC_TAG, *code, *name)); |
303 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *name, *code)); | 303 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *name, *code)); |
304 JSObject::UpdateMapCodeCache(isolate_, receiver, name, code); | 304 JSObject::UpdateMapCodeCache(receiver, name, code); |
305 return code; | 305 return code; |
306 } | 306 } |
307 | 307 |
308 | 308 |
309 Handle<Code> KeyedLoadStubCompiler::CompileLoadField(Handle<String> name, | 309 Handle<Code> KeyedLoadStubCompiler::CompileLoadField(Handle<String> name, |
310 Handle<JSObject> object, | 310 Handle<JSObject> object, |
311 Handle<JSObject> holder, | 311 Handle<JSObject> holder, |
312 int index) { | 312 int index) { |
313 CALL_HEAP_FUNCTION(isolate(), | 313 CALL_HEAP_FUNCTION(isolate(), |
314 CompileLoadField(*name, *object, *holder, index), | 314 CompileLoadField(*name, *object, *holder, index), |
315 Code); | 315 Code); |
316 } | 316 } |
317 | 317 |
318 | 318 |
319 Handle<Code> StubCache::ComputeKeyedLoadField(Handle<String> name, | 319 Handle<Code> StubCache::ComputeKeyedLoadField(Handle<String> name, |
320 Handle<JSObject> receiver, | 320 Handle<JSObject> receiver, |
321 Handle<JSObject> holder, | 321 Handle<JSObject> holder, |
322 int field_index) { | 322 int field_index) { |
323 ASSERT(IC::GetCodeCacheForObject(*receiver, *holder) == OWN_MAP); | 323 ASSERT(IC::GetCodeCacheForObject(*receiver, *holder) == OWN_MAP); |
324 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, FIELD); | 324 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, FIELD); |
325 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); | 325 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); |
326 if (probe->IsCode()) return Handle<Code>::cast(probe); | 326 if (probe->IsCode()) return Handle<Code>::cast(probe); |
327 | 327 |
328 KeyedLoadStubCompiler compiler(isolate_); | 328 KeyedLoadStubCompiler compiler(isolate_); |
329 Handle<Code> code = | 329 Handle<Code> code = |
330 compiler.CompileLoadField(name, receiver, holder, field_index); | 330 compiler.CompileLoadField(name, receiver, holder, field_index); |
331 PROFILE(isolate_, CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, *code, *name)); | 331 PROFILE(isolate_, CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, *code, *name)); |
332 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, *name, *code)); | 332 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, *name, *code)); |
333 JSObject::UpdateMapCodeCache(isolate_, receiver, name, code); | 333 JSObject::UpdateMapCodeCache(receiver, name, code); |
334 return code; | 334 return code; |
335 } | 335 } |
336 | 336 |
337 | 337 |
338 Handle<Code> KeyedLoadStubCompiler::CompileLoadConstant(Handle<String> name, | 338 Handle<Code> KeyedLoadStubCompiler::CompileLoadConstant(Handle<String> name, |
339 Handle<JSObject> object, | 339 Handle<JSObject> object, |
340 Handle<JSObject> holder, | 340 Handle<JSObject> holder, |
341 Handle<Object> value) { | 341 Handle<Object> value) { |
342 CALL_HEAP_FUNCTION(isolate(), | 342 CALL_HEAP_FUNCTION(isolate(), |
343 CompileLoadConstant(*name, *object, *holder, *value), | 343 CompileLoadConstant(*name, *object, *holder, *value), |
344 Code); | 344 Code); |
345 } | 345 } |
346 | 346 |
347 | 347 |
348 Handle<Code> StubCache::ComputeKeyedLoadConstant(Handle<String> name, | 348 Handle<Code> StubCache::ComputeKeyedLoadConstant(Handle<String> name, |
349 Handle<JSObject> receiver, | 349 Handle<JSObject> receiver, |
350 Handle<JSObject> holder, | 350 Handle<JSObject> holder, |
351 Handle<Object> value) { | 351 Handle<Object> value) { |
352 ASSERT(IC::GetCodeCacheForObject(*receiver, *holder) == OWN_MAP); | 352 ASSERT(IC::GetCodeCacheForObject(*receiver, *holder) == OWN_MAP); |
353 Code::Flags flags = | 353 Code::Flags flags = |
354 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CONSTANT_FUNCTION); | 354 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CONSTANT_FUNCTION); |
355 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); | 355 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); |
356 if (probe->IsCode()) return Handle<Code>::cast(probe); | 356 if (probe->IsCode()) return Handle<Code>::cast(probe); |
357 | 357 |
358 KeyedLoadStubCompiler compiler(isolate_); | 358 KeyedLoadStubCompiler compiler(isolate_); |
359 Handle<Code> code = | 359 Handle<Code> code = |
360 compiler.CompileLoadConstant(name, receiver, holder, value); | 360 compiler.CompileLoadConstant(name, receiver, holder, value); |
361 PROFILE(isolate_, CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, *code, *name)); | 361 PROFILE(isolate_, CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, *code, *name)); |
362 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, *name, *code)); | 362 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, *name, *code)); |
363 JSObject::UpdateMapCodeCache(isolate_, receiver, name, code); | 363 JSObject::UpdateMapCodeCache(receiver, name, code); |
364 return code; | 364 return code; |
365 } | 365 } |
366 | 366 |
367 | 367 |
368 Handle<Code> KeyedLoadStubCompiler::CompileLoadInterceptor( | 368 Handle<Code> KeyedLoadStubCompiler::CompileLoadInterceptor( |
369 Handle<JSObject> object, | 369 Handle<JSObject> object, |
370 Handle<JSObject> holder, | 370 Handle<JSObject> holder, |
371 Handle<String> name) { | 371 Handle<String> name) { |
372 CALL_HEAP_FUNCTION(isolate(), | 372 CALL_HEAP_FUNCTION(isolate(), |
373 CompileLoadInterceptor(*object, *holder, *name), | 373 CompileLoadInterceptor(*object, *holder, *name), |
374 Code); | 374 Code); |
375 } | 375 } |
376 | 376 |
377 | 377 |
378 Handle<Code> StubCache::ComputeKeyedLoadInterceptor(Handle<String> name, | 378 Handle<Code> StubCache::ComputeKeyedLoadInterceptor(Handle<String> name, |
379 Handle<JSObject> receiver, | 379 Handle<JSObject> receiver, |
380 Handle<JSObject> holder) { | 380 Handle<JSObject> holder) { |
381 ASSERT(IC::GetCodeCacheForObject(*receiver, *holder) == OWN_MAP); | 381 ASSERT(IC::GetCodeCacheForObject(*receiver, *holder) == OWN_MAP); |
382 Code::Flags flags = | 382 Code::Flags flags = |
383 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, INTERCEPTOR); | 383 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, INTERCEPTOR); |
384 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); | 384 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); |
385 if (probe->IsCode()) return Handle<Code>::cast(probe); | 385 if (probe->IsCode()) return Handle<Code>::cast(probe); |
386 | 386 |
387 KeyedLoadStubCompiler compiler(isolate_); | 387 KeyedLoadStubCompiler compiler(isolate_); |
388 Handle<Code> code = compiler.CompileLoadInterceptor(receiver, holder, name); | 388 Handle<Code> code = compiler.CompileLoadInterceptor(receiver, holder, name); |
389 PROFILE(isolate_, CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, *code, *name)); | 389 PROFILE(isolate_, CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, *code, *name)); |
390 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, *name, *code)); | 390 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, *name, *code)); |
391 JSObject::UpdateMapCodeCache(isolate_, receiver, name, code); | 391 JSObject::UpdateMapCodeCache(receiver, name, code); |
392 return code; | 392 return code; |
393 } | 393 } |
394 | 394 |
395 | 395 |
396 Handle<Code> KeyedLoadStubCompiler::CompileLoadCallback( | 396 Handle<Code> KeyedLoadStubCompiler::CompileLoadCallback( |
397 Handle<String> name, | 397 Handle<String> name, |
398 Handle<JSObject> object, | 398 Handle<JSObject> object, |
399 Handle<JSObject> holder, | 399 Handle<JSObject> holder, |
400 Handle<AccessorInfo> callback) { | 400 Handle<AccessorInfo> callback) { |
401 CALL_HEAP_FUNCTION(isolate(), | 401 CALL_HEAP_FUNCTION(isolate(), |
(...skipping 11 matching lines...) Expand all Loading... |
413 Code::Flags flags = | 413 Code::Flags flags = |
414 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); | 414 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); |
415 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); | 415 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); |
416 if (probe->IsCode()) return Handle<Code>::cast(probe); | 416 if (probe->IsCode()) return Handle<Code>::cast(probe); |
417 | 417 |
418 KeyedLoadStubCompiler compiler(isolate_); | 418 KeyedLoadStubCompiler compiler(isolate_); |
419 Handle<Code> code = | 419 Handle<Code> code = |
420 compiler.CompileLoadCallback(name, receiver, holder, callback); | 420 compiler.CompileLoadCallback(name, receiver, holder, callback); |
421 PROFILE(isolate_, CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, *code, *name)); | 421 PROFILE(isolate_, CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, *code, *name)); |
422 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, *name, *code)); | 422 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, *name, *code)); |
423 JSObject::UpdateMapCodeCache(isolate_, receiver, name, code); | 423 JSObject::UpdateMapCodeCache(receiver, name, code); |
424 return code; | 424 return code; |
425 } | 425 } |
426 | 426 |
427 | 427 |
428 Handle<Code> KeyedLoadStubCompiler::CompileLoadArrayLength( | 428 Handle<Code> KeyedLoadStubCompiler::CompileLoadArrayLength( |
429 Handle<String> name) { | 429 Handle<String> name) { |
430 CALL_HEAP_FUNCTION(isolate(), | 430 CALL_HEAP_FUNCTION(isolate(), |
431 CompileLoadArrayLength(*name), | 431 CompileLoadArrayLength(*name), |
432 Code); | 432 Code); |
433 } | 433 } |
434 | 434 |
435 Handle<Code> StubCache::ComputeKeyedLoadArrayLength(Handle<String> name, | 435 Handle<Code> StubCache::ComputeKeyedLoadArrayLength(Handle<String> name, |
436 Handle<JSArray> receiver) { | 436 Handle<JSArray> receiver) { |
437 Code::Flags flags = | 437 Code::Flags flags = |
438 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); | 438 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); |
439 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); | 439 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); |
440 if (probe->IsCode()) return Handle<Code>::cast(probe); | 440 if (probe->IsCode()) return Handle<Code>::cast(probe); |
441 | 441 |
442 KeyedLoadStubCompiler compiler(isolate_); | 442 KeyedLoadStubCompiler compiler(isolate_); |
443 Handle<Code> code = compiler.CompileLoadArrayLength(name); | 443 Handle<Code> code = compiler.CompileLoadArrayLength(name); |
444 PROFILE(isolate_, CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, *code, *name)); | 444 PROFILE(isolate_, CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, *code, *name)); |
445 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, *name, *code)); | 445 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, *name, *code)); |
446 JSObject::UpdateMapCodeCache(isolate_, receiver, name, code); | 446 JSObject::UpdateMapCodeCache(receiver, name, code); |
447 return code; | 447 return code; |
448 } | 448 } |
449 | 449 |
450 | 450 |
451 Handle<Code> KeyedLoadStubCompiler::CompileLoadStringLength( | 451 Handle<Code> KeyedLoadStubCompiler::CompileLoadStringLength( |
452 Handle<String> name) { | 452 Handle<String> name) { |
453 CALL_HEAP_FUNCTION(isolate(), | 453 CALL_HEAP_FUNCTION(isolate(), |
454 CompileLoadStringLength(*name), | 454 CompileLoadStringLength(*name), |
455 Code); | 455 Code); |
456 } | 456 } |
(...skipping 28 matching lines...) Expand all Loading... |
485 Handle<JSFunction> receiver) { | 485 Handle<JSFunction> receiver) { |
486 Code::Flags flags = | 486 Code::Flags flags = |
487 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); | 487 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); |
488 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); | 488 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); |
489 if (probe->IsCode()) return Handle<Code>::cast(probe); | 489 if (probe->IsCode()) return Handle<Code>::cast(probe); |
490 | 490 |
491 KeyedLoadStubCompiler compiler(isolate_); | 491 KeyedLoadStubCompiler compiler(isolate_); |
492 Handle<Code> code = compiler.CompileLoadFunctionPrototype(name); | 492 Handle<Code> code = compiler.CompileLoadFunctionPrototype(name); |
493 PROFILE(isolate_, CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, *code, *name)); | 493 PROFILE(isolate_, CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, *code, *name)); |
494 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, *name, *code)); | 494 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, *name, *code)); |
495 JSObject::UpdateMapCodeCache(isolate_, receiver, name, code); | 495 JSObject::UpdateMapCodeCache(receiver, name, code); |
496 return code; | 496 return code; |
497 } | 497 } |
498 | 498 |
499 | 499 |
500 Handle<Code> StoreStubCompiler::CompileStoreField(Handle<JSObject> object, | 500 Handle<Code> StoreStubCompiler::CompileStoreField(Handle<JSObject> object, |
501 int index, | 501 int index, |
502 Handle<Map> transition, | 502 Handle<Map> transition, |
503 Handle<String> name) { | 503 Handle<String> name) { |
504 CALL_HEAP_FUNCTION(isolate(), | 504 CALL_HEAP_FUNCTION( |
505 CompileStoreField(*object, | 505 isolate(), |
506 index, | 506 CompileStoreField(*object, index, |
507 (transition.is_null() | 507 transition.is_null() ? NULL : *transition, |
508 ? NULL | 508 *name), |
509 : *transition), | 509 Code); |
510 *name), | |
511 Code); | |
512 } | 510 } |
513 | 511 |
514 | 512 |
515 Handle<Code> StubCache::ComputeStoreField(Handle<String> name, | 513 Handle<Code> StubCache::ComputeStoreField(Handle<String> name, |
516 Handle<JSObject> receiver, | 514 Handle<JSObject> receiver, |
517 int field_index, | 515 int field_index, |
518 Handle<Map> transition, | 516 Handle<Map> transition, |
519 StrictModeFlag strict_mode) { | 517 StrictModeFlag strict_mode) { |
520 PropertyType type = (transition.is_null()) ? FIELD : MAP_TRANSITION; | 518 PropertyType type = (transition.is_null()) ? FIELD : MAP_TRANSITION; |
521 Code::Flags flags = Code::ComputeMonomorphicFlags( | 519 Code::Flags flags = Code::ComputeMonomorphicFlags( |
522 Code::STORE_IC, type, strict_mode); | 520 Code::STORE_IC, type, strict_mode); |
523 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); | 521 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); |
524 if (probe->IsCode()) return Handle<Code>::cast(probe); | 522 if (probe->IsCode()) return Handle<Code>::cast(probe); |
525 | 523 |
526 StoreStubCompiler compiler(isolate_, strict_mode); | 524 StoreStubCompiler compiler(isolate_, strict_mode); |
527 Handle<Code> code = | 525 Handle<Code> code = |
528 compiler.CompileStoreField(receiver, field_index, transition, name); | 526 compiler.CompileStoreField(receiver, field_index, transition, name); |
529 PROFILE(isolate_, CodeCreateEvent(Logger::STORE_IC_TAG, *code, *name)); | 527 PROFILE(isolate_, CodeCreateEvent(Logger::STORE_IC_TAG, *code, *name)); |
530 GDBJIT(AddCode(GDBJITInterface::STORE_IC, *name, *code)); | 528 GDBJIT(AddCode(GDBJITInterface::STORE_IC, *name, *code)); |
531 JSObject::UpdateMapCodeCache(isolate_, receiver, name, code); | 529 JSObject::UpdateMapCodeCache(receiver, name, code); |
532 return code; | 530 return code; |
533 } | 531 } |
534 | 532 |
535 | 533 |
536 MaybeObject* StubCache::ComputeKeyedLoadOrStoreElement( | 534 MaybeObject* StubCache::ComputeKeyedLoadOrStoreElement( |
537 JSObject* receiver, | 535 JSObject* receiver, |
538 KeyedIC::StubKind stub_kind, | 536 KeyedIC::StubKind stub_kind, |
539 StrictModeFlag strict_mode) { | 537 StrictModeFlag strict_mode) { |
540 Code::Flags flags = | 538 Code::Flags flags = |
541 Code::ComputeMonomorphicFlags( | 539 Code::ComputeMonomorphicFlags( |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 StrictModeFlag strict_mode) { | 620 StrictModeFlag strict_mode) { |
623 Code::Flags flags = Code::ComputeMonomorphicFlags( | 621 Code::Flags flags = Code::ComputeMonomorphicFlags( |
624 Code::STORE_IC, NORMAL, strict_mode); | 622 Code::STORE_IC, NORMAL, strict_mode); |
625 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); | 623 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); |
626 if (probe->IsCode()) return Handle<Code>::cast(probe); | 624 if (probe->IsCode()) return Handle<Code>::cast(probe); |
627 | 625 |
628 StoreStubCompiler compiler(isolate_, strict_mode); | 626 StoreStubCompiler compiler(isolate_, strict_mode); |
629 Handle<Code> code = compiler.CompileStoreGlobal(receiver, cell, name); | 627 Handle<Code> code = compiler.CompileStoreGlobal(receiver, cell, name); |
630 PROFILE(isolate_, CodeCreateEvent(Logger::STORE_IC_TAG, *code, *name)); | 628 PROFILE(isolate_, CodeCreateEvent(Logger::STORE_IC_TAG, *code, *name)); |
631 GDBJIT(AddCode(GDBJITInterface::STORE_IC, *name, *code)); | 629 GDBJIT(AddCode(GDBJITInterface::STORE_IC, *name, *code)); |
632 JSObject::UpdateMapCodeCache(isolate_, receiver, name, code); | 630 JSObject::UpdateMapCodeCache(receiver, name, code); |
633 return code; | 631 return code; |
634 } | 632 } |
635 | 633 |
636 | 634 |
637 Handle<Code> StoreStubCompiler::CompileStoreCallback( | 635 Handle<Code> StoreStubCompiler::CompileStoreCallback( |
638 Handle<JSObject> object, | 636 Handle<JSObject> object, |
639 Handle<AccessorInfo> callback, | 637 Handle<AccessorInfo> callback, |
640 Handle<String> name) { | 638 Handle<String> name) { |
641 CALL_HEAP_FUNCTION(isolate(), | 639 CALL_HEAP_FUNCTION(isolate(), |
642 CompileStoreCallback(*object, *callback, *name), | 640 CompileStoreCallback(*object, *callback, *name), |
643 Code); | 641 Code); |
644 } | 642 } |
645 | 643 |
646 | 644 |
647 Handle<Code> StubCache::ComputeStoreCallback(Handle<String> name, | 645 Handle<Code> StubCache::ComputeStoreCallback(Handle<String> name, |
648 Handle<JSObject> receiver, | 646 Handle<JSObject> receiver, |
649 Handle<AccessorInfo> callback, | 647 Handle<AccessorInfo> callback, |
650 StrictModeFlag strict_mode) { | 648 StrictModeFlag strict_mode) { |
651 ASSERT(v8::ToCData<Address>(callback->setter()) != 0); | 649 ASSERT(v8::ToCData<Address>(callback->setter()) != 0); |
652 Code::Flags flags = Code::ComputeMonomorphicFlags( | 650 Code::Flags flags = Code::ComputeMonomorphicFlags( |
653 Code::STORE_IC, CALLBACKS, strict_mode); | 651 Code::STORE_IC, CALLBACKS, strict_mode); |
654 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); | 652 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); |
655 if (probe->IsCode()) return Handle<Code>::cast(probe); | 653 if (probe->IsCode()) return Handle<Code>::cast(probe); |
656 | 654 |
657 StoreStubCompiler compiler(isolate_, strict_mode); | 655 StoreStubCompiler compiler(isolate_, strict_mode); |
658 Handle<Code> code = compiler.CompileStoreCallback(receiver, callback, name); | 656 Handle<Code> code = compiler.CompileStoreCallback(receiver, callback, name); |
659 PROFILE(isolate_, CodeCreateEvent(Logger::STORE_IC_TAG, *code, *name)); | 657 PROFILE(isolate_, CodeCreateEvent(Logger::STORE_IC_TAG, *code, *name)); |
660 GDBJIT(AddCode(GDBJITInterface::STORE_IC, *name, *code)); | 658 GDBJIT(AddCode(GDBJITInterface::STORE_IC, *name, *code)); |
661 JSObject::UpdateMapCodeCache(isolate_, receiver, name, code); | 659 JSObject::UpdateMapCodeCache(receiver, name, code); |
662 return code; | 660 return code; |
663 } | 661 } |
664 | 662 |
665 | 663 |
666 Handle<Code> StoreStubCompiler::CompileStoreInterceptor(Handle<JSObject> object, | 664 Handle<Code> StoreStubCompiler::CompileStoreInterceptor(Handle<JSObject> object, |
667 Handle<String> name) { | 665 Handle<String> name) { |
668 CALL_HEAP_FUNCTION(isolate(), | 666 CALL_HEAP_FUNCTION(isolate(), |
669 CompileStoreInterceptor(*object, *name), | 667 CompileStoreInterceptor(*object, *name), |
670 Code); | 668 Code); |
671 } | 669 } |
672 | 670 |
673 | 671 |
674 Handle<Code> StubCache::ComputeStoreInterceptor(Handle<String> name, | 672 Handle<Code> StubCache::ComputeStoreInterceptor(Handle<String> name, |
675 Handle<JSObject> receiver, | 673 Handle<JSObject> receiver, |
676 StrictModeFlag strict_mode) { | 674 StrictModeFlag strict_mode) { |
677 Code::Flags flags = Code::ComputeMonomorphicFlags( | 675 Code::Flags flags = Code::ComputeMonomorphicFlags( |
678 Code::STORE_IC, INTERCEPTOR, strict_mode); | 676 Code::STORE_IC, INTERCEPTOR, strict_mode); |
679 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); | 677 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); |
680 if (probe->IsCode()) return Handle<Code>::cast(probe); | 678 if (probe->IsCode()) return Handle<Code>::cast(probe); |
681 | 679 |
682 StoreStubCompiler compiler(isolate_, strict_mode); | 680 StoreStubCompiler compiler(isolate_, strict_mode); |
683 Handle<Code> code = compiler.CompileStoreInterceptor(receiver, name); | 681 Handle<Code> code = compiler.CompileStoreInterceptor(receiver, name); |
684 PROFILE(isolate_, CodeCreateEvent(Logger::STORE_IC_TAG, *code, *name)); | 682 PROFILE(isolate_, CodeCreateEvent(Logger::STORE_IC_TAG, *code, *name)); |
685 GDBJIT(AddCode(GDBJITInterface::STORE_IC, *name, *code)); | 683 GDBJIT(AddCode(GDBJITInterface::STORE_IC, *name, *code)); |
686 JSObject::UpdateMapCodeCache(isolate_, receiver, name, code); | 684 JSObject::UpdateMapCodeCache(receiver, name, code); |
687 return code; | 685 return code; |
688 } | 686 } |
689 | 687 |
690 | 688 |
691 MaybeObject* StubCache::ComputeKeyedStoreField(String* name, | 689 MaybeObject* StubCache::ComputeKeyedStoreField(String* name, |
692 JSObject* receiver, | 690 JSObject* receiver, |
693 int field_index, | 691 int field_index, |
694 Map* transition, | 692 Map* transition, |
695 StrictModeFlag strict_mode) { | 693 StrictModeFlag strict_mode) { |
696 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; | 694 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; |
(...skipping 16 matching lines...) Expand all Loading... |
713 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 711 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
714 if (!maybe_result->ToObject(&result)) return maybe_result; | 712 if (!maybe_result->ToObject(&result)) return maybe_result; |
715 } | 713 } |
716 } | 714 } |
717 return code; | 715 return code; |
718 } | 716 } |
719 | 717 |
720 #define CALL_LOGGER_TAG(kind, type) \ | 718 #define CALL_LOGGER_TAG(kind, type) \ |
721 (kind == Code::CALL_IC ? Logger::type : Logger::KEYED_##type) | 719 (kind == Code::CALL_IC ? Logger::type : Logger::KEYED_##type) |
722 | 720 |
723 MaybeObject* StubCache::ComputeCallConstant(int argc, | 721 Handle<Code> CallStubCompiler::CompileCallConstant(Handle<Object> object, |
| 722 Handle<JSObject> holder, |
| 723 Handle<JSFunction> function, |
| 724 Handle<String> name, |
| 725 CheckType check) { |
| 726 CALL_HEAP_FUNCTION( |
| 727 isolate(), |
| 728 CompileCallConstant(*object, *holder, *function, *name, check), |
| 729 Code); |
| 730 } |
| 731 |
| 732 |
| 733 Handle<Code> StubCache::ComputeCallConstant(int argc, |
724 Code::Kind kind, | 734 Code::Kind kind, |
725 Code::ExtraICState extra_ic_state, | 735 Code::ExtraICState extra_state, |
726 String* name, | 736 Handle<String> name, |
727 Object* object, | 737 Handle<Object> object, |
728 JSObject* holder, | 738 Handle<JSObject> holder, |
729 JSFunction* function) { | 739 Handle<JSFunction> function) { |
730 // Compute the check type and the map. | 740 // Compute the check type and the map. |
731 InlineCacheHolderFlag cache_holder = | 741 InlineCacheHolderFlag cache_holder = |
732 IC::GetCodeCacheForObject(object, holder); | 742 IC::GetCodeCacheForObject(*object, *holder); |
733 JSObject* map_holder = IC::GetCodeCacheHolder(object, cache_holder); | 743 Handle<JSObject> map_holder(IC::GetCodeCacheHolder(*object, cache_holder)); |
734 | 744 |
735 // Compute check type based on receiver/holder. | 745 // Compute check type based on receiver/holder. |
736 CheckType check = RECEIVER_MAP_CHECK; | 746 CheckType check = RECEIVER_MAP_CHECK; |
737 if (object->IsString()) { | 747 if (object->IsString()) { |
738 check = STRING_CHECK; | 748 check = STRING_CHECK; |
739 } else if (object->IsNumber()) { | 749 } else if (object->IsNumber()) { |
740 check = NUMBER_CHECK; | 750 check = NUMBER_CHECK; |
741 } else if (object->IsBoolean()) { | 751 } else if (object->IsBoolean()) { |
742 check = BOOLEAN_CHECK; | 752 check = BOOLEAN_CHECK; |
743 } | 753 } |
744 | 754 |
745 Code::Flags flags = Code::ComputeMonomorphicFlags(kind, | 755 Code::Flags flags = |
746 CONSTANT_FUNCTION, | 756 Code::ComputeMonomorphicFlags(kind, CONSTANT_FUNCTION, extra_state, |
747 extra_ic_state, | 757 cache_holder, argc); |
748 cache_holder, | 758 Handle<Object> probe(map_holder->map()->FindInCodeCache(*name, flags)); |
749 argc); | 759 if (probe->IsCode()) return Handle<Code>::cast(probe); |
750 Object* code = map_holder->map()->FindInCodeCache(name, flags); | 760 |
751 if (code->IsUndefined()) { | 761 CallStubCompiler compiler(isolate_, argc, kind, extra_state, cache_holder); |
752 // If the function hasn't been compiled yet, we cannot do it now | 762 Handle<Code> code = |
753 // because it may cause GC. To avoid this issue, we return an | 763 compiler.CompileCallConstant(object, holder, function, name, check); |
754 // internal error which will make sure we do not update any | 764 code->set_check_type(check); |
755 // caches. | 765 ASSERT_EQ(flags, code->flags()); |
756 if (!function->is_compiled()) return Failure::InternalError(); | 766 PROFILE(isolate_, |
757 // Compile the stub - only create stubs for fully compiled functions. | 767 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), *code, *name)); |
758 HandleScope scope(isolate_); | 768 GDBJIT(AddCode(GDBJITInterface::CALL_IC, *name, *code)); |
759 CallStubCompiler compiler(isolate_, | 769 JSObject::UpdateMapCodeCache(map_holder, name, code); |
760 argc, | |
761 kind, | |
762 extra_ic_state, | |
763 cache_holder); | |
764 { MaybeObject* maybe_code = | |
765 compiler.CompileCallConstant(object, holder, function, name, check); | |
766 if (!maybe_code->ToObject(&code)) return maybe_code; | |
767 } | |
768 Code::cast(code)->set_check_type(check); | |
769 ASSERT_EQ(flags, Code::cast(code)->flags()); | |
770 PROFILE(isolate_, | |
771 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), | |
772 Code::cast(code), name)); | |
773 GDBJIT(AddCode(GDBJITInterface::CALL_IC, name, Code::cast(code))); | |
774 Object* result; | |
775 { MaybeObject* maybe_result = | |
776 map_holder->UpdateMapCodeCache(name, Code::cast(code)); | |
777 if (!maybe_result->ToObject(&result)) return maybe_result; | |
778 } | |
779 } | |
780 return code; | 770 return code; |
781 } | 771 } |
782 | 772 |
783 | 773 |
784 MaybeObject* StubCache::ComputeCallField(int argc, | 774 Handle<Code> CallStubCompiler::CompileCallField(Handle<JSObject> object, |
| 775 Handle<JSObject> holder, |
| 776 int index, |
| 777 Handle<String> name) { |
| 778 CALL_HEAP_FUNCTION( |
| 779 isolate(), |
| 780 CompileCallField(*object, *holder, index, *name), |
| 781 Code); |
| 782 } |
| 783 |
| 784 |
| 785 Handle<Code> StubCache::ComputeCallField(int argc, |
785 Code::Kind kind, | 786 Code::Kind kind, |
786 Code::ExtraICState extra_ic_state, | 787 Code::ExtraICState extra_state, |
787 String* name, | 788 Handle<String> name, |
788 Object* object, | 789 Handle<Object> object, |
789 JSObject* holder, | 790 Handle<JSObject> holder, |
790 int index) { | 791 int index) { |
791 // Compute the check type and the map. | 792 // Compute the check type and the map. |
792 InlineCacheHolderFlag cache_holder = | 793 InlineCacheHolderFlag cache_holder = |
793 IC::GetCodeCacheForObject(object, holder); | 794 IC::GetCodeCacheForObject(*object, *holder); |
794 JSObject* map_holder = IC::GetCodeCacheHolder(object, cache_holder); | 795 Handle<JSObject> map_holder(IC::GetCodeCacheHolder(*object, cache_holder)); |
795 | 796 |
796 // TODO(1233596): We cannot do receiver map check for non-JS objects | 797 // TODO(1233596): We cannot do receiver map check for non-JS objects |
797 // because they may be represented as immediates without a | 798 // because they may be represented as immediates without a |
798 // map. Instead, we check against the map in the holder. | 799 // map. Instead, we check against the map in the holder. |
799 if (object->IsNumber() || object->IsBoolean() || object->IsString()) { | 800 if (object->IsNumber() || object->IsBoolean() || object->IsString()) { |
800 object = holder; | 801 object = holder; |
801 } | 802 } |
802 | 803 |
803 Code::Flags flags = Code::ComputeMonomorphicFlags(kind, | 804 Code::Flags flags = |
804 FIELD, | 805 Code::ComputeMonomorphicFlags(kind, FIELD, extra_state, |
805 extra_ic_state, | 806 cache_holder, argc); |
806 cache_holder, | 807 Handle<Object> probe(map_holder->map()->FindInCodeCache(*name, flags)); |
807 argc); | 808 if (probe->IsCode()) return Handle<Code>::cast(probe); |
808 Object* code = map_holder->map()->FindInCodeCache(name, flags); | 809 |
809 if (code->IsUndefined()) { | 810 CallStubCompiler compiler(isolate_, argc, kind, extra_state, cache_holder); |
810 HandleScope scope(isolate_); | 811 Handle<Code> code = |
811 CallStubCompiler compiler(isolate_, | 812 compiler.CompileCallField(Handle<JSObject>::cast(object), |
812 argc, | 813 holder, index, name); |
813 kind, | 814 ASSERT_EQ(flags, code->flags()); |
814 extra_ic_state, | 815 PROFILE(isolate_, |
815 cache_holder); | 816 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), *code, *name)); |
816 { MaybeObject* maybe_code = | 817 GDBJIT(AddCode(GDBJITInterface::CALL_IC, *name, *code)); |
817 compiler.CompileCallField(JSObject::cast(object), | 818 JSObject::UpdateMapCodeCache(map_holder, name, code); |
818 holder, | |
819 index, | |
820 name); | |
821 if (!maybe_code->ToObject(&code)) return maybe_code; | |
822 } | |
823 ASSERT_EQ(flags, Code::cast(code)->flags()); | |
824 PROFILE(isolate_, | |
825 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), | |
826 Code::cast(code), name)); | |
827 GDBJIT(AddCode(GDBJITInterface::CALL_IC, name, Code::cast(code))); | |
828 Object* result; | |
829 { MaybeObject* maybe_result = | |
830 map_holder->UpdateMapCodeCache(name, Code::cast(code)); | |
831 if (!maybe_result->ToObject(&result)) return maybe_result; | |
832 } | |
833 } | |
834 return code; | 819 return code; |
835 } | 820 } |
836 | 821 |
837 | 822 |
838 MaybeObject* StubCache::ComputeCallInterceptor( | 823 Handle<Code> CallStubCompiler::CompileCallInterceptor(Handle<JSObject> object, |
839 int argc, | 824 Handle<JSObject> holder, |
840 Code::Kind kind, | 825 Handle<String> name) { |
841 Code::ExtraICState extra_ic_state, | 826 CALL_HEAP_FUNCTION( |
842 String* name, | 827 isolate(), |
843 Object* object, | 828 CompileCallInterceptor(*object, *holder, *name), |
844 JSObject* holder) { | 829 Code); |
| 830 } |
| 831 |
| 832 |
| 833 Handle<Code> StubCache::ComputeCallInterceptor(int argc, |
| 834 Code::Kind kind, |
| 835 Code::ExtraICState extra_state, |
| 836 Handle<String> name, |
| 837 Handle<Object> object, |
| 838 Handle<JSObject> holder) { |
845 // Compute the check type and the map. | 839 // Compute the check type and the map. |
846 InlineCacheHolderFlag cache_holder = | 840 InlineCacheHolderFlag cache_holder = |
847 IC::GetCodeCacheForObject(object, holder); | 841 IC::GetCodeCacheForObject(*object, *holder); |
848 JSObject* map_holder = IC::GetCodeCacheHolder(object, cache_holder); | 842 Handle<JSObject> map_holder(IC::GetCodeCacheHolder(*object, cache_holder)); |
849 | 843 |
850 // TODO(1233596): We cannot do receiver map check for non-JS objects | 844 // TODO(1233596): We cannot do receiver map check for non-JS objects |
851 // because they may be represented as immediates without a | 845 // because they may be represented as immediates without a |
852 // map. Instead, we check against the map in the holder. | 846 // map. Instead, we check against the map in the holder. |
853 if (object->IsNumber() || object->IsBoolean() || object->IsString()) { | 847 if (object->IsNumber() || object->IsBoolean() || object->IsString()) { |
854 object = holder; | 848 object = holder; |
855 } | 849 } |
856 | 850 |
857 Code::Flags flags = Code::ComputeMonomorphicFlags(kind, | 851 Code::Flags flags = |
858 INTERCEPTOR, | 852 Code::ComputeMonomorphicFlags(kind, INTERCEPTOR, extra_state, |
859 extra_ic_state, | 853 cache_holder, argc); |
860 cache_holder, | 854 Handle<Object> probe(map_holder->map()->FindInCodeCache(*name, flags)); |
861 argc); | 855 if (probe->IsCode()) return Handle<Code>::cast(probe); |
862 Object* code = map_holder->map()->FindInCodeCache(name, flags); | 856 |
863 if (code->IsUndefined()) { | 857 CallStubCompiler compiler(isolate(), argc, kind, extra_state, cache_holder); |
864 HandleScope scope(isolate()); | 858 Handle<Code> code = |
865 CallStubCompiler compiler(isolate(), | 859 compiler.CompileCallInterceptor(Handle<JSObject>::cast(object), |
866 argc, | 860 holder, name); |
867 kind, | 861 ASSERT_EQ(flags, code->flags()); |
868 extra_ic_state, | 862 PROFILE(isolate(), |
869 cache_holder); | 863 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), *code, *name)); |
870 { MaybeObject* maybe_code = | 864 GDBJIT(AddCode(GDBJITInterface::CALL_IC, *name, *code)); |
871 compiler.CompileCallInterceptor(JSObject::cast(object), holder, name); | 865 JSObject::UpdateMapCodeCache(map_holder, name, code); |
872 if (!maybe_code->ToObject(&code)) return maybe_code; | |
873 } | |
874 ASSERT_EQ(flags, Code::cast(code)->flags()); | |
875 PROFILE(isolate(), | |
876 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), | |
877 Code::cast(code), name)); | |
878 GDBJIT(AddCode(GDBJITInterface::CALL_IC, name, Code::cast(code))); | |
879 Object* result; | |
880 { MaybeObject* maybe_result = | |
881 map_holder->UpdateMapCodeCache(name, Code::cast(code)); | |
882 if (!maybe_result->ToObject(&result)) return maybe_result; | |
883 } | |
884 } | |
885 return code; | 866 return code; |
886 } | 867 } |
887 | 868 |
888 | 869 |
889 MaybeObject* StubCache::ComputeCallNormal(int argc, | 870 Handle<Code> CallStubCompiler::CompileCallGlobal( |
| 871 Handle<JSObject> object, |
| 872 Handle<GlobalObject> holder, |
| 873 Handle<JSGlobalPropertyCell> cell, |
| 874 Handle<JSFunction> function, |
| 875 Handle<String> name) { |
| 876 CALL_HEAP_FUNCTION( |
| 877 isolate(), |
| 878 CompileCallGlobal(*object, *holder, *cell, *function, *name), |
| 879 Code); |
| 880 } |
| 881 |
| 882 |
| 883 Handle<Code> StubCache::ComputeCallGlobal(int argc, |
890 Code::Kind kind, | 884 Code::Kind kind, |
891 Code::ExtraICState extra_ic_state, | 885 Code::ExtraICState extra_state, |
892 String* name, | 886 Handle<String> name, |
893 JSObject* receiver) { | 887 Handle<JSObject> receiver, |
894 Object* code; | 888 Handle<GlobalObject> holder, |
895 { MaybeObject* maybe_code = ComputeCallNormal(argc, kind, extra_ic_state); | 889 Handle<JSGlobalPropertyCell> cell, |
896 if (!maybe_code->ToObject(&code)) return maybe_code; | 890 Handle<JSFunction> function) { |
897 } | 891 InlineCacheHolderFlag cache_holder = |
| 892 IC::GetCodeCacheForObject(*receiver, *holder); |
| 893 Handle<JSObject> map_holder(IC::GetCodeCacheHolder(*receiver, cache_holder)); |
| 894 Code::Flags flags = |
| 895 Code::ComputeMonomorphicFlags(kind, NORMAL, extra_state, |
| 896 cache_holder, argc); |
| 897 Handle<Object> probe(map_holder->map()->FindInCodeCache(*name, flags)); |
| 898 if (probe->IsCode()) return Handle<Code>::null(); |
| 899 |
| 900 CallStubCompiler compiler(isolate(), argc, kind, extra_state, cache_holder); |
| 901 Handle<Code> code = |
| 902 compiler.CompileCallGlobal(receiver, holder, cell, function, name); |
| 903 ASSERT_EQ(flags, code->flags()); |
| 904 PROFILE(isolate(), |
| 905 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), *code, *name)); |
| 906 GDBJIT(AddCode(GDBJITInterface::CALL_IC, *name, *code)); |
| 907 JSObject::UpdateMapCodeCache(map_holder, name, code); |
898 return code; | 908 return code; |
899 } | 909 } |
900 | 910 |
901 | 911 |
902 MaybeObject* StubCache::ComputeCallGlobal(int argc, | 912 static void FillCache(Isolate* isolate, Handle<Code> code) { |
903 Code::Kind kind, | 913 Handle<NumberDictionary> dictionary = |
904 Code::ExtraICState extra_ic_state, | 914 NumberDictionarySet(isolate->factory()->non_monomorphic_cache(), |
905 String* name, | 915 code->flags(), |
906 JSObject* receiver, | 916 code, |
907 GlobalObject* holder, | 917 PropertyDetails(NONE, NORMAL)); |
908 JSGlobalPropertyCell* cell, | 918 isolate->heap()->public_set_non_monomorphic_cache(*dictionary); |
909 JSFunction* function) { | |
910 InlineCacheHolderFlag cache_holder = | |
911 IC::GetCodeCacheForObject(receiver, holder); | |
912 JSObject* map_holder = IC::GetCodeCacheHolder(receiver, cache_holder); | |
913 Code::Flags flags = Code::ComputeMonomorphicFlags(kind, | |
914 NORMAL, | |
915 extra_ic_state, | |
916 cache_holder, | |
917 argc); | |
918 Object* code = map_holder->map()->FindInCodeCache(name, flags); | |
919 if (code->IsUndefined()) { | |
920 // If the function hasn't been compiled yet, we cannot do it now | |
921 // because it may cause GC. To avoid this issue, we return an | |
922 // internal error which will make sure we do not update any | |
923 // caches. | |
924 if (!function->is_compiled()) return Failure::InternalError(); | |
925 HandleScope scope(isolate()); | |
926 CallStubCompiler compiler(isolate(), | |
927 argc, | |
928 kind, | |
929 extra_ic_state, | |
930 cache_holder); | |
931 { MaybeObject* maybe_code = | |
932 compiler.CompileCallGlobal(receiver, holder, cell, function, name); | |
933 if (!maybe_code->ToObject(&code)) return maybe_code; | |
934 } | |
935 ASSERT_EQ(flags, Code::cast(code)->flags()); | |
936 PROFILE(isolate(), | |
937 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), | |
938 Code::cast(code), name)); | |
939 GDBJIT(AddCode(GDBJITInterface::CALL_IC, name, Code::cast(code))); | |
940 Object* result; | |
941 { MaybeObject* maybe_result = | |
942 map_holder->UpdateMapCodeCache(name, Code::cast(code)); | |
943 if (!maybe_result->ToObject(&result)) return maybe_result; | |
944 } | |
945 } | |
946 return code; | |
947 } | 919 } |
948 | 920 |
949 | 921 |
950 static Object* GetProbeValue(Isolate* isolate, Code::Flags flags) { | |
951 // Use raw_unchecked... so we don't get assert failures during GC. | |
952 NumberDictionary* dictionary = | |
953 isolate->heap()->raw_unchecked_non_monomorphic_cache(); | |
954 int entry = dictionary->FindEntry(isolate, flags); | |
955 if (entry != -1) return dictionary->ValueAt(entry); | |
956 return isolate->heap()->raw_unchecked_undefined_value(); | |
957 } | |
958 | |
959 | |
960 MUST_USE_RESULT static MaybeObject* ProbeCache(Isolate* isolate, | |
961 Code::Flags flags) { | |
962 Heap* heap = isolate->heap(); | |
963 Object* probe = GetProbeValue(isolate, flags); | |
964 if (probe != heap->undefined_value()) return probe; | |
965 // Seed the cache with an undefined value to make sure that any | |
966 // generated code object can always be inserted into the cache | |
967 // without causing allocation failures. | |
968 Object* result; | |
969 { MaybeObject* maybe_result = | |
970 heap->non_monomorphic_cache()->AtNumberPut(flags, | |
971 heap->undefined_value()); | |
972 if (!maybe_result->ToObject(&result)) return maybe_result; | |
973 } | |
974 heap->public_set_non_monomorphic_cache(NumberDictionary::cast(result)); | |
975 return probe; | |
976 } | |
977 | |
978 | |
979 static MaybeObject* FillCache(Isolate* isolate, MaybeObject* maybe_code) { | |
980 Object* code; | |
981 if (maybe_code->ToObject(&code)) { | |
982 if (code->IsCode()) { | |
983 Heap* heap = isolate->heap(); | |
984 int entry = heap->non_monomorphic_cache()->FindEntry( | |
985 Code::cast(code)->flags()); | |
986 // The entry must be present see comment in ProbeCache. | |
987 ASSERT(entry != -1); | |
988 ASSERT(heap->non_monomorphic_cache()->ValueAt(entry) == | |
989 heap->undefined_value()); | |
990 heap->non_monomorphic_cache()->ValueAtPut(entry, code); | |
991 CHECK(GetProbeValue(isolate, Code::cast(code)->flags()) == code); | |
992 } | |
993 } | |
994 return maybe_code; | |
995 } | |
996 | |
997 | |
998 Code* StubCache::FindCallInitialize(int argc, | 922 Code* StubCache::FindCallInitialize(int argc, |
999 RelocInfo::Mode mode, | 923 RelocInfo::Mode mode, |
1000 Code::Kind kind) { | 924 Code::Kind kind) { |
1001 Code::ExtraICState extra_state = | 925 Code::ExtraICState extra_state = |
1002 CallICBase::StringStubState::encode(DEFAULT_STRING_STUB) | | 926 CallICBase::StringStubState::encode(DEFAULT_STRING_STUB) | |
1003 CallICBase::Contextual::encode(mode == RelocInfo::CODE_TARGET_CONTEXT); | 927 CallICBase::Contextual::encode(mode == RelocInfo::CODE_TARGET_CONTEXT); |
1004 Code::Flags flags = Code::ComputeFlags(kind, | 928 Code::Flags flags = |
1005 UNINITIALIZED, | 929 Code::ComputeFlags(kind, UNINITIALIZED, extra_state, NORMAL, argc); |
1006 extra_state, | 930 |
1007 NORMAL, | 931 // Use raw_unchecked... so we don't get assert failures during GC. |
1008 argc); | 932 NumberDictionary* dictionary = |
1009 Object* result = ProbeCache(isolate(), flags)->ToObjectUnchecked(); | 933 isolate()->heap()->raw_unchecked_non_monomorphic_cache(); |
1010 ASSERT(result != heap()->undefined_value()); | 934 int entry = dictionary->FindEntry(isolate(), flags); |
| 935 ASSERT(entry != -1); |
| 936 Object* code = dictionary->ValueAt(entry); |
1011 // This might be called during the marking phase of the collector | 937 // This might be called during the marking phase of the collector |
1012 // hence the unchecked cast. | 938 // hence the unchecked cast. |
1013 return reinterpret_cast<Code*>(result); | 939 return reinterpret_cast<Code*>(code); |
1014 } | 940 } |
1015 | 941 |
1016 | 942 |
1017 MaybeObject* StubCache::ComputeCallInitialize(int argc, | 943 Handle<Code> StubCache::ComputeCallInitialize(int argc, |
1018 RelocInfo::Mode mode, | 944 RelocInfo::Mode mode, |
1019 Code::Kind kind) { | 945 Code::Kind kind) { |
1020 Code::ExtraICState extra_state = | 946 Code::ExtraICState extra_state = |
1021 CallICBase::StringStubState::encode(DEFAULT_STRING_STUB) | | 947 CallICBase::StringStubState::encode(DEFAULT_STRING_STUB) | |
1022 CallICBase::Contextual::encode(mode == RelocInfo::CODE_TARGET_CONTEXT); | 948 CallICBase::Contextual::encode(mode == RelocInfo::CODE_TARGET_CONTEXT); |
1023 Code::Flags flags = Code::ComputeFlags(kind, | 949 Code::Flags flags = |
1024 UNINITIALIZED, | 950 Code::ComputeFlags(kind, UNINITIALIZED, extra_state, NORMAL, argc); |
1025 extra_state, | 951 Handle<NumberDictionary> cache = isolate_->factory()->non_monomorphic_cache(); |
1026 NORMAL, | 952 int entry = cache->FindEntry(isolate_, flags); |
1027 argc); | 953 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); |
1028 Object* probe; | 954 |
1029 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags); | |
1030 if (!maybe_probe->ToObject(&probe)) return maybe_probe; | |
1031 } | |
1032 if (!probe->IsUndefined()) return probe; | |
1033 HandleScope scope(isolate_); | |
1034 StubCompiler compiler(isolate_); | 955 StubCompiler compiler(isolate_); |
1035 return FillCache(isolate_, compiler.CompileCallInitialize(flags)); | 956 Handle<Code> code = compiler.CompileCallInitialize(flags); |
| 957 FillCache(isolate_, code); |
| 958 return code; |
1036 } | 959 } |
1037 | 960 |
1038 | 961 |
1039 Handle<Code> StubCache::ComputeCallInitialize(int argc, | 962 Handle<Code> StubCache::ComputeCallInitialize(int argc, RelocInfo::Mode mode) { |
1040 RelocInfo::Mode mode) { | 963 return ComputeCallInitialize(argc, mode, Code::CALL_IC); |
1041 CALL_HEAP_FUNCTION(isolate_, | |
1042 ComputeCallInitialize(argc, mode, Code::CALL_IC), | |
1043 Code); | |
1044 } | 964 } |
1045 | 965 |
1046 | 966 |
1047 Handle<Code> StubCache::ComputeKeyedCallInitialize(int argc) { | 967 Handle<Code> StubCache::ComputeKeyedCallInitialize(int argc) { |
1048 CALL_HEAP_FUNCTION( | 968 return ComputeCallInitialize(argc, RelocInfo::CODE_TARGET, Code::KEYED_CALL_IC
); |
1049 isolate_, | |
1050 ComputeCallInitialize(argc, RelocInfo::CODE_TARGET, Code::KEYED_CALL_IC), | |
1051 Code); | |
1052 } | 969 } |
1053 | 970 |
1054 | 971 |
1055 MaybeObject* StubCache::ComputeCallPreMonomorphic( | 972 Handle<Code> StubCache::ComputeCallPreMonomorphic( |
1056 int argc, | 973 int argc, |
1057 Code::Kind kind, | 974 Code::Kind kind, |
1058 Code::ExtraICState extra_ic_state) { | 975 Code::ExtraICState extra_state) { |
1059 Code::Flags flags = Code::ComputeFlags(kind, | 976 Code::Flags flags = |
1060 PREMONOMORPHIC, | 977 Code::ComputeFlags(kind, PREMONOMORPHIC, extra_state, NORMAL, argc); |
1061 extra_ic_state, | 978 Handle<NumberDictionary> cache = isolate_->factory()->non_monomorphic_cache(); |
1062 NORMAL, | 979 int entry = cache->FindEntry(isolate_, flags); |
1063 argc); | 980 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); |
1064 Object* probe; | 981 |
1065 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags); | |
1066 if (!maybe_probe->ToObject(&probe)) return maybe_probe; | |
1067 } | |
1068 if (!probe->IsUndefined()) return probe; | |
1069 HandleScope scope(isolate_); | |
1070 StubCompiler compiler(isolate_); | 982 StubCompiler compiler(isolate_); |
1071 return FillCache(isolate_, compiler.CompileCallPreMonomorphic(flags)); | 983 Handle<Code> code = compiler.CompileCallPreMonomorphic(flags); |
| 984 FillCache(isolate_, code); |
| 985 return code; |
1072 } | 986 } |
1073 | 987 |
1074 | 988 |
1075 MaybeObject* StubCache::ComputeCallNormal(int argc, | 989 Handle<Code> StubCache::ComputeCallNormal(int argc, |
1076 Code::Kind kind, | 990 Code::Kind kind, |
1077 Code::ExtraICState extra_ic_state) { | 991 Code::ExtraICState extra_state) { |
1078 Code::Flags flags = Code::ComputeFlags(kind, | 992 Code::Flags flags = |
1079 MONOMORPHIC, | 993 Code::ComputeFlags(kind, MONOMORPHIC, extra_state, NORMAL, argc); |
1080 extra_ic_state, | 994 Handle<NumberDictionary> cache = isolate_->factory()->non_monomorphic_cache(); |
1081 NORMAL, | 995 int entry = cache->FindEntry(isolate_, flags); |
1082 argc); | 996 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); |
1083 Object* probe; | 997 |
1084 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags); | |
1085 if (!maybe_probe->ToObject(&probe)) return maybe_probe; | |
1086 } | |
1087 if (!probe->IsUndefined()) return probe; | |
1088 HandleScope scope(isolate_); | |
1089 StubCompiler compiler(isolate_); | 998 StubCompiler compiler(isolate_); |
1090 return FillCache(isolate_, compiler.CompileCallNormal(flags)); | 999 Handle<Code> code = compiler.CompileCallNormal(flags); |
| 1000 FillCache(isolate_, code); |
| 1001 return code; |
1091 } | 1002 } |
1092 | 1003 |
1093 | 1004 |
1094 MaybeObject* StubCache::ComputeCallArguments(int argc, Code::Kind kind) { | 1005 Handle<Code> StubCache::ComputeCallArguments(int argc, Code::Kind kind) { |
1095 ASSERT(kind == Code::KEYED_CALL_IC); | 1006 ASSERT(kind == Code::KEYED_CALL_IC); |
1096 Code::Flags flags = Code::ComputeFlags(kind, | 1007 Code::Flags flags = |
1097 MEGAMORPHIC, | 1008 Code::ComputeFlags(kind, MEGAMORPHIC, Code::kNoExtraICState, |
1098 Code::kNoExtraICState, | 1009 NORMAL, argc); |
1099 NORMAL, | 1010 Handle<NumberDictionary> cache = isolate_->factory()->non_monomorphic_cache(); |
1100 argc); | 1011 int entry = cache->FindEntry(isolate_, flags); |
1101 Object* probe; | 1012 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); |
1102 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags); | 1013 |
1103 if (!maybe_probe->ToObject(&probe)) return maybe_probe; | |
1104 } | |
1105 if (!probe->IsUndefined()) return probe; | |
1106 HandleScope scope(isolate_); | |
1107 StubCompiler compiler(isolate_); | 1014 StubCompiler compiler(isolate_); |
1108 return FillCache(isolate_, compiler.CompileCallArguments(flags)); | 1015 Handle<Code> code = compiler.CompileCallArguments(flags); |
| 1016 FillCache(isolate_, code); |
| 1017 return code; |
1109 } | 1018 } |
1110 | 1019 |
1111 | 1020 |
1112 MaybeObject* StubCache::ComputeCallMegamorphic( | 1021 Handle<Code> StubCache::ComputeCallMegamorphic( |
1113 int argc, | 1022 int argc, |
1114 Code::Kind kind, | 1023 Code::Kind kind, |
1115 Code::ExtraICState extra_ic_state) { | 1024 Code::ExtraICState extra_state) { |
1116 Code::Flags flags = Code::ComputeFlags(kind, | 1025 Code::Flags flags = |
1117 MEGAMORPHIC, | 1026 Code::ComputeFlags(kind, MEGAMORPHIC, extra_state, |
1118 extra_ic_state, | 1027 NORMAL, argc); |
1119 NORMAL, | 1028 Handle<NumberDictionary> cache = isolate_->factory()->non_monomorphic_cache(); |
1120 argc); | 1029 int entry = cache->FindEntry(isolate_, flags); |
1121 Object* probe; | 1030 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); |
1122 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags); | 1031 |
1123 if (!maybe_probe->ToObject(&probe)) return maybe_probe; | |
1124 } | |
1125 if (!probe->IsUndefined()) return probe; | |
1126 HandleScope scope(isolate_); | |
1127 StubCompiler compiler(isolate_); | 1032 StubCompiler compiler(isolate_); |
1128 return FillCache(isolate_, compiler.CompileCallMegamorphic(flags)); | 1033 Handle<Code> code = compiler.CompileCallMegamorphic(flags); |
| 1034 FillCache(isolate_, code); |
| 1035 return code; |
1129 } | 1036 } |
1130 | 1037 |
1131 | 1038 |
1132 MaybeObject* StubCache::ComputeCallMiss(int argc, | 1039 Handle<Code> StubCache::ComputeCallMiss(int argc, |
1133 Code::Kind kind, | 1040 Code::Kind kind, |
1134 Code::ExtraICState extra_ic_state) { | 1041 Code::ExtraICState extra_state) { |
1135 // MONOMORPHIC_PROTOTYPE_FAILURE state is used to make sure that miss stubs | 1042 // MONOMORPHIC_PROTOTYPE_FAILURE state is used to make sure that miss stubs |
1136 // and monomorphic stubs are not mixed up together in the stub cache. | 1043 // and monomorphic stubs are not mixed up together in the stub cache. |
1137 Code::Flags flags = Code::ComputeFlags(kind, | 1044 Code::Flags flags = |
1138 MONOMORPHIC_PROTOTYPE_FAILURE, | 1045 Code::ComputeFlags(kind, MONOMORPHIC_PROTOTYPE_FAILURE, extra_state, |
1139 extra_ic_state, | 1046 NORMAL, argc, OWN_MAP); |
1140 NORMAL, | 1047 Handle<NumberDictionary> cache = isolate_->factory()->non_monomorphic_cache(); |
1141 argc, | 1048 int entry = cache->FindEntry(isolate_, flags); |
1142 OWN_MAP); | 1049 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); |
1143 Object* probe; | 1050 |
1144 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags); | |
1145 if (!maybe_probe->ToObject(&probe)) return maybe_probe; | |
1146 } | |
1147 if (!probe->IsUndefined()) return probe; | |
1148 HandleScope scope(isolate_); | |
1149 StubCompiler compiler(isolate_); | 1051 StubCompiler compiler(isolate_); |
1150 return FillCache(isolate_, compiler.CompileCallMiss(flags)); | 1052 Handle<Code> code = compiler.CompileCallMiss(flags); |
| 1053 FillCache(isolate_, code); |
| 1054 return code; |
| 1055 } |
| 1056 |
| 1057 |
| 1058 // The CallStubCompiler needs a version of ComputeCallMiss that does not |
| 1059 // perform GC. This function is temporary, because the stub cache but not |
| 1060 // yet the stub compiler uses handles. |
| 1061 MaybeObject* StubCache::TryComputeCallMiss(int argc, |
| 1062 Code::Kind kind, |
| 1063 Code::ExtraICState extra_state) { |
| 1064 Code::Flags flags = |
| 1065 Code::ComputeFlags(kind, MONOMORPHIC_PROTOTYPE_FAILURE, extra_state, |
| 1066 NORMAL, argc, OWN_MAP); |
| 1067 NumberDictionary* cache = isolate_->heap()->non_monomorphic_cache(); |
| 1068 int entry = cache->FindEntry(isolate_, flags); |
| 1069 if (entry != -1) return cache->ValueAt(entry); |
| 1070 |
| 1071 StubCompiler compiler(isolate_); |
| 1072 Code* code = NULL; |
| 1073 MaybeObject* maybe_code = compiler.TryCompileCallMiss(flags); |
| 1074 if (!maybe_code->To(&code)) return maybe_code; |
| 1075 |
| 1076 NumberDictionary* new_cache = NULL; |
| 1077 MaybeObject* maybe_new_cache = cache->AtNumberPut(flags, code); |
| 1078 if (!maybe_new_cache->To(&new_cache)) return maybe_new_cache; |
| 1079 isolate_->heap()->public_set_non_monomorphic_cache(new_cache); |
| 1080 |
| 1081 return code; |
1151 } | 1082 } |
1152 | 1083 |
1153 | 1084 |
1154 #ifdef ENABLE_DEBUGGER_SUPPORT | 1085 #ifdef ENABLE_DEBUGGER_SUPPORT |
1155 MaybeObject* StubCache::ComputeCallDebugBreak( | 1086 Handle<Code> StubCache::ComputeCallDebugBreak(int argc, |
1156 int argc, | 1087 Code::Kind kind) { |
1157 Code::Kind kind) { | |
1158 // Extra IC state is irrelevant for debug break ICs. They jump to | 1088 // Extra IC state is irrelevant for debug break ICs. They jump to |
1159 // the actual call ic to carry out the work. | 1089 // the actual call ic to carry out the work. |
1160 Code::Flags flags = Code::ComputeFlags(kind, | 1090 Code::Flags flags = |
1161 DEBUG_BREAK, | 1091 Code::ComputeFlags(kind, DEBUG_BREAK, Code::kNoExtraICState, |
1162 Code::kNoExtraICState, | 1092 NORMAL, argc); |
1163 NORMAL, | 1093 Handle<NumberDictionary> cache = isolate_->factory()->non_monomorphic_cache(); |
1164 argc); | 1094 int entry = cache->FindEntry(isolate_, flags); |
1165 Object* probe; | 1095 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); |
1166 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags); | 1096 |
1167 if (!maybe_probe->ToObject(&probe)) return maybe_probe; | |
1168 } | |
1169 if (!probe->IsUndefined()) return probe; | |
1170 HandleScope scope(isolate_); | |
1171 StubCompiler compiler(isolate_); | 1097 StubCompiler compiler(isolate_); |
1172 return FillCache(isolate_, compiler.CompileCallDebugBreak(flags)); | 1098 Handle<Code> code = compiler.CompileCallDebugBreak(flags); |
| 1099 FillCache(isolate_, code); |
| 1100 return code; |
1173 } | 1101 } |
1174 | 1102 |
1175 | 1103 |
1176 MaybeObject* StubCache::ComputeCallDebugPrepareStepIn( | 1104 Handle<Code> StubCache::ComputeCallDebugPrepareStepIn(int argc, |
1177 int argc, | 1105 Code::Kind kind) { |
1178 Code::Kind kind) { | |
1179 // Extra IC state is irrelevant for debug break ICs. They jump to | 1106 // Extra IC state is irrelevant for debug break ICs. They jump to |
1180 // the actual call ic to carry out the work. | 1107 // the actual call ic to carry out the work. |
1181 Code::Flags flags = Code::ComputeFlags(kind, | 1108 Code::Flags flags = |
1182 DEBUG_PREPARE_STEP_IN, | 1109 Code::ComputeFlags(kind, DEBUG_PREPARE_STEP_IN, Code::kNoExtraICState, |
1183 Code::kNoExtraICState, | 1110 NORMAL, argc); |
1184 NORMAL, | 1111 Handle<NumberDictionary> cache = isolate_->factory()->non_monomorphic_cache(); |
1185 argc); | 1112 int entry = cache->FindEntry(isolate_, flags); |
1186 Object* probe; | 1113 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry))); |
1187 { MaybeObject* maybe_probe = ProbeCache(isolate_, flags); | 1114 |
1188 if (!maybe_probe->ToObject(&probe)) return maybe_probe; | |
1189 } | |
1190 if (!probe->IsUndefined()) return probe; | |
1191 HandleScope scope(isolate_); | |
1192 StubCompiler compiler(isolate_); | 1115 StubCompiler compiler(isolate_); |
1193 return FillCache(isolate_, compiler.CompileCallDebugPrepareStepIn(flags)); | 1116 Handle<Code> code = compiler.CompileCallDebugPrepareStepIn(flags); |
| 1117 FillCache(isolate_, code); |
| 1118 return code; |
1194 } | 1119 } |
1195 #endif | 1120 #endif |
1196 | 1121 |
1197 | 1122 |
1198 void StubCache::Clear() { | 1123 void StubCache::Clear() { |
1199 Code* empty = isolate_->builtins()->builtin(Builtins::kIllegal); | 1124 Code* empty = isolate_->builtins()->builtin(Builtins::kIllegal); |
1200 for (int i = 0; i < kPrimaryTableSize; i++) { | 1125 for (int i = 0; i < kPrimaryTableSize; i++) { |
1201 primary_[i].key = heap()->empty_string(); | 1126 primary_[i].key = heap()->empty_string(); |
1202 primary_[i].value = empty; | 1127 primary_[i].value = empty; |
1203 } | 1128 } |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1448 | 1373 |
1449 | 1374 |
1450 RUNTIME_FUNCTION(MaybeObject*, KeyedLoadPropertyWithInterceptor) { | 1375 RUNTIME_FUNCTION(MaybeObject*, KeyedLoadPropertyWithInterceptor) { |
1451 JSObject* receiver = JSObject::cast(args[0]); | 1376 JSObject* receiver = JSObject::cast(args[0]); |
1452 ASSERT(args.smi_at(1) >= 0); | 1377 ASSERT(args.smi_at(1) >= 0); |
1453 uint32_t index = args.smi_at(1); | 1378 uint32_t index = args.smi_at(1); |
1454 return receiver->GetElementWithInterceptor(receiver, index); | 1379 return receiver->GetElementWithInterceptor(receiver, index); |
1455 } | 1380 } |
1456 | 1381 |
1457 | 1382 |
1458 MaybeObject* StubCompiler::CompileCallInitialize(Code::Flags flags) { | 1383 Handle<Code> StubCompiler::CompileCallInitialize(Code::Flags flags) { |
| 1384 CALL_HEAP_FUNCTION(isolate(), TryCompileCallInitialize(flags), Code); |
| 1385 } |
| 1386 |
| 1387 |
| 1388 MaybeObject* StubCompiler::TryCompileCallInitialize(Code::Flags flags) { |
1459 HandleScope scope(isolate()); | 1389 HandleScope scope(isolate()); |
1460 int argc = Code::ExtractArgumentsCountFromFlags(flags); | 1390 int argc = Code::ExtractArgumentsCountFromFlags(flags); |
1461 Code::Kind kind = Code::ExtractKindFromFlags(flags); | 1391 Code::Kind kind = Code::ExtractKindFromFlags(flags); |
1462 Code::ExtraICState extra_ic_state = Code::ExtractExtraICStateFromFlags(flags); | 1392 Code::ExtraICState extra_state = Code::ExtractExtraICStateFromFlags(flags); |
1463 if (kind == Code::CALL_IC) { | 1393 if (kind == Code::CALL_IC) { |
1464 CallIC::GenerateInitialize(masm(), argc, extra_ic_state); | 1394 CallIC::GenerateInitialize(masm(), argc, extra_state); |
1465 } else { | 1395 } else { |
1466 KeyedCallIC::GenerateInitialize(masm(), argc); | 1396 KeyedCallIC::GenerateInitialize(masm(), argc); |
1467 } | 1397 } |
1468 Object* result; | 1398 Object* result; |
1469 { MaybeObject* maybe_result = | 1399 { MaybeObject* maybe_result = |
1470 GetCodeWithFlags(flags, "CompileCallInitialize"); | 1400 GetCodeWithFlags(flags, "CompileCallInitialize"); |
1471 if (!maybe_result->ToObject(&result)) return maybe_result; | 1401 if (!maybe_result->ToObject(&result)) return maybe_result; |
1472 } | 1402 } |
1473 isolate()->counters()->call_initialize_stubs()->Increment(); | 1403 isolate()->counters()->call_initialize_stubs()->Increment(); |
1474 Code* code = Code::cast(result); | 1404 Code* code = Code::cast(result); |
1475 USE(code); | 1405 USE(code); |
1476 PROFILE(isolate(), | 1406 PROFILE(isolate(), |
1477 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_INITIALIZE_TAG), | 1407 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_INITIALIZE_TAG), |
1478 code, code->arguments_count())); | 1408 code, code->arguments_count())); |
1479 GDBJIT(AddCode(GDBJITInterface::CALL_INITIALIZE, Code::cast(code))); | 1409 GDBJIT(AddCode(GDBJITInterface::CALL_INITIALIZE, Code::cast(code))); |
1480 return result; | 1410 return result; |
1481 } | 1411 } |
1482 | 1412 |
1483 | 1413 |
1484 MaybeObject* StubCompiler::CompileCallPreMonomorphic(Code::Flags flags) { | 1414 Handle<Code> StubCompiler::CompileCallPreMonomorphic(Code::Flags flags) { |
| 1415 CALL_HEAP_FUNCTION(isolate(), TryCompileCallPreMonomorphic(flags), Code); |
| 1416 } |
| 1417 |
| 1418 |
| 1419 MaybeObject* StubCompiler::TryCompileCallPreMonomorphic(Code::Flags flags) { |
1485 HandleScope scope(isolate()); | 1420 HandleScope scope(isolate()); |
1486 int argc = Code::ExtractArgumentsCountFromFlags(flags); | 1421 int argc = Code::ExtractArgumentsCountFromFlags(flags); |
1487 // The code of the PreMonomorphic stub is the same as the code | 1422 // The code of the PreMonomorphic stub is the same as the code |
1488 // of the Initialized stub. They just differ on the code object flags. | 1423 // of the Initialized stub. They just differ on the code object flags. |
1489 Code::Kind kind = Code::ExtractKindFromFlags(flags); | 1424 Code::Kind kind = Code::ExtractKindFromFlags(flags); |
1490 Code::ExtraICState extra_ic_state = Code::ExtractExtraICStateFromFlags(flags); | 1425 Code::ExtraICState extra_state = Code::ExtractExtraICStateFromFlags(flags); |
1491 if (kind == Code::CALL_IC) { | 1426 if (kind == Code::CALL_IC) { |
1492 CallIC::GenerateInitialize(masm(), argc, extra_ic_state); | 1427 CallIC::GenerateInitialize(masm(), argc, extra_state); |
1493 } else { | 1428 } else { |
1494 KeyedCallIC::GenerateInitialize(masm(), argc); | 1429 KeyedCallIC::GenerateInitialize(masm(), argc); |
1495 } | 1430 } |
1496 Object* result; | 1431 Object* result; |
1497 { MaybeObject* maybe_result = | 1432 { MaybeObject* maybe_result = |
1498 GetCodeWithFlags(flags, "CompileCallPreMonomorphic"); | 1433 GetCodeWithFlags(flags, "CompileCallPreMonomorphic"); |
1499 if (!maybe_result->ToObject(&result)) return maybe_result; | 1434 if (!maybe_result->ToObject(&result)) return maybe_result; |
1500 } | 1435 } |
1501 isolate()->counters()->call_premonomorphic_stubs()->Increment(); | 1436 isolate()->counters()->call_premonomorphic_stubs()->Increment(); |
1502 Code* code = Code::cast(result); | 1437 Code* code = Code::cast(result); |
1503 USE(code); | 1438 USE(code); |
1504 PROFILE(isolate(), | 1439 PROFILE(isolate(), |
1505 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_PRE_MONOMORPHIC_TAG), | 1440 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_PRE_MONOMORPHIC_TAG), |
1506 code, code->arguments_count())); | 1441 code, code->arguments_count())); |
1507 GDBJIT(AddCode(GDBJITInterface::CALL_PRE_MONOMORPHIC, Code::cast(code))); | 1442 GDBJIT(AddCode(GDBJITInterface::CALL_PRE_MONOMORPHIC, Code::cast(code))); |
1508 return result; | 1443 return result; |
1509 } | 1444 } |
1510 | 1445 |
1511 | 1446 |
1512 MaybeObject* StubCompiler::CompileCallNormal(Code::Flags flags) { | 1447 Handle<Code> StubCompiler::CompileCallNormal(Code::Flags flags) { |
| 1448 CALL_HEAP_FUNCTION(isolate(), TryCompileCallNormal(flags), Code); |
| 1449 } |
| 1450 |
| 1451 |
| 1452 MaybeObject* StubCompiler::TryCompileCallNormal(Code::Flags flags) { |
1513 HandleScope scope(isolate()); | 1453 HandleScope scope(isolate()); |
1514 int argc = Code::ExtractArgumentsCountFromFlags(flags); | 1454 int argc = Code::ExtractArgumentsCountFromFlags(flags); |
1515 Code::Kind kind = Code::ExtractKindFromFlags(flags); | 1455 Code::Kind kind = Code::ExtractKindFromFlags(flags); |
1516 if (kind == Code::CALL_IC) { | 1456 if (kind == Code::CALL_IC) { |
1517 // Call normal is always with a explict receiver. | 1457 // Call normal is always with a explict receiver. |
1518 ASSERT(!CallIC::Contextual::decode( | 1458 ASSERT(!CallIC::Contextual::decode( |
1519 Code::ExtractExtraICStateFromFlags(flags))); | 1459 Code::ExtractExtraICStateFromFlags(flags))); |
1520 CallIC::GenerateNormal(masm(), argc); | 1460 CallIC::GenerateNormal(masm(), argc); |
1521 } else { | 1461 } else { |
1522 KeyedCallIC::GenerateNormal(masm(), argc); | 1462 KeyedCallIC::GenerateNormal(masm(), argc); |
1523 } | 1463 } |
1524 Object* result; | 1464 Object* result; |
1525 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "CompileCallNormal"); | 1465 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "CompileCallNormal"); |
1526 if (!maybe_result->ToObject(&result)) return maybe_result; | 1466 if (!maybe_result->ToObject(&result)) return maybe_result; |
1527 } | 1467 } |
1528 isolate()->counters()->call_normal_stubs()->Increment(); | 1468 isolate()->counters()->call_normal_stubs()->Increment(); |
1529 Code* code = Code::cast(result); | 1469 Code* code = Code::cast(result); |
1530 USE(code); | 1470 USE(code); |
1531 PROFILE(isolate(), | 1471 PROFILE(isolate(), |
1532 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_NORMAL_TAG), | 1472 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_NORMAL_TAG), |
1533 code, code->arguments_count())); | 1473 code, code->arguments_count())); |
1534 GDBJIT(AddCode(GDBJITInterface::CALL_NORMAL, Code::cast(code))); | 1474 GDBJIT(AddCode(GDBJITInterface::CALL_NORMAL, Code::cast(code))); |
1535 return result; | 1475 return result; |
1536 } | 1476 } |
1537 | 1477 |
1538 | 1478 |
1539 MaybeObject* StubCompiler::CompileCallMegamorphic(Code::Flags flags) { | 1479 Handle<Code> StubCompiler::CompileCallMegamorphic(Code::Flags flags) { |
| 1480 CALL_HEAP_FUNCTION(isolate(), TryCompileCallMegamorphic(flags), Code); |
| 1481 } |
| 1482 |
| 1483 |
| 1484 MaybeObject* StubCompiler::TryCompileCallMegamorphic(Code::Flags flags) { |
1540 HandleScope scope(isolate()); | 1485 HandleScope scope(isolate()); |
1541 int argc = Code::ExtractArgumentsCountFromFlags(flags); | 1486 int argc = Code::ExtractArgumentsCountFromFlags(flags); |
1542 Code::Kind kind = Code::ExtractKindFromFlags(flags); | 1487 Code::Kind kind = Code::ExtractKindFromFlags(flags); |
1543 Code::ExtraICState extra_ic_state = Code::ExtractExtraICStateFromFlags(flags); | 1488 Code::ExtraICState extra_state = Code::ExtractExtraICStateFromFlags(flags); |
1544 if (kind == Code::CALL_IC) { | 1489 if (kind == Code::CALL_IC) { |
1545 CallIC::GenerateMegamorphic(masm(), argc, extra_ic_state); | 1490 CallIC::GenerateMegamorphic(masm(), argc, extra_state); |
1546 } else { | 1491 } else { |
1547 KeyedCallIC::GenerateMegamorphic(masm(), argc); | 1492 KeyedCallIC::GenerateMegamorphic(masm(), argc); |
1548 } | 1493 } |
1549 Object* result; | 1494 Object* result; |
1550 { MaybeObject* maybe_result = | 1495 { MaybeObject* maybe_result = |
1551 GetCodeWithFlags(flags, "CompileCallMegamorphic"); | 1496 GetCodeWithFlags(flags, "CompileCallMegamorphic"); |
1552 if (!maybe_result->ToObject(&result)) return maybe_result; | 1497 if (!maybe_result->ToObject(&result)) return maybe_result; |
1553 } | 1498 } |
1554 isolate()->counters()->call_megamorphic_stubs()->Increment(); | 1499 isolate()->counters()->call_megamorphic_stubs()->Increment(); |
1555 Code* code = Code::cast(result); | 1500 Code* code = Code::cast(result); |
1556 USE(code); | 1501 USE(code); |
1557 PROFILE(isolate(), | 1502 PROFILE(isolate(), |
1558 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_MEGAMORPHIC_TAG), | 1503 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_MEGAMORPHIC_TAG), |
1559 code, code->arguments_count())); | 1504 code, code->arguments_count())); |
1560 GDBJIT(AddCode(GDBJITInterface::CALL_MEGAMORPHIC, Code::cast(code))); | 1505 GDBJIT(AddCode(GDBJITInterface::CALL_MEGAMORPHIC, Code::cast(code))); |
1561 return result; | 1506 return result; |
1562 } | 1507 } |
1563 | 1508 |
1564 | 1509 |
1565 MaybeObject* StubCompiler::CompileCallArguments(Code::Flags flags) { | 1510 Handle<Code> StubCompiler::CompileCallArguments(Code::Flags flags) { |
| 1511 CALL_HEAP_FUNCTION(isolate(), TryCompileCallArguments(flags), Code); |
| 1512 } |
| 1513 |
| 1514 |
| 1515 MaybeObject* StubCompiler::TryCompileCallArguments(Code::Flags flags) { |
1566 HandleScope scope(isolate()); | 1516 HandleScope scope(isolate()); |
1567 int argc = Code::ExtractArgumentsCountFromFlags(flags); | 1517 int argc = Code::ExtractArgumentsCountFromFlags(flags); |
1568 KeyedCallIC::GenerateNonStrictArguments(masm(), argc); | 1518 KeyedCallIC::GenerateNonStrictArguments(masm(), argc); |
1569 Code::Kind kind = Code::ExtractKindFromFlags(flags); | 1519 Code::Kind kind = Code::ExtractKindFromFlags(flags); |
1570 Object* result; | 1520 Object* result; |
1571 { MaybeObject* maybe_result = | 1521 { MaybeObject* maybe_result = |
1572 GetCodeWithFlags(flags, "CompileCallArguments"); | 1522 GetCodeWithFlags(flags, "CompileCallArguments"); |
1573 if (!maybe_result->ToObject(&result)) return maybe_result; | 1523 if (!maybe_result->ToObject(&result)) return maybe_result; |
1574 } | 1524 } |
1575 Code* code = Code::cast(result); | 1525 Code* code = Code::cast(result); |
1576 USE(code); | 1526 USE(code); |
1577 PROFILE(isolate(), | 1527 PROFILE(isolate(), |
1578 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_MEGAMORPHIC_TAG), | 1528 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_MEGAMORPHIC_TAG), |
1579 code, code->arguments_count())); | 1529 code, code->arguments_count())); |
1580 GDBJIT(AddCode(GDBJITInterface::CALL_MEGAMORPHIC, Code::cast(code))); | 1530 GDBJIT(AddCode(GDBJITInterface::CALL_MEGAMORPHIC, Code::cast(code))); |
1581 return result; | 1531 return result; |
1582 } | 1532 } |
1583 | 1533 |
1584 | 1534 |
1585 MaybeObject* StubCompiler::CompileCallMiss(Code::Flags flags) { | 1535 Handle<Code> StubCompiler::CompileCallMiss(Code::Flags flags) { |
| 1536 CALL_HEAP_FUNCTION(isolate(), TryCompileCallMiss(flags), Code); |
| 1537 } |
| 1538 |
| 1539 |
| 1540 MaybeObject* StubCompiler::TryCompileCallMiss(Code::Flags flags) { |
1586 HandleScope scope(isolate()); | 1541 HandleScope scope(isolate()); |
1587 int argc = Code::ExtractArgumentsCountFromFlags(flags); | 1542 int argc = Code::ExtractArgumentsCountFromFlags(flags); |
1588 Code::Kind kind = Code::ExtractKindFromFlags(flags); | 1543 Code::Kind kind = Code::ExtractKindFromFlags(flags); |
1589 Code::ExtraICState extra_ic_state = Code::ExtractExtraICStateFromFlags(flags); | 1544 Code::ExtraICState extra_state = Code::ExtractExtraICStateFromFlags(flags); |
1590 if (kind == Code::CALL_IC) { | 1545 if (kind == Code::CALL_IC) { |
1591 CallIC::GenerateMiss(masm(), argc, extra_ic_state); | 1546 CallIC::GenerateMiss(masm(), argc, extra_state); |
1592 } else { | 1547 } else { |
1593 KeyedCallIC::GenerateMiss(masm(), argc); | 1548 KeyedCallIC::GenerateMiss(masm(), argc); |
1594 } | 1549 } |
1595 Object* result; | 1550 Object* result; |
1596 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "CompileCallMiss"); | 1551 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "CompileCallMiss"); |
1597 if (!maybe_result->ToObject(&result)) return maybe_result; | 1552 if (!maybe_result->ToObject(&result)) return maybe_result; |
1598 } | 1553 } |
1599 isolate()->counters()->call_megamorphic_stubs()->Increment(); | 1554 isolate()->counters()->call_megamorphic_stubs()->Increment(); |
1600 Code* code = Code::cast(result); | 1555 Code* code = Code::cast(result); |
1601 USE(code); | 1556 USE(code); |
1602 PROFILE(isolate(), | 1557 PROFILE(isolate(), |
1603 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_MISS_TAG), | 1558 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_MISS_TAG), |
1604 code, code->arguments_count())); | 1559 code, code->arguments_count())); |
1605 GDBJIT(AddCode(GDBJITInterface::CALL_MISS, Code::cast(code))); | 1560 GDBJIT(AddCode(GDBJITInterface::CALL_MISS, Code::cast(code))); |
1606 return result; | 1561 return result; |
1607 } | 1562 } |
1608 | 1563 |
1609 | 1564 |
1610 #ifdef ENABLE_DEBUGGER_SUPPORT | 1565 #ifdef ENABLE_DEBUGGER_SUPPORT |
1611 MaybeObject* StubCompiler::CompileCallDebugBreak(Code::Flags flags) { | 1566 Handle<Code> StubCompiler::CompileCallDebugBreak(Code::Flags flags) { |
| 1567 CALL_HEAP_FUNCTION(isolate(), TryCompileCallDebugBreak(flags), Code); |
| 1568 } |
| 1569 |
| 1570 |
| 1571 MaybeObject* StubCompiler::TryCompileCallDebugBreak(Code::Flags flags) { |
1612 HandleScope scope(isolate()); | 1572 HandleScope scope(isolate()); |
1613 Debug::GenerateCallICDebugBreak(masm()); | 1573 Debug::GenerateCallICDebugBreak(masm()); |
1614 Object* result; | 1574 Object* result; |
1615 { MaybeObject* maybe_result = | 1575 { MaybeObject* maybe_result = |
1616 GetCodeWithFlags(flags, "CompileCallDebugBreak"); | 1576 GetCodeWithFlags(flags, "CompileCallDebugBreak"); |
1617 if (!maybe_result->ToObject(&result)) return maybe_result; | 1577 if (!maybe_result->ToObject(&result)) return maybe_result; |
1618 } | 1578 } |
1619 Code* code = Code::cast(result); | 1579 Code* code = Code::cast(result); |
1620 USE(code); | 1580 USE(code); |
1621 Code::Kind kind = Code::ExtractKindFromFlags(flags); | 1581 Code::Kind kind = Code::ExtractKindFromFlags(flags); |
1622 USE(kind); | 1582 USE(kind); |
1623 PROFILE(isolate(), | 1583 PROFILE(isolate(), |
1624 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_DEBUG_BREAK_TAG), | 1584 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_DEBUG_BREAK_TAG), |
1625 code, code->arguments_count())); | 1585 code, code->arguments_count())); |
1626 return result; | 1586 return result; |
1627 } | 1587 } |
1628 | 1588 |
1629 | 1589 |
1630 MaybeObject* StubCompiler::CompileCallDebugPrepareStepIn(Code::Flags flags) { | 1590 Handle<Code> StubCompiler::CompileCallDebugPrepareStepIn(Code::Flags flags) { |
| 1591 CALL_HEAP_FUNCTION(isolate(), TryCompileCallDebugPrepareStepIn(flags), Code); |
| 1592 } |
| 1593 |
| 1594 |
| 1595 MaybeObject* StubCompiler::TryCompileCallDebugPrepareStepIn(Code::Flags flags) { |
1631 HandleScope scope(isolate()); | 1596 HandleScope scope(isolate()); |
1632 // Use the same code for the the step in preparations as we do for | 1597 // Use the same code for the the step in preparations as we do for |
1633 // the miss case. | 1598 // the miss case. |
1634 int argc = Code::ExtractArgumentsCountFromFlags(flags); | 1599 int argc = Code::ExtractArgumentsCountFromFlags(flags); |
1635 Code::Kind kind = Code::ExtractKindFromFlags(flags); | 1600 Code::Kind kind = Code::ExtractKindFromFlags(flags); |
1636 if (kind == Code::CALL_IC) { | 1601 if (kind == Code::CALL_IC) { |
1637 // For the debugger extra ic state is irrelevant. | 1602 // For the debugger extra ic state is irrelevant. |
1638 CallIC::GenerateMiss(masm(), argc, Code::kNoExtraICState); | 1603 CallIC::GenerateMiss(masm(), argc, Code::kNoExtraICState); |
1639 } else { | 1604 } else { |
1640 KeyedCallIC::GenerateMiss(masm(), argc); | 1605 KeyedCallIC::GenerateMiss(masm(), argc); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1771 | 1736 |
1772 void KeyedStoreStubCompiler::GenerateStoreDictionaryElement( | 1737 void KeyedStoreStubCompiler::GenerateStoreDictionaryElement( |
1773 MacroAssembler* masm) { | 1738 MacroAssembler* masm) { |
1774 KeyedStoreIC::GenerateSlow(masm); | 1739 KeyedStoreIC::GenerateSlow(masm); |
1775 } | 1740 } |
1776 | 1741 |
1777 | 1742 |
1778 CallStubCompiler::CallStubCompiler(Isolate* isolate, | 1743 CallStubCompiler::CallStubCompiler(Isolate* isolate, |
1779 int argc, | 1744 int argc, |
1780 Code::Kind kind, | 1745 Code::Kind kind, |
1781 Code::ExtraICState extra_ic_state, | 1746 Code::ExtraICState extra_state, |
1782 InlineCacheHolderFlag cache_holder) | 1747 InlineCacheHolderFlag cache_holder) |
1783 : StubCompiler(isolate), | 1748 : StubCompiler(isolate), |
1784 arguments_(argc), | 1749 arguments_(argc), |
1785 kind_(kind), | 1750 kind_(kind), |
1786 extra_ic_state_(extra_ic_state), | 1751 extra_state_(extra_state), |
1787 cache_holder_(cache_holder) { | 1752 cache_holder_(cache_holder) { |
1788 } | 1753 } |
1789 | 1754 |
1790 | 1755 |
1791 bool CallStubCompiler::HasCustomCallGenerator(JSFunction* function) { | 1756 bool CallStubCompiler::HasCustomCallGenerator(JSFunction* function) { |
1792 SharedFunctionInfo* info = function->shared(); | 1757 SharedFunctionInfo* info = function->shared(); |
1793 if (info->HasBuiltinFunctionId()) { | 1758 if (info->HasBuiltinFunctionId()) { |
1794 BuiltinFunctionId id = info->builtin_function_id(); | 1759 BuiltinFunctionId id = info->builtin_function_id(); |
1795 #define CALL_GENERATOR_CASE(name) if (id == k##name) return true; | 1760 #define CALL_GENERATOR_CASE(name) if (id == k##name) return true; |
1796 CUSTOM_CALL_IC_GENERATORS(CALL_GENERATOR_CASE) | 1761 CUSTOM_CALL_IC_GENERATORS(CALL_GENERATOR_CASE) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1833 cell, | 1798 cell, |
1834 function, | 1799 function, |
1835 fname); | 1800 fname); |
1836 } | 1801 } |
1837 | 1802 |
1838 | 1803 |
1839 MaybeObject* CallStubCompiler::GetCode(PropertyType type, String* name) { | 1804 MaybeObject* CallStubCompiler::GetCode(PropertyType type, String* name) { |
1840 int argc = arguments_.immediate(); | 1805 int argc = arguments_.immediate(); |
1841 Code::Flags flags = Code::ComputeMonomorphicFlags(kind_, | 1806 Code::Flags flags = Code::ComputeMonomorphicFlags(kind_, |
1842 type, | 1807 type, |
1843 extra_ic_state_, | 1808 extra_state_, |
1844 cache_holder_, | 1809 cache_holder_, |
1845 argc); | 1810 argc); |
1846 return GetCodeWithFlags(flags, name); | 1811 return GetCodeWithFlags(flags, name); |
1847 } | 1812 } |
1848 | 1813 |
1849 | 1814 |
1850 MaybeObject* CallStubCompiler::GetCode(JSFunction* function) { | 1815 MaybeObject* CallStubCompiler::GetCode(JSFunction* function) { |
1851 String* function_name = NULL; | 1816 String* function_name = NULL; |
1852 if (function->shared()->name()->IsString()) { | 1817 if (function->shared()->name()->IsString()) { |
1853 function_name = String::cast(function->shared()->name()); | 1818 function_name = String::cast(function->shared()->name()); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1931 expected_receiver_type_ = | 1896 expected_receiver_type_ = |
1932 FunctionTemplateInfo::cast(signature->receiver()); | 1897 FunctionTemplateInfo::cast(signature->receiver()); |
1933 } | 1898 } |
1934 } | 1899 } |
1935 | 1900 |
1936 is_simple_api_call_ = true; | 1901 is_simple_api_call_ = true; |
1937 } | 1902 } |
1938 | 1903 |
1939 | 1904 |
1940 } } // namespace v8::internal | 1905 } } // namespace v8::internal |
OLD | NEW |