OLD | NEW |
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 28 matching lines...) Expand all Loading... |
39 #include "conversions-inl.h" | 39 #include "conversions-inl.h" |
40 #include "counters.h" | 40 #include "counters.h" |
41 #include "cpu-profiler.h" | 41 #include "cpu-profiler.h" |
42 #include "debug.h" | 42 #include "debug.h" |
43 #include "deoptimizer.h" | 43 #include "deoptimizer.h" |
44 #include "execution.h" | 44 #include "execution.h" |
45 #include "global-handles.h" | 45 #include "global-handles.h" |
46 #include "heap-profiler.h" | 46 #include "heap-profiler.h" |
47 #include "heap-snapshot-generator-inl.h" | 47 #include "heap-snapshot-generator-inl.h" |
48 #include "icu_util.h" | 48 #include "icu_util.h" |
49 #include "json-parser.h" | |
50 #include "messages.h" | 49 #include "messages.h" |
51 #ifdef COMPRESS_STARTUP_DATA_BZ2 | 50 #ifdef COMPRESS_STARTUP_DATA_BZ2 |
52 #include "natives.h" | 51 #include "natives.h" |
53 #endif | 52 #endif |
54 #include "parser.h" | 53 #include "parser.h" |
55 #include "platform.h" | 54 #include "platform.h" |
56 #include "profile-generator-inl.h" | 55 #include "profile-generator-inl.h" |
57 #include "property-details.h" | 56 #include "property-details.h" |
58 #include "property.h" | 57 #include "property.h" |
59 #include "runtime.h" | 58 #include "runtime.h" |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 return StartupData::kUncompressed; | 391 return StartupData::kUncompressed; |
393 #endif | 392 #endif |
394 } | 393 } |
395 | 394 |
396 | 395 |
397 enum CompressedStartupDataItems { | 396 enum CompressedStartupDataItems { |
398 kSnapshot = 0, | 397 kSnapshot = 0, |
399 kSnapshotContext, | 398 kSnapshotContext, |
400 kLibraries, | 399 kLibraries, |
401 kExperimentalLibraries, | 400 kExperimentalLibraries, |
402 #if defined(V8_I18N_SUPPORT) | 401 #if defined(ENABLE_I18N_SUPPORT) |
403 kI18NExtension, | 402 kI18NExtension, |
404 #endif | 403 #endif |
405 kCompressedStartupDataCount | 404 kCompressedStartupDataCount |
406 }; | 405 }; |
407 | 406 |
408 | 407 |
409 int V8::GetCompressedStartupDataCount() { | 408 int V8::GetCompressedStartupDataCount() { |
410 #ifdef COMPRESS_STARTUP_DATA_BZ2 | 409 #ifdef COMPRESS_STARTUP_DATA_BZ2 |
411 return kCompressedStartupDataCount; | 410 return kCompressedStartupDataCount; |
412 #else | 411 #else |
(...skipping 23 matching lines...) Expand all Loading... |
436 | 435 |
437 i::Vector<const i::byte> exp_libraries_source = | 436 i::Vector<const i::byte> exp_libraries_source = |
438 i::ExperimentalNatives::GetScriptsSource(); | 437 i::ExperimentalNatives::GetScriptsSource(); |
439 compressed_data[kExperimentalLibraries].data = | 438 compressed_data[kExperimentalLibraries].data = |
440 reinterpret_cast<const char*>(exp_libraries_source.start()); | 439 reinterpret_cast<const char*>(exp_libraries_source.start()); |
441 compressed_data[kExperimentalLibraries].compressed_size = | 440 compressed_data[kExperimentalLibraries].compressed_size = |
442 exp_libraries_source.length(); | 441 exp_libraries_source.length(); |
443 compressed_data[kExperimentalLibraries].raw_size = | 442 compressed_data[kExperimentalLibraries].raw_size = |
444 i::ExperimentalNatives::GetRawScriptsSize(); | 443 i::ExperimentalNatives::GetRawScriptsSize(); |
445 | 444 |
446 #if defined(V8_I18N_SUPPORT) | 445 #if defined(ENABLE_I18N_SUPPORT) |
447 i::Vector<const ii:byte> i18n_extension_source = | 446 i::Vector<const ii:byte> i18n_extension_source = |
448 i::I18NNatives::GetScriptsSource(); | 447 i::I18NNatives::GetScriptsSource(); |
449 compressed_data[kI18NExtension].data = | 448 compressed_data[kI18NExtension].data = |
450 reinterpret_cast<const char*>(i18n_extension_source.start()); | 449 reinterpret_cast<const char*>(i18n_extension_source.start()); |
451 compressed_data[kI18NExtension].compressed_size = | 450 compressed_data[kI18NExtension].compressed_size = |
452 i18n_extension_source.length(); | 451 i18n_extension_source.length(); |
453 compressed_data[kI18NExtension].raw_size = | 452 compressed_data[kI18NExtension].raw_size = |
454 i::I18NNatives::GetRawScriptsSize(); | 453 i::I18NNatives::GetRawScriptsSize(); |
455 #endif | 454 #endif |
456 #endif | 455 #endif |
(...skipping 19 matching lines...) Expand all Loading... |
476 decompressed_data[kLibraries].raw_size); | 475 decompressed_data[kLibraries].raw_size); |
477 i::Natives::SetRawScriptsSource(libraries_source); | 476 i::Natives::SetRawScriptsSource(libraries_source); |
478 | 477 |
479 ASSERT_EQ(i::ExperimentalNatives::GetRawScriptsSize(), | 478 ASSERT_EQ(i::ExperimentalNatives::GetRawScriptsSize(), |
480 decompressed_data[kExperimentalLibraries].raw_size); | 479 decompressed_data[kExperimentalLibraries].raw_size); |
481 i::Vector<const char> exp_libraries_source( | 480 i::Vector<const char> exp_libraries_source( |
482 decompressed_data[kExperimentalLibraries].data, | 481 decompressed_data[kExperimentalLibraries].data, |
483 decompressed_data[kExperimentalLibraries].raw_size); | 482 decompressed_data[kExperimentalLibraries].raw_size); |
484 i::ExperimentalNatives::SetRawScriptsSource(exp_libraries_source); | 483 i::ExperimentalNatives::SetRawScriptsSource(exp_libraries_source); |
485 | 484 |
486 #if defined(V8_I18N_SUPPORT) | 485 #if defined(ENABLE_I18N_SUPPORT) |
487 ASSERT_EQ(i::I18NNatives::GetRawScriptsSize(), | 486 ASSERT_EQ(i::I18NNatives::GetRawScriptsSize(), |
488 decompressed_data[kI18NExtension].raw_size); | 487 decompressed_data[kI18NExtension].raw_size); |
489 i::Vector<const char> i18n_extension_source( | 488 i::Vector<const char> i18n_extension_source( |
490 decompressed_data[kI18NExtension].data, | 489 decompressed_data[kI18NExtension].data, |
491 decompressed_data[kI18NExtension].raw_size); | 490 decompressed_data[kI18NExtension].raw_size); |
492 i::I18NNatives::SetRawScriptsSource(i18n_extension_source); | 491 i::I18NNatives::SetRawScriptsSource(i18n_extension_source); |
493 #endif | 492 #endif |
494 #endif | 493 #endif |
495 } | 494 } |
496 | 495 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 void V8::ClearWeak(i::Object** obj) { | 668 void V8::ClearWeak(i::Object** obj) { |
670 i::GlobalHandles::ClearWeakness(obj); | 669 i::GlobalHandles::ClearWeakness(obj); |
671 } | 670 } |
672 | 671 |
673 | 672 |
674 void V8::DisposeGlobal(i::Object** obj) { | 673 void V8::DisposeGlobal(i::Object** obj) { |
675 i::GlobalHandles::Destroy(obj); | 674 i::GlobalHandles::Destroy(obj); |
676 } | 675 } |
677 | 676 |
678 | 677 |
679 int V8::Eternalize(i::Isolate* isolate, i::Object** handle) { | |
680 return isolate->eternal_handles()->Create(isolate, *handle); | |
681 } | |
682 | |
683 | |
684 i::Object** V8::GetEternal(i::Isolate* isolate, int index) { | |
685 return isolate->eternal_handles()->Get(index).location(); | |
686 } | |
687 | |
688 | |
689 // --- H a n d l e s --- | 678 // --- H a n d l e s --- |
690 | 679 |
691 | 680 |
692 HandleScope::HandleScope() { | 681 HandleScope::HandleScope() { |
693 Initialize(reinterpret_cast<Isolate*>(i::Isolate::Current())); | 682 Initialize(reinterpret_cast<Isolate*>(i::Isolate::Current())); |
694 } | 683 } |
695 | 684 |
696 | 685 |
697 HandleScope::HandleScope(Isolate* isolate) { | 686 HandleScope::HandleScope(Isolate* isolate) { |
698 Initialize(isolate); | 687 Initialize(isolate); |
(...skipping 1912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2611 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2600 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2612 if (IsDeadCheck(isolate, "v8::StackFrame::IsConstructor()")) return false; | 2601 if (IsDeadCheck(isolate, "v8::StackFrame::IsConstructor()")) return false; |
2613 ENTER_V8(isolate); | 2602 ENTER_V8(isolate); |
2614 i::HandleScope scope(isolate); | 2603 i::HandleScope scope(isolate); |
2615 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2604 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
2616 i::Handle<i::Object> is_constructor = GetProperty(self, "isConstructor"); | 2605 i::Handle<i::Object> is_constructor = GetProperty(self, "isConstructor"); |
2617 return is_constructor->IsTrue(); | 2606 return is_constructor->IsTrue(); |
2618 } | 2607 } |
2619 | 2608 |
2620 | 2609 |
2621 // --- J S O N --- | |
2622 | |
2623 Local<Object> JSON::Parse(Local<String> json_string) { | |
2624 i::Isolate* isolate = i::Isolate::Current(); | |
2625 EnsureInitializedForIsolate(isolate, "v8::JSON::Parse"); | |
2626 ENTER_V8(isolate); | |
2627 i::HandleScope scope(isolate); | |
2628 i::Handle<i::String> source = i::Handle<i::String>( | |
2629 FlattenGetString(Utils::OpenHandle(*json_string))); | |
2630 EXCEPTION_PREAMBLE(isolate); | |
2631 i::Handle<i::Object> result; | |
2632 if (source->IsSeqOneByteString()) { | |
2633 result = i::JsonParser<true>::Parse(source); | |
2634 } else { | |
2635 result = i::JsonParser<false>::Parse(source); | |
2636 } | |
2637 has_pending_exception = result.is_null(); | |
2638 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>()); | |
2639 return Utils::ToLocal( | |
2640 i::Handle<i::JSObject>::cast(scope.CloseAndEscape(result))); | |
2641 } | |
2642 | |
2643 | |
2644 // --- D a t a --- | 2610 // --- D a t a --- |
2645 | 2611 |
2646 bool Value::FullIsUndefined() const { | 2612 bool Value::FullIsUndefined() const { |
2647 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsUndefined()")) { | 2613 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsUndefined()")) { |
2648 return false; | 2614 return false; |
2649 } | 2615 } |
2650 bool result = Utils::OpenHandle(this)->IsUndefined(); | 2616 bool result = Utils::OpenHandle(this)->IsUndefined(); |
2651 ASSERT_EQ(result, QuickIsUndefined()); | 2617 ASSERT_EQ(result, QuickIsUndefined()); |
2652 return result; | 2618 return result; |
2653 } | 2619 } |
(...skipping 4940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7594 return reinterpret_cast<const CpuProfileNode*>(profile->top_down()->root()); | 7560 return reinterpret_cast<const CpuProfileNode*>(profile->top_down()->root()); |
7595 } | 7561 } |
7596 | 7562 |
7597 | 7563 |
7598 const CpuProfileNode* CpuProfile::GetSample(int index) const { | 7564 const CpuProfileNode* CpuProfile::GetSample(int index) const { |
7599 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); | 7565 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); |
7600 return reinterpret_cast<const CpuProfileNode*>(profile->sample(index)); | 7566 return reinterpret_cast<const CpuProfileNode*>(profile->sample(index)); |
7601 } | 7567 } |
7602 | 7568 |
7603 | 7569 |
7604 int64_t CpuProfile::GetStartTime() const { | |
7605 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); | |
7606 return profile->start_time_us(); | |
7607 } | |
7608 | |
7609 | |
7610 int64_t CpuProfile::GetEndTime() const { | |
7611 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); | |
7612 return profile->end_time_us(); | |
7613 } | |
7614 | |
7615 | |
7616 int CpuProfile::GetSamplesCount() const { | 7570 int CpuProfile::GetSamplesCount() const { |
7617 return reinterpret_cast<const i::CpuProfile*>(this)->samples_count(); | 7571 return reinterpret_cast<const i::CpuProfile*>(this)->samples_count(); |
7618 } | 7572 } |
7619 | 7573 |
7620 | 7574 |
7621 int CpuProfiler::GetProfileCount() { | 7575 int CpuProfiler::GetProfileCount() { |
7622 return reinterpret_cast<i::CpuProfiler*>(this)->GetProfilesCount(); | 7576 return reinterpret_cast<i::CpuProfiler*>(this)->GetProfilesCount(); |
7623 } | 7577 } |
7624 | 7578 |
7625 | 7579 |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8170 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 8124 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
8171 Address callback_address = | 8125 Address callback_address = |
8172 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8126 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8173 VMState<EXTERNAL> state(isolate); | 8127 VMState<EXTERNAL> state(isolate); |
8174 ExternalCallbackScope call_scope(isolate, callback_address); | 8128 ExternalCallbackScope call_scope(isolate, callback_address); |
8175 return callback(info); | 8129 return callback(info); |
8176 } | 8130 } |
8177 | 8131 |
8178 | 8132 |
8179 } } // namespace v8::internal | 8133 } } // namespace v8::internal |
OLD | NEW |