OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 handler = | 265 handler = |
266 compiler.CompileLoadNonexistent(receiver, current, cache_name, global); | 266 compiler.CompileLoadNonexistent(receiver, current, cache_name, global); |
267 JSObject::UpdateMapCodeCache(receiver, cache_name, handler); | 267 JSObject::UpdateMapCodeCache(receiver, cache_name, handler); |
268 return handler; | 268 return handler; |
269 } | 269 } |
270 | 270 |
271 | 271 |
272 Handle<Code> StubCache::ComputeLoadField(Handle<Name> name, | 272 Handle<Code> StubCache::ComputeLoadField(Handle<Name> name, |
273 Handle<JSObject> receiver, | 273 Handle<JSObject> receiver, |
274 Handle<JSObject> holder, | 274 Handle<JSObject> holder, |
275 Code::Kind kind, | |
276 PropertyIndex field, | 275 PropertyIndex field, |
277 Representation representation) { | 276 Representation representation) { |
278 if (receiver.is_identical_to(holder)) { | 277 if (receiver.is_identical_to(holder)) { |
279 if (kind == Code::LOAD_IC) { | 278 LoadFieldStub stub(field.is_inobject(holder), |
280 LoadFieldStub stub(field.is_inobject(holder), | 279 field.translate(holder), |
281 field.translate(holder), | 280 representation); |
282 representation); | 281 return stub.GetCode(isolate()); |
283 return stub.GetCode(isolate()); | |
284 } else { | |
285 KeyedLoadFieldStub stub(field.is_inobject(holder), | |
286 field.translate(holder), | |
287 representation); | |
288 return stub.GetCode(isolate()); | |
289 } | |
290 } | 282 } |
291 | 283 |
292 Handle<JSObject> stub_holder = StubHolder(receiver, holder); | 284 Handle<JSObject> stub_holder = StubHolder(receiver, holder); |
293 Handle<Code> stub = FindLoadHandler( | 285 Handle<Code> stub = FindLoadHandler( |
294 name, receiver, stub_holder, kind, Code::FIELD); | 286 name, receiver, stub_holder, Code::LOAD_IC, Code::FIELD); |
295 if (!stub.is_null()) return stub; | 287 if (!stub.is_null()) return stub; |
296 | 288 |
297 BaseLoadStubCompiler compiler(isolate_, kind); | 289 LoadStubCompiler compiler(isolate_); |
298 Handle<Code> handler = | 290 Handle<Code> handler = |
299 compiler.CompileLoadField(receiver, holder, name, field, representation); | 291 compiler.CompileLoadField(receiver, holder, name, field, representation); |
300 JSObject::UpdateMapCodeCache(stub_holder, name, handler); | 292 JSObject::UpdateMapCodeCache(stub_holder, name, handler); |
301 return handler; | 293 return handler; |
302 } | 294 } |
303 | 295 |
304 | 296 |
305 Handle<Code> StubCache::ComputeLoadCallback( | 297 Handle<Code> StubCache::ComputeLoadCallback( |
306 Handle<Name> name, | 298 Handle<Name> name, |
307 Handle<JSObject> receiver, | 299 Handle<JSObject> receiver, |
308 Handle<JSObject> holder, | 300 Handle<JSObject> holder, |
309 Code::Kind kind, | |
310 Handle<ExecutableAccessorInfo> callback) { | 301 Handle<ExecutableAccessorInfo> callback) { |
311 ASSERT(v8::ToCData<Address>(callback->getter()) != 0); | 302 ASSERT(v8::ToCData<Address>(callback->getter()) != 0); |
312 Handle<JSObject> stub_holder = StubHolder(receiver, holder); | 303 Handle<JSObject> stub_holder = StubHolder(receiver, holder); |
313 Handle<Code> stub = FindLoadHandler( | 304 Handle<Code> stub = FindLoadHandler( |
314 name, receiver, stub_holder, kind, Code::CALLBACKS); | 305 name, receiver, stub_holder, Code::LOAD_IC, Code::CALLBACKS); |
315 if (!stub.is_null()) return stub; | 306 if (!stub.is_null()) return stub; |
316 | 307 |
317 BaseLoadStubCompiler compiler(isolate_, kind); | 308 LoadStubCompiler compiler(isolate_); |
318 Handle<Code> handler = | 309 Handle<Code> handler = |
319 compiler.CompileLoadCallback(receiver, holder, name, callback); | 310 compiler.CompileLoadCallback(receiver, holder, name, callback); |
320 JSObject::UpdateMapCodeCache(stub_holder, name, handler); | 311 JSObject::UpdateMapCodeCache(stub_holder, name, handler); |
321 return handler; | 312 return handler; |
322 } | 313 } |
323 | 314 |
324 | 315 |
325 Handle<Code> StubCache::ComputeLoadCallback( | 316 Handle<Code> StubCache::ComputeLoadCallback( |
326 Handle<Name> name, | 317 Handle<Name> name, |
327 Handle<JSObject> receiver, | 318 Handle<JSObject> receiver, |
328 Handle<JSObject> holder, | 319 Handle<JSObject> holder, |
329 Code::Kind kind, | |
330 const CallOptimization& call_optimization) { | 320 const CallOptimization& call_optimization) { |
331 Handle<JSObject> stub_holder = StubHolder(receiver, holder); | 321 Handle<JSObject> stub_holder = StubHolder(receiver, holder); |
332 Handle<Code> stub = FindLoadHandler( | 322 Handle<Code> stub = FindLoadHandler( |
333 name, receiver, stub_holder, kind, Code::CALLBACKS); | 323 name, receiver, stub_holder, Code::LOAD_IC, Code::CALLBACKS); |
334 if (!stub.is_null()) return stub; | 324 if (!stub.is_null()) return stub; |
335 | 325 |
336 BaseLoadStubCompiler compiler(isolate_, kind); | 326 LoadStubCompiler compiler(isolate_); |
337 Handle<Code> handler = | 327 Handle<Code> handler = |
338 compiler.CompileLoadCallback(receiver, holder, name, call_optimization); | 328 compiler.CompileLoadCallback(receiver, holder, name, call_optimization); |
339 JSObject::UpdateMapCodeCache(stub_holder, name, handler); | 329 JSObject::UpdateMapCodeCache(stub_holder, name, handler); |
340 return handler; | 330 return handler; |
341 } | 331 } |
342 | 332 |
343 | 333 |
344 Handle<Code> StubCache::ComputeLoadViaGetter(Handle<Name> name, | 334 Handle<Code> StubCache::ComputeLoadViaGetter(Handle<Name> name, |
345 Handle<JSObject> receiver, | 335 Handle<JSObject> receiver, |
346 Handle<JSObject> holder, | 336 Handle<JSObject> holder, |
347 Handle<JSFunction> getter) { | 337 Handle<JSFunction> getter) { |
348 Handle<JSObject> stub_holder = StubHolder(receiver, holder); | 338 Handle<JSObject> stub_holder = StubHolder(receiver, holder); |
349 Handle<Code> stub = FindLoadHandler( | 339 Handle<Code> stub = FindLoadHandler( |
350 name, receiver, stub_holder, Code::LOAD_IC, Code::CALLBACKS); | 340 name, receiver, stub_holder, Code::LOAD_IC, Code::CALLBACKS); |
351 if (!stub.is_null()) return stub; | 341 if (!stub.is_null()) return stub; |
352 | 342 |
353 LoadStubCompiler compiler(isolate_); | 343 LoadStubCompiler compiler(isolate_); |
354 Handle<Code> handler = | 344 Handle<Code> handler = |
355 compiler.CompileLoadViaGetter(receiver, holder, name, getter); | 345 compiler.CompileLoadViaGetter(receiver, holder, name, getter); |
356 JSObject::UpdateMapCodeCache(stub_holder, name, handler); | 346 JSObject::UpdateMapCodeCache(stub_holder, name, handler); |
357 return handler; | 347 return handler; |
358 } | 348 } |
359 | 349 |
360 | 350 |
361 Handle<Code> StubCache::ComputeLoadConstant(Handle<Name> name, | 351 Handle<Code> StubCache::ComputeLoadConstant(Handle<Name> name, |
362 Handle<JSObject> receiver, | 352 Handle<JSObject> receiver, |
363 Handle<JSObject> holder, | 353 Handle<JSObject> holder, |
364 Code::Kind kind, | |
365 Handle<Object> value) { | 354 Handle<Object> value) { |
366 Handle<JSObject> stub_holder = StubHolder(receiver, holder); | 355 Handle<JSObject> stub_holder = StubHolder(receiver, holder); |
367 Handle<Code> handler = FindLoadHandler( | 356 Handle<Code> handler = FindLoadHandler( |
368 name, receiver, stub_holder, kind, Code::CONSTANT); | 357 name, receiver, stub_holder, Code::LOAD_IC, Code::CONSTANT); |
369 if (!handler.is_null()) return handler; | 358 if (!handler.is_null()) return handler; |
370 | 359 |
371 BaseLoadStubCompiler compiler(isolate_, kind); | 360 LoadStubCompiler compiler(isolate_); |
372 handler = compiler.CompileLoadConstant(receiver, holder, name, value); | 361 handler = compiler.CompileLoadConstant(receiver, holder, name, value); |
373 JSObject::UpdateMapCodeCache(stub_holder, name, handler); | 362 JSObject::UpdateMapCodeCache(stub_holder, name, handler); |
| 363 |
374 return handler; | 364 return handler; |
375 } | 365 } |
376 | 366 |
377 | 367 |
378 Handle<Code> StubCache::ComputeLoadInterceptor(Handle<Name> name, | 368 Handle<Code> StubCache::ComputeLoadInterceptor(Handle<Name> name, |
379 Handle<JSObject> receiver, | 369 Handle<JSObject> receiver, |
380 Handle<JSObject> holder, | 370 Handle<JSObject> holder) { |
381 Code::Kind kind) { | |
382 Handle<JSObject> stub_holder = StubHolder(receiver, holder); | 371 Handle<JSObject> stub_holder = StubHolder(receiver, holder); |
383 Handle<Code> stub = FindLoadHandler( | 372 Handle<Code> stub = FindLoadHandler( |
384 name, receiver, stub_holder, kind, Code::INTERCEPTOR); | 373 name, receiver, stub_holder, Code::LOAD_IC, Code::INTERCEPTOR); |
385 if (!stub.is_null()) return stub; | 374 if (!stub.is_null()) return stub; |
386 | 375 |
387 BaseLoadStubCompiler compiler(isolate_, kind); | 376 LoadStubCompiler compiler(isolate_); |
388 Handle<Code> handler = | 377 Handle<Code> handler = |
389 compiler.CompileLoadInterceptor(receiver, holder, name); | 378 compiler.CompileLoadInterceptor(receiver, holder, name); |
390 JSObject::UpdateMapCodeCache(stub_holder, name, handler); | 379 JSObject::UpdateMapCodeCache(stub_holder, name, handler); |
391 return handler; | 380 return handler; |
392 } | 381 } |
393 | 382 |
394 | 383 |
395 Handle<Code> StubCache::ComputeLoadNormal(Handle<Name> name, | 384 Handle<Code> StubCache::ComputeLoadNormal(Handle<Name> name, |
396 Handle<JSObject> receiver) { | 385 Handle<JSObject> receiver) { |
397 return isolate_->builtins()->LoadIC_Normal(); | 386 return isolate_->builtins()->LoadIC_Normal(); |
(...skipping 10 matching lines...) Expand all Loading... |
408 if (!stub.is_null()) return stub; | 397 if (!stub.is_null()) return stub; |
409 | 398 |
410 LoadStubCompiler compiler(isolate_); | 399 LoadStubCompiler compiler(isolate_); |
411 Handle<Code> ic = | 400 Handle<Code> ic = |
412 compiler.CompileLoadGlobal(receiver, holder, cell, name, is_dont_delete); | 401 compiler.CompileLoadGlobal(receiver, holder, cell, name, is_dont_delete); |
413 JSObject::UpdateMapCodeCache(stub_holder, name, ic); | 402 JSObject::UpdateMapCodeCache(stub_holder, name, ic); |
414 return ic; | 403 return ic; |
415 } | 404 } |
416 | 405 |
417 | 406 |
| 407 Handle<Code> StubCache::ComputeKeyedLoadField(Handle<Name> name, |
| 408 Handle<JSObject> receiver, |
| 409 Handle<JSObject> holder, |
| 410 PropertyIndex field, |
| 411 Representation representation) { |
| 412 if (receiver.is_identical_to(holder)) { |
| 413 // TODO(titzer): this should use an HObjectAccess |
| 414 KeyedLoadFieldStub stub(field.is_inobject(holder), |
| 415 field.translate(holder), |
| 416 representation); |
| 417 return stub.GetCode(isolate()); |
| 418 } |
| 419 |
| 420 Handle<JSObject> stub_holder = StubHolder(receiver, holder); |
| 421 Handle<Code> stub = FindLoadHandler( |
| 422 name, receiver, stub_holder, Code::KEYED_LOAD_IC, Code::FIELD); |
| 423 if (!stub.is_null()) return stub; |
| 424 |
| 425 KeyedLoadStubCompiler compiler(isolate_); |
| 426 Handle<Code> handler = |
| 427 compiler.CompileLoadField(receiver, holder, name, field, representation); |
| 428 JSObject::UpdateMapCodeCache(stub_holder, name, handler); |
| 429 return handler; |
| 430 } |
| 431 |
| 432 |
| 433 Handle<Code> StubCache::ComputeKeyedLoadConstant(Handle<Name> name, |
| 434 Handle<JSObject> receiver, |
| 435 Handle<JSObject> holder, |
| 436 Handle<Object> value) { |
| 437 Handle<JSObject> stub_holder = StubHolder(receiver, holder); |
| 438 Handle<Code> handler = FindLoadHandler( |
| 439 name, receiver, stub_holder, Code::KEYED_LOAD_IC, |
| 440 Code::CONSTANT); |
| 441 if (!handler.is_null()) return handler; |
| 442 |
| 443 KeyedLoadStubCompiler compiler(isolate_); |
| 444 handler = compiler.CompileLoadConstant(receiver, holder, name, value); |
| 445 JSObject::UpdateMapCodeCache(stub_holder, name, handler); |
| 446 return handler; |
| 447 } |
| 448 |
| 449 |
| 450 Handle<Code> StubCache::ComputeKeyedLoadInterceptor(Handle<Name> name, |
| 451 Handle<JSObject> receiver, |
| 452 Handle<JSObject> holder) { |
| 453 Handle<JSObject> stub_holder = StubHolder(receiver, holder); |
| 454 Handle<Code> stub = FindLoadHandler( |
| 455 name, receiver, stub_holder, Code::KEYED_LOAD_IC, Code::INTERCEPTOR); |
| 456 if (!stub.is_null()) return stub; |
| 457 |
| 458 KeyedLoadStubCompiler compiler(isolate_); |
| 459 Handle<Code> handler = |
| 460 compiler.CompileLoadInterceptor(receiver, holder, name); |
| 461 JSObject::UpdateMapCodeCache(stub_holder, name, handler); |
| 462 return handler; |
| 463 } |
| 464 |
| 465 |
| 466 Handle<Code> StubCache::ComputeKeyedLoadCallback( |
| 467 Handle<Name> name, |
| 468 Handle<JSObject> receiver, |
| 469 Handle<JSObject> holder, |
| 470 Handle<ExecutableAccessorInfo> callback) { |
| 471 Handle<JSObject> stub_holder = StubHolder(receiver, holder); |
| 472 Handle<Code> stub = FindLoadHandler( |
| 473 name, receiver, stub_holder, Code::KEYED_LOAD_IC, Code::CALLBACKS); |
| 474 if (!stub.is_null()) return stub; |
| 475 |
| 476 KeyedLoadStubCompiler compiler(isolate_); |
| 477 Handle<Code> handler = |
| 478 compiler.CompileLoadCallback(receiver, holder, name, callback); |
| 479 JSObject::UpdateMapCodeCache(stub_holder, name, handler); |
| 480 return handler; |
| 481 } |
| 482 |
| 483 |
| 484 Handle<Code> StubCache::ComputeKeyedLoadCallback( |
| 485 Handle<Name> name, |
| 486 Handle<JSObject> receiver, |
| 487 Handle<JSObject> holder, |
| 488 const CallOptimization& call_optimization) { |
| 489 Handle<JSObject> stub_holder = StubHolder(receiver, holder); |
| 490 Handle<Code> stub = FindLoadHandler( |
| 491 name, receiver, stub_holder, Code::KEYED_LOAD_IC, Code::CALLBACKS); |
| 492 if (!stub.is_null()) return stub; |
| 493 |
| 494 KeyedLoadStubCompiler compiler(isolate_); |
| 495 Handle<Code> handler = |
| 496 compiler.CompileLoadCallback(receiver, holder, name, call_optimization); |
| 497 JSObject::UpdateMapCodeCache(stub_holder, name, handler); |
| 498 return handler; |
| 499 } |
| 500 |
| 501 |
418 Handle<Code> StubCache::ComputeStoreField(Handle<Name> name, | 502 Handle<Code> StubCache::ComputeStoreField(Handle<Name> name, |
419 Handle<JSObject> receiver, | 503 Handle<JSObject> receiver, |
420 LookupResult* lookup, | 504 LookupResult* lookup, |
421 StrictModeFlag strict_mode) { | 505 StrictModeFlag strict_mode) { |
422 Handle<Code> stub = FindStoreHandler( | 506 Handle<Code> stub = FindStoreHandler( |
423 name, receiver, Code::STORE_IC, Code::FIELD, strict_mode); | 507 name, receiver, Code::STORE_IC, Code::FIELD, strict_mode); |
424 if (!stub.is_null()) return stub; | 508 if (!stub.is_null()) return stub; |
425 | 509 |
426 StoreStubCompiler compiler(isolate_, strict_mode); | 510 StoreStubCompiler compiler(isolate_, strict_mode); |
427 Handle<Code> handler = compiler.CompileStoreField(receiver, lookup, name); | 511 Handle<Code> handler = compiler.CompileStoreField(receiver, lookup, name); |
(...skipping 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1866 | 1950 |
1867 #undef __ | 1951 #undef __ |
1868 | 1952 |
1869 | 1953 |
1870 void StubCompiler::TailCallBuiltin(MacroAssembler* masm, Builtins::Name name) { | 1954 void StubCompiler::TailCallBuiltin(MacroAssembler* masm, Builtins::Name name) { |
1871 Handle<Code> code(masm->isolate()->builtins()->builtin(name)); | 1955 Handle<Code> code(masm->isolate()->builtins()->builtin(name)); |
1872 GenerateTailCall(masm, code); | 1956 GenerateTailCall(masm, code); |
1873 } | 1957 } |
1874 | 1958 |
1875 | 1959 |
1876 Register* BaseLoadStoreStubCompiler::GetRegisters(Code::Kind kind) { | 1960 void LoadStubCompiler::JitEvent(Handle<Name> name, Handle<Code> code) { |
1877 switch (kind) { | 1961 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *name, *code)); |
1878 case Code::LOAD_IC: return LoadStubCompiler::registers(); | |
1879 case Code::STORE_IC: return StoreStubCompiler::registers(); | |
1880 case Code::KEYED_LOAD_IC: return KeyedLoadStubCompiler::registers(); | |
1881 case Code::KEYED_STORE_IC: return KeyedStoreStubCompiler::registers(); | |
1882 default: UNREACHABLE(); | |
1883 } | |
1884 return NULL; | |
1885 } | 1962 } |
1886 | 1963 |
1887 | 1964 |
| 1965 void KeyedLoadStubCompiler::JitEvent(Handle<Name> name, Handle<Code> code) { |
| 1966 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, *name, *code)); |
| 1967 } |
| 1968 |
| 1969 |
| 1970 void StoreStubCompiler::JitEvent(Handle<Name> name, Handle<Code> code) { |
| 1971 GDBJIT(AddCode(GDBJITInterface::STORE_IC, *name, *code)); |
| 1972 } |
| 1973 |
| 1974 |
| 1975 void KeyedStoreStubCompiler::JitEvent(Handle<Name> name, Handle<Code> code) { |
| 1976 GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, *name, *code)); |
| 1977 } |
| 1978 |
| 1979 |
1888 Handle<Code> BaseLoadStoreStubCompiler::GetICCode(Code::Kind kind, | 1980 Handle<Code> BaseLoadStoreStubCompiler::GetICCode(Code::Kind kind, |
1889 Code::StubType type, | 1981 Code::StubType type, |
1890 Handle<Name> name, | 1982 Handle<Name> name, |
1891 InlineCacheState state) { | 1983 InlineCacheState state) { |
1892 Code::Flags flags = Code::ComputeFlags( | 1984 Code::Flags flags = Code::ComputeFlags( |
1893 kind, state, extra_state(), type); | 1985 kind, state, extra_state(), type); |
1894 Handle<Code> code = GetCodeWithFlags(flags, name); | 1986 Handle<Code> code = GetCodeWithFlags(flags, name); |
1895 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name)); | 1987 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name)); |
1896 JitEvent(name, code); | 1988 JitEvent(name, code); |
1897 return code; | 1989 return code; |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2169 Handle<FunctionTemplateInfo>( | 2261 Handle<FunctionTemplateInfo>( |
2170 FunctionTemplateInfo::cast(signature->receiver())); | 2262 FunctionTemplateInfo::cast(signature->receiver())); |
2171 } | 2263 } |
2172 } | 2264 } |
2173 | 2265 |
2174 is_simple_api_call_ = true; | 2266 is_simple_api_call_ = true; |
2175 } | 2267 } |
2176 | 2268 |
2177 | 2269 |
2178 } } // namespace v8::internal | 2270 } } // namespace v8::internal |
OLD | NEW |