OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 } | 512 } |
513 } | 513 } |
514 } | 514 } |
515 | 515 |
516 | 516 |
517 void ScriptCache::Add(Handle<Script> script) { | 517 void ScriptCache::Add(Handle<Script> script) { |
518 GlobalHandles* global_handles = isolate_->global_handles(); | 518 GlobalHandles* global_handles = isolate_->global_handles(); |
519 // Create an entry in the hash map for the script. | 519 // Create an entry in the hash map for the script. |
520 int id = script->id()->value(); | 520 int id = script->id()->value(); |
521 HashMap::Entry* entry = | 521 HashMap::Entry* entry = |
522 HashMap::Lookup(reinterpret_cast<void*>(id), Hash(id), true); | 522 HashMap::LookupOrInsert(reinterpret_cast<void*>(id), Hash(id)); |
523 if (entry->value != NULL) { | 523 if (entry->value != NULL) { |
524 #ifdef DEBUG | 524 #ifdef DEBUG |
525 // The code deserializer may introduce duplicate Script objects. | 525 // The code deserializer may introduce duplicate Script objects. |
526 // Assert that the Script objects with the same id have the same name. | 526 // Assert that the Script objects with the same id have the same name. |
527 Handle<Script> found(reinterpret_cast<Script**>(entry->value)); | 527 Handle<Script> found(reinterpret_cast<Script**>(entry->value)); |
528 DCHECK(script->id() == found->id()); | 528 DCHECK(script->id() == found->id()); |
529 DCHECK(!script->name()->IsString() || | 529 DCHECK(!script->name()->IsString() || |
530 String::cast(script->name())->Equals(String::cast(found->name()))); | 530 String::cast(script->name())->Equals(String::cast(found->name()))); |
531 #endif | 531 #endif |
532 return; | 532 return; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 const v8::WeakCallbackData<v8::Value, void>& data) { | 575 const v8::WeakCallbackData<v8::Value, void>& data) { |
576 // Retrieve the script identifier. | 576 // Retrieve the script identifier. |
577 Handle<Object> object = Utils::OpenHandle(*data.GetValue()); | 577 Handle<Object> object = Utils::OpenHandle(*data.GetValue()); |
578 int id = Handle<Script>::cast(object)->id()->value(); | 578 int id = Handle<Script>::cast(object)->id()->value(); |
579 void* key = reinterpret_cast<void*>(id); | 579 void* key = reinterpret_cast<void*>(id); |
580 uint32_t hash = Hash(id); | 580 uint32_t hash = Hash(id); |
581 | 581 |
582 // Remove the corresponding entry from the cache. | 582 // Remove the corresponding entry from the cache. |
583 ScriptCache* script_cache = | 583 ScriptCache* script_cache = |
584 reinterpret_cast<ScriptCache*>(data.GetParameter()); | 584 reinterpret_cast<ScriptCache*>(data.GetParameter()); |
585 HashMap::Entry* entry = script_cache->Lookup(key, hash, false); | 585 HashMap::Entry* entry = script_cache->Lookup(key, hash); |
| 586 DCHECK_NOT_NULL(entry); |
586 Object** location = reinterpret_cast<Object**>(entry->value); | 587 Object** location = reinterpret_cast<Object**>(entry->value); |
587 script_cache->Remove(key, hash); | 588 script_cache->Remove(key, hash); |
588 | 589 |
589 // Clear the weak handle. | 590 // Clear the weak handle. |
590 GlobalHandles::Destroy(location); | 591 GlobalHandles::Destroy(location); |
591 } | 592 } |
592 | 593 |
593 | 594 |
594 void Debug::HandlePhantomDebugInfo( | 595 void Debug::HandlePhantomDebugInfo( |
595 const v8::WeakCallbackInfo<DebugInfoListNode>& data) { | 596 const v8::WeakCallbackInfo<DebugInfoListNode>& data) { |
(...skipping 2806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3402 logger_->DebugEvent("Put", message.text()); | 3403 logger_->DebugEvent("Put", message.text()); |
3403 } | 3404 } |
3404 | 3405 |
3405 | 3406 |
3406 void LockingCommandMessageQueue::Clear() { | 3407 void LockingCommandMessageQueue::Clear() { |
3407 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 3408 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
3408 queue_.Clear(); | 3409 queue_.Clear(); |
3409 } | 3410 } |
3410 | 3411 |
3411 } } // namespace v8::internal | 3412 } } // namespace v8::internal |
OLD | NEW |