Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/stub-cache.cc

Issue 23647011: Unify computation of load stubs in stub cache. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Toon Verwaest. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/stub-cache.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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,
275 PropertyIndex field, 276 PropertyIndex field,
276 Representation representation) { 277 Representation representation) {
277 if (receiver.is_identical_to(holder)) { 278 if (receiver.is_identical_to(holder)) {
278 LoadFieldStub stub(field.is_inobject(holder), 279 if (kind == Code::LOAD_IC) {
279 field.translate(holder), 280 LoadFieldStub stub(field.is_inobject(holder),
280 representation); 281 field.translate(holder),
281 return stub.GetCode(isolate()); 282 representation);
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 }
282 } 290 }
283 291
284 Handle<JSObject> stub_holder = StubHolder(receiver, holder); 292 Handle<JSObject> stub_holder = StubHolder(receiver, holder);
285 Handle<Code> stub = FindLoadHandler( 293 Handle<Code> stub = FindLoadHandler(
286 name, receiver, stub_holder, Code::LOAD_IC, Code::FIELD); 294 name, receiver, stub_holder, kind, Code::FIELD);
287 if (!stub.is_null()) return stub; 295 if (!stub.is_null()) return stub;
288 296
289 LoadStubCompiler compiler(isolate_); 297 BaseLoadStubCompiler compiler(isolate_, kind);
290 Handle<Code> handler = 298 Handle<Code> handler =
291 compiler.CompileLoadField(receiver, holder, name, field, representation); 299 compiler.CompileLoadField(receiver, holder, name, field, representation);
292 JSObject::UpdateMapCodeCache(stub_holder, name, handler); 300 JSObject::UpdateMapCodeCache(stub_holder, name, handler);
293 return handler; 301 return handler;
294 } 302 }
295 303
296 304
297 Handle<Code> StubCache::ComputeLoadCallback( 305 Handle<Code> StubCache::ComputeLoadCallback(
298 Handle<Name> name, 306 Handle<Name> name,
299 Handle<JSObject> receiver, 307 Handle<JSObject> receiver,
300 Handle<JSObject> holder, 308 Handle<JSObject> holder,
309 Code::Kind kind,
301 Handle<ExecutableAccessorInfo> callback) { 310 Handle<ExecutableAccessorInfo> callback) {
302 ASSERT(v8::ToCData<Address>(callback->getter()) != 0); 311 ASSERT(v8::ToCData<Address>(callback->getter()) != 0);
303 Handle<JSObject> stub_holder = StubHolder(receiver, holder); 312 Handle<JSObject> stub_holder = StubHolder(receiver, holder);
304 Handle<Code> stub = FindLoadHandler( 313 Handle<Code> stub = FindLoadHandler(
305 name, receiver, stub_holder, Code::LOAD_IC, Code::CALLBACKS); 314 name, receiver, stub_holder, kind, Code::CALLBACKS);
306 if (!stub.is_null()) return stub; 315 if (!stub.is_null()) return stub;
307 316
308 LoadStubCompiler compiler(isolate_); 317 BaseLoadStubCompiler compiler(isolate_, kind);
309 Handle<Code> handler = 318 Handle<Code> handler =
310 compiler.CompileLoadCallback(receiver, holder, name, callback); 319 compiler.CompileLoadCallback(receiver, holder, name, callback);
311 JSObject::UpdateMapCodeCache(stub_holder, name, handler); 320 JSObject::UpdateMapCodeCache(stub_holder, name, handler);
312 return handler; 321 return handler;
313 } 322 }
314 323
315 324
316 Handle<Code> StubCache::ComputeLoadCallback( 325 Handle<Code> StubCache::ComputeLoadCallback(
317 Handle<Name> name, 326 Handle<Name> name,
318 Handle<JSObject> receiver, 327 Handle<JSObject> receiver,
319 Handle<JSObject> holder, 328 Handle<JSObject> holder,
329 Code::Kind kind,
320 const CallOptimization& call_optimization) { 330 const CallOptimization& call_optimization) {
321 Handle<JSObject> stub_holder = StubHolder(receiver, holder); 331 Handle<JSObject> stub_holder = StubHolder(receiver, holder);
322 Handle<Code> stub = FindLoadHandler( 332 Handle<Code> stub = FindLoadHandler(
323 name, receiver, stub_holder, Code::LOAD_IC, Code::CALLBACKS); 333 name, receiver, stub_holder, kind, Code::CALLBACKS);
324 if (!stub.is_null()) return stub; 334 if (!stub.is_null()) return stub;
325 335
326 LoadStubCompiler compiler(isolate_); 336 BaseLoadStubCompiler compiler(isolate_, kind);
327 Handle<Code> handler = 337 Handle<Code> handler =
328 compiler.CompileLoadCallback(receiver, holder, name, call_optimization); 338 compiler.CompileLoadCallback(receiver, holder, name, call_optimization);
329 JSObject::UpdateMapCodeCache(stub_holder, name, handler); 339 JSObject::UpdateMapCodeCache(stub_holder, name, handler);
330 return handler; 340 return handler;
331 } 341 }
332 342
333 343
334 Handle<Code> StubCache::ComputeLoadViaGetter(Handle<Name> name, 344 Handle<Code> StubCache::ComputeLoadViaGetter(Handle<Name> name,
335 Handle<JSObject> receiver, 345 Handle<JSObject> receiver,
336 Handle<JSObject> holder, 346 Handle<JSObject> holder,
337 Handle<JSFunction> getter) { 347 Handle<JSFunction> getter) {
338 Handle<JSObject> stub_holder = StubHolder(receiver, holder); 348 Handle<JSObject> stub_holder = StubHolder(receiver, holder);
339 Handle<Code> stub = FindLoadHandler( 349 Handle<Code> stub = FindLoadHandler(
340 name, receiver, stub_holder, Code::LOAD_IC, Code::CALLBACKS); 350 name, receiver, stub_holder, Code::LOAD_IC, Code::CALLBACKS);
341 if (!stub.is_null()) return stub; 351 if (!stub.is_null()) return stub;
342 352
343 LoadStubCompiler compiler(isolate_); 353 LoadStubCompiler compiler(isolate_);
344 Handle<Code> handler = 354 Handle<Code> handler =
345 compiler.CompileLoadViaGetter(receiver, holder, name, getter); 355 compiler.CompileLoadViaGetter(receiver, holder, name, getter);
346 JSObject::UpdateMapCodeCache(stub_holder, name, handler); 356 JSObject::UpdateMapCodeCache(stub_holder, name, handler);
347 return handler; 357 return handler;
348 } 358 }
349 359
350 360
351 Handle<Code> StubCache::ComputeLoadConstant(Handle<Name> name, 361 Handle<Code> StubCache::ComputeLoadConstant(Handle<Name> name,
352 Handle<JSObject> receiver, 362 Handle<JSObject> receiver,
353 Handle<JSObject> holder, 363 Handle<JSObject> holder,
364 Code::Kind kind,
354 Handle<Object> value) { 365 Handle<Object> value) {
355 Handle<JSObject> stub_holder = StubHolder(receiver, holder); 366 Handle<JSObject> stub_holder = StubHolder(receiver, holder);
356 Handle<Code> handler = FindLoadHandler( 367 Handle<Code> handler = FindLoadHandler(
357 name, receiver, stub_holder, Code::LOAD_IC, Code::CONSTANT); 368 name, receiver, stub_holder, kind, Code::CONSTANT);
358 if (!handler.is_null()) return handler; 369 if (!handler.is_null()) return handler;
359 370
360 LoadStubCompiler compiler(isolate_); 371 BaseLoadStubCompiler compiler(isolate_, kind);
361 handler = compiler.CompileLoadConstant(receiver, holder, name, value); 372 handler = compiler.CompileLoadConstant(receiver, holder, name, value);
362 JSObject::UpdateMapCodeCache(stub_holder, name, handler); 373 JSObject::UpdateMapCodeCache(stub_holder, name, handler);
363
364 return handler; 374 return handler;
365 } 375 }
366 376
367 377
368 Handle<Code> StubCache::ComputeLoadInterceptor(Handle<Name> name, 378 Handle<Code> StubCache::ComputeLoadInterceptor(Handle<Name> name,
369 Handle<JSObject> receiver, 379 Handle<JSObject> receiver,
370 Handle<JSObject> holder) { 380 Handle<JSObject> holder,
381 Code::Kind kind) {
371 Handle<JSObject> stub_holder = StubHolder(receiver, holder); 382 Handle<JSObject> stub_holder = StubHolder(receiver, holder);
372 Handle<Code> stub = FindLoadHandler( 383 Handle<Code> stub = FindLoadHandler(
373 name, receiver, stub_holder, Code::LOAD_IC, Code::INTERCEPTOR); 384 name, receiver, stub_holder, kind, Code::INTERCEPTOR);
374 if (!stub.is_null()) return stub; 385 if (!stub.is_null()) return stub;
375 386
376 LoadStubCompiler compiler(isolate_); 387 BaseLoadStubCompiler compiler(isolate_, kind);
377 Handle<Code> handler = 388 Handle<Code> handler =
378 compiler.CompileLoadInterceptor(receiver, holder, name); 389 compiler.CompileLoadInterceptor(receiver, holder, name);
379 JSObject::UpdateMapCodeCache(stub_holder, name, handler); 390 JSObject::UpdateMapCodeCache(stub_holder, name, handler);
380 return handler; 391 return handler;
381 } 392 }
382 393
383 394
384 Handle<Code> StubCache::ComputeLoadNormal(Handle<Name> name, 395 Handle<Code> StubCache::ComputeLoadNormal(Handle<Name> name,
385 Handle<JSObject> receiver) { 396 Handle<JSObject> receiver) {
386 return isolate_->builtins()->LoadIC_Normal(); 397 return isolate_->builtins()->LoadIC_Normal();
(...skipping 10 matching lines...) Expand all
397 if (!stub.is_null()) return stub; 408 if (!stub.is_null()) return stub;
398 409
399 LoadStubCompiler compiler(isolate_); 410 LoadStubCompiler compiler(isolate_);
400 Handle<Code> ic = 411 Handle<Code> ic =
401 compiler.CompileLoadGlobal(receiver, holder, cell, name, is_dont_delete); 412 compiler.CompileLoadGlobal(receiver, holder, cell, name, is_dont_delete);
402 JSObject::UpdateMapCodeCache(stub_holder, name, ic); 413 JSObject::UpdateMapCodeCache(stub_holder, name, ic);
403 return ic; 414 return ic;
404 } 415 }
405 416
406 417
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
502 Handle<Code> StubCache::ComputeStoreField(Handle<Name> name, 418 Handle<Code> StubCache::ComputeStoreField(Handle<Name> name,
503 Handle<JSObject> receiver, 419 Handle<JSObject> receiver,
504 LookupResult* lookup, 420 LookupResult* lookup,
505 StrictModeFlag strict_mode) { 421 StrictModeFlag strict_mode) {
506 Handle<Code> stub = FindStoreHandler( 422 Handle<Code> stub = FindStoreHandler(
507 name, receiver, Code::STORE_IC, Code::FIELD, strict_mode); 423 name, receiver, Code::STORE_IC, Code::FIELD, strict_mode);
508 if (!stub.is_null()) return stub; 424 if (!stub.is_null()) return stub;
509 425
510 StoreStubCompiler compiler(isolate_, strict_mode); 426 StoreStubCompiler compiler(isolate_, strict_mode);
511 Handle<Code> handler = compiler.CompileStoreField(receiver, lookup, name); 427 Handle<Code> handler = compiler.CompileStoreField(receiver, lookup, name);
(...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after
1932 1848
1933 #undef __ 1849 #undef __
1934 1850
1935 1851
1936 void StubCompiler::TailCallBuiltin(MacroAssembler* masm, Builtins::Name name) { 1852 void StubCompiler::TailCallBuiltin(MacroAssembler* masm, Builtins::Name name) {
1937 Handle<Code> code(masm->isolate()->builtins()->builtin(name)); 1853 Handle<Code> code(masm->isolate()->builtins()->builtin(name));
1938 GenerateTailCall(masm, code); 1854 GenerateTailCall(masm, code);
1939 } 1855 }
1940 1856
1941 1857
1942 void LoadStubCompiler::JitEvent(Handle<Name> name, Handle<Code> code) { 1858 Register* BaseLoadStoreStubCompiler::GetRegisters(Code::Kind kind) {
1943 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *name, *code)); 1859 switch (kind) {
1860 case Code::LOAD_IC: return LoadStubCompiler::registers();
1861 case Code::STORE_IC: return StoreStubCompiler::registers();
1862 case Code::KEYED_LOAD_IC: return KeyedLoadStubCompiler::registers();
1863 case Code::KEYED_STORE_IC: return KeyedStoreStubCompiler::registers();
1864 default: UNREACHABLE();
1865 }
1866 return NULL;
1944 } 1867 }
1945 1868
1946 1869
1947 void KeyedLoadStubCompiler::JitEvent(Handle<Name> name, Handle<Code> code) {
1948 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, *name, *code));
1949 }
1950
1951
1952 void StoreStubCompiler::JitEvent(Handle<Name> name, Handle<Code> code) {
1953 GDBJIT(AddCode(GDBJITInterface::STORE_IC, *name, *code));
1954 }
1955
1956
1957 void KeyedStoreStubCompiler::JitEvent(Handle<Name> name, Handle<Code> code) {
1958 GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, *name, *code));
1959 }
1960
1961
1962 Handle<Code> BaseLoadStoreStubCompiler::GetICCode(Code::Kind kind, 1870 Handle<Code> BaseLoadStoreStubCompiler::GetICCode(Code::Kind kind,
1963 Code::StubType type, 1871 Code::StubType type,
1964 Handle<Name> name, 1872 Handle<Name> name,
1965 InlineCacheState state) { 1873 InlineCacheState state) {
1966 Code::Flags flags = Code::ComputeFlags( 1874 Code::Flags flags = Code::ComputeFlags(
1967 kind, state, extra_state(), type); 1875 kind, state, extra_state(), type);
1968 Handle<Code> code = GetCodeWithFlags(flags, name); 1876 Handle<Code> code = GetCodeWithFlags(flags, name);
1969 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name)); 1877 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name));
1970 JitEvent(name, code); 1878 JitEvent(name, code);
1971 return code; 1879 return code;
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
2243 Handle<FunctionTemplateInfo>( 2151 Handle<FunctionTemplateInfo>(
2244 FunctionTemplateInfo::cast(signature->receiver())); 2152 FunctionTemplateInfo::cast(signature->receiver()));
2245 } 2153 }
2246 } 2154 }
2247 2155
2248 is_simple_api_call_ = true; 2156 is_simple_api_call_ = true;
2249 } 2157 }
2250 2158
2251 2159
2252 } } // namespace v8::internal 2160 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/stub-cache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698