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/snapshot/serialize.h" | 5 #include "src/snapshot/serialize.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 369 matching lines...) Loading... |
380 public: | 380 public: |
381 explicit CodeAddressMap(Isolate* isolate) | 381 explicit CodeAddressMap(Isolate* isolate) |
382 : isolate_(isolate) { | 382 : isolate_(isolate) { |
383 isolate->logger()->addCodeEventListener(this); | 383 isolate->logger()->addCodeEventListener(this); |
384 } | 384 } |
385 | 385 |
386 ~CodeAddressMap() override { | 386 ~CodeAddressMap() override { |
387 isolate_->logger()->removeCodeEventListener(this); | 387 isolate_->logger()->removeCodeEventListener(this); |
388 } | 388 } |
389 | 389 |
390 void CodeMoveEvent(Address from, Address to) override { | 390 void CodeMoveEvent(AbstractCode* from, Address to) override { |
391 address_to_name_map_.Move(from, to); | 391 address_to_name_map_.Move(from->address(), to); |
392 } | 392 } |
393 | 393 |
394 void CodeDisableOptEvent(Code* code, SharedFunctionInfo* shared) override {} | 394 void CodeDisableOptEvent(AbstractCode* code, |
395 | 395 SharedFunctionInfo* shared) override {} |
396 void CodeDeleteEvent(Address from) override { | |
397 address_to_name_map_.Remove(from); | |
398 } | |
399 | 396 |
400 const char* Lookup(Address address) { | 397 const char* Lookup(Address address) { |
401 return address_to_name_map_.Lookup(address); | 398 return address_to_name_map_.Lookup(address); |
402 } | 399 } |
403 | 400 |
404 private: | 401 private: |
405 class NameMap { | 402 class NameMap { |
406 public: | 403 public: |
407 NameMap() : impl_(HashMap::PointersMatch) {} | 404 NameMap() : impl_(HashMap::PointersMatch) {} |
408 | 405 |
(...skipping 57 matching lines...) Loading... |
466 | 463 |
467 void RemoveEntry(HashMap::Entry* entry) { | 464 void RemoveEntry(HashMap::Entry* entry) { |
468 impl_.Remove(entry->key, entry->hash); | 465 impl_.Remove(entry->key, entry->hash); |
469 } | 466 } |
470 | 467 |
471 HashMap impl_; | 468 HashMap impl_; |
472 | 469 |
473 DISALLOW_COPY_AND_ASSIGN(NameMap); | 470 DISALLOW_COPY_AND_ASSIGN(NameMap); |
474 }; | 471 }; |
475 | 472 |
476 void LogRecordedBuffer(Code* code, SharedFunctionInfo*, const char* name, | 473 void LogRecordedBuffer(AbstractCode* code, SharedFunctionInfo*, |
477 int length) override { | 474 const char* name, int length) override { |
478 address_to_name_map_.Insert(code->address(), name, length); | 475 address_to_name_map_.Insert(code->address(), name, length); |
479 } | 476 } |
480 | 477 |
481 NameMap address_to_name_map_; | 478 NameMap address_to_name_map_; |
482 Isolate* isolate_; | 479 Isolate* isolate_; |
483 }; | 480 }; |
484 | 481 |
485 | 482 |
486 void Deserializer::DecodeReservation( | 483 void Deserializer::DecodeReservation( |
487 Vector<const SerializedData::Reservation> res) { | 484 Vector<const SerializedData::Reservation> res) { |
(...skipping 2140 matching lines...) Loading... |
2628 } | 2625 } |
2629 result->set_deserialized(true); | 2626 result->set_deserialized(true); |
2630 | 2627 |
2631 if (isolate->logger()->is_logging_code_events() || | 2628 if (isolate->logger()->is_logging_code_events() || |
2632 isolate->cpu_profiler()->is_profiling()) { | 2629 isolate->cpu_profiler()->is_profiling()) { |
2633 String* name = isolate->heap()->empty_string(); | 2630 String* name = isolate->heap()->empty_string(); |
2634 if (result->script()->IsScript()) { | 2631 if (result->script()->IsScript()) { |
2635 Script* script = Script::cast(result->script()); | 2632 Script* script = Script::cast(result->script()); |
2636 if (script->name()->IsString()) name = String::cast(script->name()); | 2633 if (script->name()->IsString()) name = String::cast(script->name()); |
2637 } | 2634 } |
2638 isolate->logger()->CodeCreateEvent(Logger::SCRIPT_TAG, result->code(), | 2635 isolate->logger()->CodeCreateEvent(Logger::SCRIPT_TAG, |
| 2636 AbstractCode::cast(result->code()), |
2639 *result, NULL, name); | 2637 *result, NULL, name); |
2640 } | 2638 } |
2641 return scope.CloseAndEscape(result); | 2639 return scope.CloseAndEscape(result); |
2642 } | 2640 } |
2643 | 2641 |
2644 | 2642 |
2645 void SerializedData::AllocateData(int size) { | 2643 void SerializedData::AllocateData(int size) { |
2646 DCHECK(!owns_data_); | 2644 DCHECK(!owns_data_); |
2647 data_ = NewArray<byte>(size); | 2645 data_ = NewArray<byte>(size); |
2648 size_ = size; | 2646 size_ = size; |
(...skipping 219 matching lines...) Loading... |
2868 SerializedCodeData* scd = new SerializedCodeData(cached_data); | 2866 SerializedCodeData* scd = new SerializedCodeData(cached_data); |
2869 SanityCheckResult r = scd->SanityCheck(isolate, source); | 2867 SanityCheckResult r = scd->SanityCheck(isolate, source); |
2870 if (r == CHECK_SUCCESS) return scd; | 2868 if (r == CHECK_SUCCESS) return scd; |
2871 cached_data->Reject(); | 2869 cached_data->Reject(); |
2872 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); | 2870 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); |
2873 delete scd; | 2871 delete scd; |
2874 return NULL; | 2872 return NULL; |
2875 } | 2873 } |
2876 } // namespace internal | 2874 } // namespace internal |
2877 } // namespace v8 | 2875 } // namespace v8 |
OLD | NEW |