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

Side by Side Diff: src/external-reference-table.cc

Issue 1812853002: Moved the ExternalReferenceTable class to src/external-reference-table.cc/.h (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. Created 4 years, 9 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
« no previous file with comments | « src/external-reference-table.h ('k') | src/isolate.cc » ('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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/snapshot/serializer-common.h" 5 #include "src/external-reference-table.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/assembler.h" 8 #include "src/assembler.h"
9 #include "src/counters.h" 9 #include "src/counters.h"
10 #include "src/deoptimizer.h" 10 #include "src/deoptimizer.h"
11 #include "src/ic/stub-cache.h" 11 #include "src/ic/stub-cache.h"
12 #include "src/list-inl.h"
13 12
14 namespace v8 { 13 namespace v8 {
15 namespace internal { 14 namespace internal {
16 15
17 ExternalReferenceTable* ExternalReferenceTable::instance(Isolate* isolate) { 16 ExternalReferenceTable* ExternalReferenceTable::instance(Isolate* isolate) {
18 ExternalReferenceTable* external_reference_table = 17 ExternalReferenceTable* external_reference_table =
19 isolate->external_reference_table(); 18 isolate->external_reference_table();
20 if (external_reference_table == NULL) { 19 if (external_reference_table == NULL) {
21 external_reference_table = new ExternalReferenceTable(isolate); 20 external_reference_table = new ExternalReferenceTable(isolate);
22 isolate->set_external_reference_table(external_reference_table); 21 isolate->set_external_reference_table(external_reference_table);
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 // deopt table code, which isn't possible at deserialization time. 342 // deopt table code, which isn't possible at deserialization time.
344 HandleScope scope(isolate); 343 HandleScope scope(isolate);
345 for (int entry = 0; entry < kDeoptTableSerializeEntryCount; ++entry) { 344 for (int entry = 0; entry < kDeoptTableSerializeEntryCount; ++entry) {
346 Address address = Deoptimizer::GetDeoptimizationEntry( 345 Address address = Deoptimizer::GetDeoptimizationEntry(
347 isolate, entry, Deoptimizer::LAZY, 346 isolate, entry, Deoptimizer::LAZY,
348 Deoptimizer::CALCULATE_ENTRY_ADDRESS); 347 Deoptimizer::CALCULATE_ENTRY_ADDRESS);
349 Add(address, "lazy_deopt"); 348 Add(address, "lazy_deopt");
350 } 349 }
351 } 350 }
352 351
353 ExternalReferenceEncoder::ExternalReferenceEncoder(Isolate* isolate) {
354 map_ = isolate->external_reference_map();
355 if (map_ != NULL) return;
356 map_ = new HashMap(HashMap::PointersMatch);
357 ExternalReferenceTable* table = ExternalReferenceTable::instance(isolate);
358 for (int i = 0; i < table->size(); ++i) {
359 Address addr = table->address(i);
360 if (addr == ExternalReferenceTable::NotAvailable()) continue;
361 // We expect no duplicate external references entries in the table.
362 DCHECK_NULL(map_->Lookup(addr, Hash(addr)));
363 map_->LookupOrInsert(addr, Hash(addr))->value = reinterpret_cast<void*>(i);
364 }
365 isolate->set_external_reference_map(map_);
366 }
367
368 uint32_t ExternalReferenceEncoder::Encode(Address address) const {
369 DCHECK_NOT_NULL(address);
370 HashMap::Entry* entry =
371 const_cast<HashMap*>(map_)->Lookup(address, Hash(address));
372 DCHECK_NOT_NULL(entry);
373 return static_cast<uint32_t>(reinterpret_cast<intptr_t>(entry->value));
374 }
375
376 const char* ExternalReferenceEncoder::NameOfAddress(Isolate* isolate,
377 Address address) const {
378 HashMap::Entry* entry =
379 const_cast<HashMap*>(map_)->Lookup(address, Hash(address));
380 if (entry == NULL) return "<unknown>";
381 uint32_t i = static_cast<uint32_t>(reinterpret_cast<intptr_t>(entry->value));
382 return ExternalReferenceTable::instance(isolate)->name(i);
383 }
384
385 void SerializedData::AllocateData(int size) {
386 DCHECK(!owns_data_);
387 data_ = NewArray<byte>(size);
388 size_ = size;
389 owns_data_ = true;
390 DCHECK(IsAligned(reinterpret_cast<intptr_t>(data_), kPointerAlignment));
391 }
392
393 // The partial snapshot cache is terminated by undefined. We visit the
394 // partial snapshot...
395 // - during deserialization to populate it.
396 // - during normal GC to keep its content alive.
397 // - not during serialization. The partial serializer adds to it explicitly.
398 void SerializerDeserializer::Iterate(Isolate* isolate, ObjectVisitor* visitor) {
399 List<Object*>* cache = isolate->partial_snapshot_cache();
400 for (int i = 0;; ++i) {
401 // Extend the array ready to get a value when deserializing.
402 if (cache->length() <= i) cache->Add(Smi::FromInt(0));
403 // During deserialization, the visitor populates the partial snapshot cache
404 // and eventually terminates the cache with undefined.
405 visitor->VisitPointer(&cache->at(i));
406 if (cache->at(i)->IsUndefined()) break;
407 }
408 }
409
410 bool SerializerDeserializer::CanBeDeferred(HeapObject* o) {
411 return !o->IsString() && !o->IsScript();
412 }
413
414 } // namespace internal 352 } // namespace internal
415 } // namespace v8 353 } // namespace v8
OLDNEW
« no previous file with comments | « src/external-reference-table.h ('k') | src/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698