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

Side by Side Diff: src/ic.cc

Issue 10263008: Implement clearing of CompareICs. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed moar comments by Vyacheslav Egorov. Created 8 years, 7 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/ic.h ('k') | src/objects.h » ('j') | 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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 345
346 switch (target->kind()) { 346 switch (target->kind()) {
347 case Code::LOAD_IC: return LoadIC::Clear(address, target); 347 case Code::LOAD_IC: return LoadIC::Clear(address, target);
348 case Code::KEYED_LOAD_IC: 348 case Code::KEYED_LOAD_IC:
349 return KeyedLoadIC::Clear(address, target); 349 return KeyedLoadIC::Clear(address, target);
350 case Code::STORE_IC: return StoreIC::Clear(address, target); 350 case Code::STORE_IC: return StoreIC::Clear(address, target);
351 case Code::KEYED_STORE_IC: 351 case Code::KEYED_STORE_IC:
352 return KeyedStoreIC::Clear(address, target); 352 return KeyedStoreIC::Clear(address, target);
353 case Code::CALL_IC: return CallIC::Clear(address, target); 353 case Code::CALL_IC: return CallIC::Clear(address, target);
354 case Code::KEYED_CALL_IC: return KeyedCallIC::Clear(address, target); 354 case Code::KEYED_CALL_IC: return KeyedCallIC::Clear(address, target);
355 case Code::COMPARE_IC: return CompareIC::Clear(address, target);
355 case Code::UNARY_OP_IC: 356 case Code::UNARY_OP_IC:
356 case Code::BINARY_OP_IC: 357 case Code::BINARY_OP_IC:
357 case Code::COMPARE_IC:
358 case Code::TO_BOOLEAN_IC: 358 case Code::TO_BOOLEAN_IC:
359 // Clearing these is tricky and does not 359 // Clearing these is tricky and does not
360 // make any performance difference. 360 // make any performance difference.
361 return; 361 return;
362 default: UNREACHABLE(); 362 default: UNREACHABLE();
363 } 363 }
364 } 364 }
365 365
366 366
367 void CallICBase::Clear(Address address, Code* target) { 367 void CallICBase::Clear(Address address, Code* target) {
368 if (target->ic_state() == UNINITIALIZED) return;
368 bool contextual = CallICBase::Contextual::decode(target->extra_ic_state()); 369 bool contextual = CallICBase::Contextual::decode(target->extra_ic_state());
369 State state = target->ic_state();
370 if (state == UNINITIALIZED) return;
371 Code* code = 370 Code* code =
372 Isolate::Current()->stub_cache()->FindCallInitialize( 371 Isolate::Current()->stub_cache()->FindCallInitialize(
373 target->arguments_count(), 372 target->arguments_count(),
374 contextual ? RelocInfo::CODE_TARGET_CONTEXT : RelocInfo::CODE_TARGET, 373 contextual ? RelocInfo::CODE_TARGET_CONTEXT : RelocInfo::CODE_TARGET,
375 target->kind()); 374 target->kind());
376 SetTargetAtAddress(address, code); 375 SetTargetAtAddress(address, code);
377 } 376 }
378 377
379 378
380 void KeyedLoadIC::Clear(Address address, Code* target) { 379 void KeyedLoadIC::Clear(Address address, Code* target) {
(...skipping 22 matching lines...) Expand all
403 402
404 void KeyedStoreIC::Clear(Address address, Code* target) { 403 void KeyedStoreIC::Clear(Address address, Code* target) {
405 if (target->ic_state() == UNINITIALIZED) return; 404 if (target->ic_state() == UNINITIALIZED) return;
406 SetTargetAtAddress(address, 405 SetTargetAtAddress(address,
407 (Code::GetStrictMode(target->extra_ic_state()) == kStrictMode) 406 (Code::GetStrictMode(target->extra_ic_state()) == kStrictMode)
408 ? initialize_stub_strict() 407 ? initialize_stub_strict()
409 : initialize_stub()); 408 : initialize_stub());
410 } 409 }
411 410
412 411
412 void CompareIC::Clear(Address address, Code* target) {
413 // Only clear ICCompareStubs, we currently cannot clear generic CompareStubs.
414 if (target->major_key() != CodeStub::CompareIC) return;
415 // Only clear CompareICs that can retain objects.
416 if (target->compare_state() != KNOWN_OBJECTS) return;
417 Token::Value op = CompareIC::ComputeOperation(target);
418 SetTargetAtAddress(address, GetRawUninitialized(op));
419 PatchInlinedSmiCode(address, DISABLE_INLINED_SMI_CHECK);
420 }
421
422
413 static bool HasInterceptorGetter(JSObject* object) { 423 static bool HasInterceptorGetter(JSObject* object) {
414 return !object->GetNamedInterceptor()->getter()->IsUndefined(); 424 return !object->GetNamedInterceptor()->getter()->IsUndefined();
415 } 425 }
416 426
417 427
418 static void LookupForRead(Handle<Object> object, 428 static void LookupForRead(Handle<Object> object,
419 Handle<String> name, 429 Handle<String> name,
420 LookupResult* lookup) { 430 LookupResult* lookup) {
421 // Skip all the objects with named interceptors, but 431 // Skip all the objects with named interceptors, but
422 // without actual getter. 432 // without actual getter.
(...skipping 1966 matching lines...) Expand 10 before | Expand all | Expand 10 after
2389 BinaryOpIC::GetName(previous_type), 2399 BinaryOpIC::GetName(previous_type),
2390 BinaryOpIC::GetName(type), 2400 BinaryOpIC::GetName(type),
2391 BinaryOpIC::GetName(result_type), 2401 BinaryOpIC::GetName(result_type),
2392 Token::Name(op)); 2402 Token::Name(op));
2393 } 2403 }
2394 BinaryOpIC ic(isolate); 2404 BinaryOpIC ic(isolate);
2395 ic.patch(*code); 2405 ic.patch(*code);
2396 2406
2397 // Activate inlined smi code. 2407 // Activate inlined smi code.
2398 if (previous_type == BinaryOpIC::UNINITIALIZED) { 2408 if (previous_type == BinaryOpIC::UNINITIALIZED) {
2399 PatchInlinedSmiCode(ic.address()); 2409 PatchInlinedSmiCode(ic.address(), ENABLE_INLINED_SMI_CHECK);
2400 } 2410 }
2401 } 2411 }
2402 2412
2403 Handle<JSBuiltinsObject> builtins = Handle<JSBuiltinsObject>( 2413 Handle<JSBuiltinsObject> builtins = Handle<JSBuiltinsObject>(
2404 isolate->thread_local_top()->context_->builtins(), isolate); 2414 isolate->thread_local_top()->context_->builtins(), isolate);
2405 Object* builtin = NULL; // Initialization calms down the compiler. 2415 Object* builtin = NULL; // Initialization calms down the compiler.
2406 switch (op) { 2416 switch (op) {
2407 case Token::ADD: 2417 case Token::ADD:
2408 builtin = builtins->javascript_builtin(Builtins::ADD); 2418 builtin = builtins->javascript_builtin(Builtins::ADD);
2409 break; 2419 break;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2450 ARRAY_SIZE(builtin_args), 2460 ARRAY_SIZE(builtin_args),
2451 builtin_args, 2461 builtin_args,
2452 &caught_exception); 2462 &caught_exception);
2453 if (caught_exception) { 2463 if (caught_exception) {
2454 return Failure::Exception(); 2464 return Failure::Exception();
2455 } 2465 }
2456 return *result; 2466 return *result;
2457 } 2467 }
2458 2468
2459 2469
2470 Code* CompareIC::GetRawUninitialized(Token::Value op) {
2471 ICCompareStub stub(op, UNINITIALIZED);
2472 Code* code = NULL;
2473 CHECK(stub.FindCodeInCache(&code));
2474 return code;
2475 }
2476
2477
2460 Handle<Code> CompareIC::GetUninitialized(Token::Value op) { 2478 Handle<Code> CompareIC::GetUninitialized(Token::Value op) {
2461 ICCompareStub stub(op, UNINITIALIZED); 2479 ICCompareStub stub(op, UNINITIALIZED);
2462 return stub.GetCode(); 2480 return stub.GetCode();
2463 } 2481 }
2464 2482
2465 2483
2466 CompareIC::State CompareIC::ComputeState(Code* target) { 2484 CompareIC::State CompareIC::ComputeState(Code* target) {
2467 int key = target->major_key(); 2485 int key = target->major_key();
2468 if (key == CodeStub::Compare) return GENERIC; 2486 if (key == CodeStub::Compare) return GENERIC;
2469 ASSERT(key == CodeStub::CompareIC); 2487 ASSERT(key == CodeStub::CompareIC);
2470 return static_cast<State>(target->compare_state()); 2488 return static_cast<State>(target->compare_state());
2471 } 2489 }
2472 2490
2473 2491
2492 Token::Value CompareIC::ComputeOperation(Code* target) {
2493 ASSERT(target->major_key() == CodeStub::CompareIC);
2494 return static_cast<Token::Value>(target->compare_operation());
2495 }
2496
2497
2474 const char* CompareIC::GetStateName(State state) { 2498 const char* CompareIC::GetStateName(State state) {
2475 switch (state) { 2499 switch (state) {
2476 case UNINITIALIZED: return "UNINITIALIZED"; 2500 case UNINITIALIZED: return "UNINITIALIZED";
2477 case SMIS: return "SMIS"; 2501 case SMIS: return "SMIS";
2478 case HEAP_NUMBERS: return "HEAP_NUMBERS"; 2502 case HEAP_NUMBERS: return "HEAP_NUMBERS";
2479 case OBJECTS: return "OBJECTS"; 2503 case OBJECTS: return "OBJECTS";
2480 case KNOWN_OBJECTS: return "OBJECTS"; 2504 case KNOWN_OBJECTS: return "OBJECTS";
2481 case SYMBOLS: return "SYMBOLS"; 2505 case SYMBOLS: return "SYMBOLS";
2482 case STRINGS: return "STRINGS"; 2506 case STRINGS: return "STRINGS";
2483 case GENERIC: return "GENERIC"; 2507 case GENERIC: return "GENERIC";
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
2582 #undef ADDR 2606 #undef ADDR
2583 }; 2607 };
2584 2608
2585 2609
2586 Address IC::AddressFromUtilityId(IC::UtilityId id) { 2610 Address IC::AddressFromUtilityId(IC::UtilityId id) {
2587 return IC_utilities[id]; 2611 return IC_utilities[id];
2588 } 2612 }
2589 2613
2590 2614
2591 } } // namespace v8::internal 2615 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ic.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698