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

Side by Side Diff: src/api.cc

Issue 430503007: Rename ASSERT* to DCHECK*. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE and fixes Created 6 years, 4 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/api.h ('k') | src/arguments.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 // 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/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "src/snapshot.h" 44 #include "src/snapshot.h"
45 #include "src/unicode-inl.h" 45 #include "src/unicode-inl.h"
46 #include "src/v8threads.h" 46 #include "src/v8threads.h"
47 #include "src/version.h" 47 #include "src/version.h"
48 #include "src/vm-state-inl.h" 48 #include "src/vm-state-inl.h"
49 49
50 50
51 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) 51 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr))
52 52
53 #define ENTER_V8(isolate) \ 53 #define ENTER_V8(isolate) \
54 ASSERT((isolate)->IsInitialized()); \ 54 DCHECK((isolate)->IsInitialized()); \
55 i::VMState<i::OTHER> __state__((isolate)) 55 i::VMState<i::OTHER> __state__((isolate))
56 56
57 namespace v8 { 57 namespace v8 {
58 58
59 #define ON_BAILOUT(isolate, location, code) \ 59 #define ON_BAILOUT(isolate, location, code) \
60 if (IsExecutionTerminatingCheck(isolate)) { \ 60 if (IsExecutionTerminatingCheck(isolate)) { \
61 code; \ 61 code; \
62 UNREACHABLE(); \ 62 UNREACHABLE(); \
63 } 63 }
64 64
65 65
66 #define EXCEPTION_PREAMBLE(isolate) \ 66 #define EXCEPTION_PREAMBLE(isolate) \
67 (isolate)->handle_scope_implementer()->IncrementCallDepth(); \ 67 (isolate)->handle_scope_implementer()->IncrementCallDepth(); \
68 ASSERT(!(isolate)->external_caught_exception()); \ 68 DCHECK(!(isolate)->external_caught_exception()); \
69 bool has_pending_exception = false 69 bool has_pending_exception = false
70 70
71 71
72 #define EXCEPTION_BAILOUT_CHECK_GENERIC(isolate, value, do_callback) \ 72 #define EXCEPTION_BAILOUT_CHECK_GENERIC(isolate, value, do_callback) \
73 do { \ 73 do { \
74 i::HandleScopeImplementer* handle_scope_implementer = \ 74 i::HandleScopeImplementer* handle_scope_implementer = \
75 (isolate)->handle_scope_implementer(); \ 75 (isolate)->handle_scope_implementer(); \
76 handle_scope_implementer->DecrementCallDepth(); \ 76 handle_scope_implementer->DecrementCallDepth(); \
77 if (has_pending_exception) { \ 77 if (has_pending_exception) { \
78 bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero(); \ 78 bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero(); \
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 for (int i = 0; i < compressed_data_count; ++i) { 248 for (int i = 0; i < compressed_data_count; ++i) {
249 char* decompressed = raw_data[i] = 249 char* decompressed = raw_data[i] =
250 i::NewArray<char>(compressed_data[i].raw_size); 250 i::NewArray<char>(compressed_data[i].raw_size);
251 if (compressed_data[i].compressed_size != 0) { 251 if (compressed_data[i].compressed_size != 0) {
252 int result = DecompressData(decompressed, 252 int result = DecompressData(decompressed,
253 &compressed_data[i].raw_size, 253 &compressed_data[i].raw_size,
254 compressed_data[i].data, 254 compressed_data[i].data,
255 compressed_data[i].compressed_size); 255 compressed_data[i].compressed_size);
256 if (result != 0) return result; 256 if (result != 0) return result;
257 } else { 257 } else {
258 ASSERT_EQ(0, compressed_data[i].raw_size); 258 DCHECK_EQ(0, compressed_data[i].raw_size);
259 } 259 }
260 compressed_data[i].data = decompressed; 260 compressed_data[i].data = decompressed;
261 } 261 }
262 V8::SetDecompressedStartupData(compressed_data); 262 V8::SetDecompressedStartupData(compressed_data);
263 i::DeleteArray(compressed_data); 263 i::DeleteArray(compressed_data);
264 return 0; 264 return 0;
265 } 265 }
266 266
267 267
268 StartupData::CompressionAlgorithm V8::GetCompressedStartupDataAlgorithm() { 268 StartupData::CompressionAlgorithm V8::GetCompressedStartupDataAlgorithm() {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 compressed_data[kExperimentalLibraries].compressed_size = 318 compressed_data[kExperimentalLibraries].compressed_size =
319 exp_libraries_source.length(); 319 exp_libraries_source.length();
320 compressed_data[kExperimentalLibraries].raw_size = 320 compressed_data[kExperimentalLibraries].raw_size =
321 i::ExperimentalNatives::GetRawScriptsSize(); 321 i::ExperimentalNatives::GetRawScriptsSize();
322 #endif 322 #endif
323 } 323 }
324 324
325 325
326 void V8::SetDecompressedStartupData(StartupData* decompressed_data) { 326 void V8::SetDecompressedStartupData(StartupData* decompressed_data) {
327 #ifdef COMPRESS_STARTUP_DATA_BZ2 327 #ifdef COMPRESS_STARTUP_DATA_BZ2
328 ASSERT_EQ(i::Snapshot::raw_size(), decompressed_data[kSnapshot].raw_size); 328 DCHECK_EQ(i::Snapshot::raw_size(), decompressed_data[kSnapshot].raw_size);
329 i::Snapshot::set_raw_data( 329 i::Snapshot::set_raw_data(
330 reinterpret_cast<const i::byte*>(decompressed_data[kSnapshot].data)); 330 reinterpret_cast<const i::byte*>(decompressed_data[kSnapshot].data));
331 331
332 ASSERT_EQ(i::Snapshot::context_raw_size(), 332 DCHECK_EQ(i::Snapshot::context_raw_size(),
333 decompressed_data[kSnapshotContext].raw_size); 333 decompressed_data[kSnapshotContext].raw_size);
334 i::Snapshot::set_context_raw_data( 334 i::Snapshot::set_context_raw_data(
335 reinterpret_cast<const i::byte*>( 335 reinterpret_cast<const i::byte*>(
336 decompressed_data[kSnapshotContext].data)); 336 decompressed_data[kSnapshotContext].data));
337 337
338 ASSERT_EQ(i::Natives::GetRawScriptsSize(), 338 DCHECK_EQ(i::Natives::GetRawScriptsSize(),
339 decompressed_data[kLibraries].raw_size); 339 decompressed_data[kLibraries].raw_size);
340 i::Vector<const char> libraries_source( 340 i::Vector<const char> libraries_source(
341 decompressed_data[kLibraries].data, 341 decompressed_data[kLibraries].data,
342 decompressed_data[kLibraries].raw_size); 342 decompressed_data[kLibraries].raw_size);
343 i::Natives::SetRawScriptsSource(libraries_source); 343 i::Natives::SetRawScriptsSource(libraries_source);
344 344
345 ASSERT_EQ(i::ExperimentalNatives::GetRawScriptsSize(), 345 DCHECK_EQ(i::ExperimentalNatives::GetRawScriptsSize(),
346 decompressed_data[kExperimentalLibraries].raw_size); 346 decompressed_data[kExperimentalLibraries].raw_size);
347 i::Vector<const char> exp_libraries_source( 347 i::Vector<const char> exp_libraries_source(
348 decompressed_data[kExperimentalLibraries].data, 348 decompressed_data[kExperimentalLibraries].data,
349 decompressed_data[kExperimentalLibraries].raw_size); 349 decompressed_data[kExperimentalLibraries].raw_size);
350 i::ExperimentalNatives::SetRawScriptsSource(exp_libraries_source); 350 i::ExperimentalNatives::SetRawScriptsSource(exp_libraries_source);
351 #endif 351 #endif
352 } 352 }
353 353
354 354
355 void V8::SetNativesDataBlob(StartupData* natives_blob) { 355 void V8::SetNativesDataBlob(StartupData* natives_blob) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 bool SetResourceConstraints(Isolate* v8_isolate, 495 bool SetResourceConstraints(Isolate* v8_isolate,
496 ResourceConstraints* constraints) { 496 ResourceConstraints* constraints) {
497 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); 497 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
498 int semi_space_size = constraints->max_semi_space_size(); 498 int semi_space_size = constraints->max_semi_space_size();
499 int old_space_size = constraints->max_old_space_size(); 499 int old_space_size = constraints->max_old_space_size();
500 int max_executable_size = constraints->max_executable_size(); 500 int max_executable_size = constraints->max_executable_size();
501 size_t code_range_size = constraints->code_range_size(); 501 size_t code_range_size = constraints->code_range_size();
502 if (semi_space_size != 0 || old_space_size != 0 || 502 if (semi_space_size != 0 || old_space_size != 0 ||
503 max_executable_size != 0 || code_range_size != 0) { 503 max_executable_size != 0 || code_range_size != 0) {
504 // After initialization it's too late to change Heap constraints. 504 // After initialization it's too late to change Heap constraints.
505 ASSERT(!isolate->IsInitialized()); 505 DCHECK(!isolate->IsInitialized());
506 bool result = isolate->heap()->ConfigureHeap(semi_space_size, 506 bool result = isolate->heap()->ConfigureHeap(semi_space_size,
507 old_space_size, 507 old_space_size,
508 max_executable_size, 508 max_executable_size,
509 code_range_size); 509 code_range_size);
510 if (!result) return false; 510 if (!result) return false;
511 } 511 }
512 if (constraints->stack_limit() != NULL) { 512 if (constraints->stack_limit() != NULL) {
513 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit()); 513 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit());
514 isolate->stack_guard()->SetStackLimit(limit); 514 isolate->stack_guard()->SetStackLimit(limit);
515 } 515 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 } 604 }
605 605
606 606
607 i::Object** HandleScope::CreateHandle(i::Isolate* isolate, i::Object* value) { 607 i::Object** HandleScope::CreateHandle(i::Isolate* isolate, i::Object* value) {
608 return i::HandleScope::CreateHandle(isolate, value); 608 return i::HandleScope::CreateHandle(isolate, value);
609 } 609 }
610 610
611 611
612 i::Object** HandleScope::CreateHandle(i::HeapObject* heap_object, 612 i::Object** HandleScope::CreateHandle(i::HeapObject* heap_object,
613 i::Object* value) { 613 i::Object* value) {
614 ASSERT(heap_object->IsHeapObject()); 614 DCHECK(heap_object->IsHeapObject());
615 return i::HandleScope::CreateHandle(heap_object->GetIsolate(), value); 615 return i::HandleScope::CreateHandle(heap_object->GetIsolate(), value);
616 } 616 }
617 617
618 618
619 EscapableHandleScope::EscapableHandleScope(Isolate* v8_isolate) { 619 EscapableHandleScope::EscapableHandleScope(Isolate* v8_isolate) {
620 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); 620 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
621 escape_slot_ = CreateHandle(isolate, isolate->heap()->the_hole_value()); 621 escape_slot_ = CreateHandle(isolate, isolate->heap()->the_hole_value());
622 Initialize(v8_isolate); 622 Initialize(v8_isolate);
623 } 623 }
624 624
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 return Utils::ToLocal(result); 707 return Utils::ToLocal(result);
708 } 708 }
709 709
710 710
711 void Context::SetEmbedderData(int index, v8::Handle<Value> value) { 711 void Context::SetEmbedderData(int index, v8::Handle<Value> value) {
712 const char* location = "v8::Context::SetEmbedderData()"; 712 const char* location = "v8::Context::SetEmbedderData()";
713 i::Handle<i::FixedArray> data = EmbedderDataFor(this, index, true, location); 713 i::Handle<i::FixedArray> data = EmbedderDataFor(this, index, true, location);
714 if (data.is_null()) return; 714 if (data.is_null()) return;
715 i::Handle<i::Object> val = Utils::OpenHandle(*value); 715 i::Handle<i::Object> val = Utils::OpenHandle(*value);
716 data->set(index, *val); 716 data->set(index, *val);
717 ASSERT_EQ(*Utils::OpenHandle(*value), 717 DCHECK_EQ(*Utils::OpenHandle(*value),
718 *Utils::OpenHandle(*GetEmbedderData(index))); 718 *Utils::OpenHandle(*GetEmbedderData(index)));
719 } 719 }
720 720
721 721
722 void* Context::SlowGetAlignedPointerFromEmbedderData(int index) { 722 void* Context::SlowGetAlignedPointerFromEmbedderData(int index) {
723 const char* location = "v8::Context::GetAlignedPointerFromEmbedderData()"; 723 const char* location = "v8::Context::GetAlignedPointerFromEmbedderData()";
724 i::Handle<i::FixedArray> data = EmbedderDataFor(this, index, false, location); 724 i::Handle<i::FixedArray> data = EmbedderDataFor(this, index, false, location);
725 if (data.is_null()) return NULL; 725 if (data.is_null()) return NULL;
726 return DecodeSmiToAligned(data->get(index), location); 726 return DecodeSmiToAligned(data->get(index), location);
727 } 727 }
728 728
729 729
730 void Context::SetAlignedPointerInEmbedderData(int index, void* value) { 730 void Context::SetAlignedPointerInEmbedderData(int index, void* value) {
731 const char* location = "v8::Context::SetAlignedPointerInEmbedderData()"; 731 const char* location = "v8::Context::SetAlignedPointerInEmbedderData()";
732 i::Handle<i::FixedArray> data = EmbedderDataFor(this, index, true, location); 732 i::Handle<i::FixedArray> data = EmbedderDataFor(this, index, true, location);
733 data->set(index, EncodeAlignedAsSmi(value, location)); 733 data->set(index, EncodeAlignedAsSmi(value, location));
734 ASSERT_EQ(value, GetAlignedPointerFromEmbedderData(index)); 734 DCHECK_EQ(value, GetAlignedPointerFromEmbedderData(index));
735 } 735 }
736 736
737 737
738 // --- N e a n d e r --- 738 // --- N e a n d e r ---
739 739
740 740
741 // A constructor cannot easily return an error value, therefore it is necessary 741 // A constructor cannot easily return an error value, therefore it is necessary
742 // to check for a dead VM with ON_BAILOUT before constructing any Neander 742 // to check for a dead VM with ON_BAILOUT before constructing any Neander
743 // objects. To remind you about this there is no HandleScope in the 743 // objects. To remind you about this there is no HandleScope in the
744 // NeanderObject constructor. When you add one to the site calling the 744 // NeanderObject constructor. When you add one to the site calling the
(...skipping 16 matching lines...) Expand all
761 obj_.set(0, i::Smi::FromInt(0)); 761 obj_.set(0, i::Smi::FromInt(0));
762 } 762 }
763 763
764 764
765 int NeanderArray::length() { 765 int NeanderArray::length() {
766 return i::Smi::cast(obj_.get(0))->value(); 766 return i::Smi::cast(obj_.get(0))->value();
767 } 767 }
768 768
769 769
770 i::Object* NeanderArray::get(int offset) { 770 i::Object* NeanderArray::get(int offset) {
771 ASSERT(0 <= offset); 771 DCHECK(0 <= offset);
772 ASSERT(offset < length()); 772 DCHECK(offset < length());
773 return obj_.get(offset + 1); 773 return obj_.get(offset + 1);
774 } 774 }
775 775
776 776
777 // This method cannot easily return an error value, therefore it is necessary 777 // This method cannot easily return an error value, therefore it is necessary
778 // to check for a dead VM with ON_BAILOUT before calling it. To remind you 778 // to check for a dead VM with ON_BAILOUT before calling it. To remind you
779 // about this there is no HandleScope in this method. When you add one to the 779 // about this there is no HandleScope in this method. When you add one to the
780 // site calling this method you should check that you ensured the VM was not 780 // site calling this method you should check that you ensured the VM was not
781 // dead first. 781 // dead first.
782 void NeanderArray::add(i::Handle<i::Object> value) { 782 void NeanderArray::add(i::Handle<i::Object> value) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 } 844 }
845 845
846 846
847 void Template::SetAccessorProperty( 847 void Template::SetAccessorProperty(
848 v8::Local<v8::String> name, 848 v8::Local<v8::String> name,
849 v8::Local<FunctionTemplate> getter, 849 v8::Local<FunctionTemplate> getter,
850 v8::Local<FunctionTemplate> setter, 850 v8::Local<FunctionTemplate> setter,
851 v8::PropertyAttribute attribute, 851 v8::PropertyAttribute attribute,
852 v8::AccessControl access_control) { 852 v8::AccessControl access_control) {
853 // TODO(verwaest): Remove |access_control|. 853 // TODO(verwaest): Remove |access_control|.
854 ASSERT_EQ(v8::DEFAULT, access_control); 854 DCHECK_EQ(v8::DEFAULT, access_control);
855 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 855 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
856 ENTER_V8(isolate); 856 ENTER_V8(isolate);
857 ASSERT(!name.IsEmpty()); 857 DCHECK(!name.IsEmpty());
858 ASSERT(!getter.IsEmpty() || !setter.IsEmpty()); 858 DCHECK(!getter.IsEmpty() || !setter.IsEmpty());
859 i::HandleScope scope(isolate); 859 i::HandleScope scope(isolate);
860 const int kSize = 5; 860 const int kSize = 5;
861 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); 861 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
862 v8::Handle<v8::Data> data[kSize] = { 862 v8::Handle<v8::Data> data[kSize] = {
863 name, 863 name,
864 getter, 864 getter,
865 setter, 865 setter,
866 v8::Integer::New(v8_isolate, attribute)}; 866 v8::Integer::New(v8_isolate, attribute)};
867 TemplateSet(isolate, this, kSize, data); 867 TemplateSet(isolate, this, kSize, data);
868 } 868 }
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after
1707 // - kProduceToCache -> kProduceParserCache 1707 // - kProduceToCache -> kProduceParserCache
1708 // - kNoCompileOptions + cached_data != NULL -> kConsumeParserCache 1708 // - kNoCompileOptions + cached_data != NULL -> kConsumeParserCache
1709 if (options == kProduceDataToCache) { 1709 if (options == kProduceDataToCache) {
1710 options = kProduceParserCache; 1710 options = kProduceParserCache;
1711 } else if (options == kNoCompileOptions && source->cached_data) { 1711 } else if (options == kNoCompileOptions && source->cached_data) {
1712 options = kConsumeParserCache; 1712 options = kConsumeParserCache;
1713 } 1713 }
1714 1714
1715 i::ScriptData* script_data = NULL; 1715 i::ScriptData* script_data = NULL;
1716 if (options == kConsumeParserCache || options == kConsumeCodeCache) { 1716 if (options == kConsumeParserCache || options == kConsumeCodeCache) {
1717 ASSERT(source->cached_data); 1717 DCHECK(source->cached_data);
1718 // ScriptData takes care of pointer-aligning the data. 1718 // ScriptData takes care of pointer-aligning the data.
1719 script_data = new i::ScriptData(source->cached_data->data, 1719 script_data = new i::ScriptData(source->cached_data->data,
1720 source->cached_data->length); 1720 source->cached_data->length);
1721 } 1721 }
1722 1722
1723 i::Handle<i::String> str = Utils::OpenHandle(*(source->source_string)); 1723 i::Handle<i::String> str = Utils::OpenHandle(*(source->source_string));
1724 LOG_API(isolate, "ScriptCompiler::CompileUnbound"); 1724 LOG_API(isolate, "ScriptCompiler::CompileUnbound");
1725 ENTER_V8(isolate); 1725 ENTER_V8(isolate);
1726 i::SharedFunctionInfo* raw_result = NULL; 1726 i::SharedFunctionInfo* raw_result = NULL;
1727 { i::HandleScope scope(isolate); 1727 { i::HandleScope scope(isolate);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1826 Reset(); 1826 Reset();
1827 // Special handling for simulators which have a separate JS stack. 1827 // Special handling for simulators which have a separate JS stack.
1828 js_stack_comparable_address_ = 1828 js_stack_comparable_address_ =
1829 reinterpret_cast<void*>(v8::internal::SimulatorStack::RegisterCTryCatch( 1829 reinterpret_cast<void*>(v8::internal::SimulatorStack::RegisterCTryCatch(
1830 GetCurrentStackPosition())); 1830 GetCurrentStackPosition()));
1831 isolate_->RegisterTryCatchHandler(this); 1831 isolate_->RegisterTryCatchHandler(this);
1832 } 1832 }
1833 1833
1834 1834
1835 v8::TryCatch::~TryCatch() { 1835 v8::TryCatch::~TryCatch() {
1836 ASSERT(isolate_ == i::Isolate::Current()); 1836 DCHECK(isolate_ == i::Isolate::Current());
1837 if (rethrow_) { 1837 if (rethrow_) {
1838 v8::Isolate* isolate = reinterpret_cast<Isolate*>(isolate_); 1838 v8::Isolate* isolate = reinterpret_cast<Isolate*>(isolate_);
1839 v8::HandleScope scope(isolate); 1839 v8::HandleScope scope(isolate);
1840 v8::Local<v8::Value> exc = v8::Local<v8::Value>::New(isolate, Exception()); 1840 v8::Local<v8::Value> exc = v8::Local<v8::Value>::New(isolate, Exception());
1841 if (HasCaught() && capture_message_) { 1841 if (HasCaught() && capture_message_) {
1842 // If an exception was caught and rethrow_ is indicated, the saved 1842 // If an exception was caught and rethrow_ is indicated, the saved
1843 // message, script, and location need to be restored to Isolate TLS 1843 // message, script, and location need to be restored to Isolate TLS
1844 // for reuse. capture_message_ needs to be disabled so that DoThrow() 1844 // for reuse. capture_message_ needs to be disabled so that DoThrow()
1845 // does not create a new message. 1845 // does not create a new message.
1846 isolate_->thread_local_top()->rethrowing_message_ = true; 1846 isolate_->thread_local_top()->rethrowing_message_ = true;
1847 isolate_->RestorePendingMessageFromTryCatch(this); 1847 isolate_->RestorePendingMessageFromTryCatch(this);
1848 } 1848 }
1849 isolate_->UnregisterTryCatchHandler(this); 1849 isolate_->UnregisterTryCatchHandler(this);
1850 v8::internal::SimulatorStack::UnregisterCTryCatch(); 1850 v8::internal::SimulatorStack::UnregisterCTryCatch();
1851 reinterpret_cast<Isolate*>(isolate_)->ThrowException(exc); 1851 reinterpret_cast<Isolate*>(isolate_)->ThrowException(exc);
1852 ASSERT(!isolate_->thread_local_top()->rethrowing_message_); 1852 DCHECK(!isolate_->thread_local_top()->rethrowing_message_);
1853 } else { 1853 } else {
1854 if (HasCaught() && isolate_->has_scheduled_exception()) { 1854 if (HasCaught() && isolate_->has_scheduled_exception()) {
1855 // If an exception was caught but is still scheduled because no API call 1855 // If an exception was caught but is still scheduled because no API call
1856 // promoted it, then it is canceled to prevent it from being propagated. 1856 // promoted it, then it is canceled to prevent it from being propagated.
1857 // Note that this will not cancel termination exceptions. 1857 // Note that this will not cancel termination exceptions.
1858 isolate_->CancelScheduledExceptionFromTryCatch(this); 1858 isolate_->CancelScheduledExceptionFromTryCatch(this);
1859 } 1859 }
1860 isolate_->UnregisterTryCatchHandler(this); 1860 isolate_->UnregisterTryCatchHandler(this);
1861 v8::internal::SimulatorStack::UnregisterCTryCatch(); 1861 v8::internal::SimulatorStack::UnregisterCTryCatch();
1862 } 1862 }
(...skipping 16 matching lines...) Expand all
1879 1879
1880 1880
1881 v8::Handle<v8::Value> v8::TryCatch::ReThrow() { 1881 v8::Handle<v8::Value> v8::TryCatch::ReThrow() {
1882 if (!HasCaught()) return v8::Local<v8::Value>(); 1882 if (!HasCaught()) return v8::Local<v8::Value>();
1883 rethrow_ = true; 1883 rethrow_ = true;
1884 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate_)); 1884 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate_));
1885 } 1885 }
1886 1886
1887 1887
1888 v8::Local<Value> v8::TryCatch::Exception() const { 1888 v8::Local<Value> v8::TryCatch::Exception() const {
1889 ASSERT(isolate_ == i::Isolate::Current()); 1889 DCHECK(isolate_ == i::Isolate::Current());
1890 if (HasCaught()) { 1890 if (HasCaught()) {
1891 // Check for out of memory exception. 1891 // Check for out of memory exception.
1892 i::Object* exception = reinterpret_cast<i::Object*>(exception_); 1892 i::Object* exception = reinterpret_cast<i::Object*>(exception_);
1893 return v8::Utils::ToLocal(i::Handle<i::Object>(exception, isolate_)); 1893 return v8::Utils::ToLocal(i::Handle<i::Object>(exception, isolate_));
1894 } else { 1894 } else {
1895 return v8::Local<Value>(); 1895 return v8::Local<Value>();
1896 } 1896 }
1897 } 1897 }
1898 1898
1899 1899
1900 v8::Local<Value> v8::TryCatch::StackTrace() const { 1900 v8::Local<Value> v8::TryCatch::StackTrace() const {
1901 ASSERT(isolate_ == i::Isolate::Current()); 1901 DCHECK(isolate_ == i::Isolate::Current());
1902 if (HasCaught()) { 1902 if (HasCaught()) {
1903 i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_); 1903 i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_);
1904 if (!raw_obj->IsJSObject()) return v8::Local<Value>(); 1904 if (!raw_obj->IsJSObject()) return v8::Local<Value>();
1905 i::HandleScope scope(isolate_); 1905 i::HandleScope scope(isolate_);
1906 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_); 1906 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_);
1907 i::Handle<i::String> name = isolate_->factory()->stack_string(); 1907 i::Handle<i::String> name = isolate_->factory()->stack_string();
1908 EXCEPTION_PREAMBLE(isolate_); 1908 EXCEPTION_PREAMBLE(isolate_);
1909 Maybe<bool> maybe = i::JSReceiver::HasProperty(obj, name); 1909 Maybe<bool> maybe = i::JSReceiver::HasProperty(obj, name);
1910 has_pending_exception = !maybe.has_value; 1910 has_pending_exception = !maybe.has_value;
1911 EXCEPTION_BAILOUT_CHECK(isolate_, v8::Local<Value>()); 1911 EXCEPTION_BAILOUT_CHECK(isolate_, v8::Local<Value>());
1912 if (!maybe.value) return v8::Local<Value>(); 1912 if (!maybe.value) return v8::Local<Value>();
1913 i::Handle<i::Object> value; 1913 i::Handle<i::Object> value;
1914 if (!i::Object::GetProperty(obj, name).ToHandle(&value)) { 1914 if (!i::Object::GetProperty(obj, name).ToHandle(&value)) {
1915 return v8::Local<Value>(); 1915 return v8::Local<Value>();
1916 } 1916 }
1917 return v8::Utils::ToLocal(scope.CloseAndEscape(value)); 1917 return v8::Utils::ToLocal(scope.CloseAndEscape(value));
1918 } else { 1918 } else {
1919 return v8::Local<Value>(); 1919 return v8::Local<Value>();
1920 } 1920 }
1921 } 1921 }
1922 1922
1923 1923
1924 v8::Local<v8::Message> v8::TryCatch::Message() const { 1924 v8::Local<v8::Message> v8::TryCatch::Message() const {
1925 ASSERT(isolate_ == i::Isolate::Current()); 1925 DCHECK(isolate_ == i::Isolate::Current());
1926 i::Object* message = reinterpret_cast<i::Object*>(message_obj_); 1926 i::Object* message = reinterpret_cast<i::Object*>(message_obj_);
1927 ASSERT(message->IsJSMessageObject() || message->IsTheHole()); 1927 DCHECK(message->IsJSMessageObject() || message->IsTheHole());
1928 if (HasCaught() && !message->IsTheHole()) { 1928 if (HasCaught() && !message->IsTheHole()) {
1929 return v8::Utils::MessageToLocal(i::Handle<i::Object>(message, isolate_)); 1929 return v8::Utils::MessageToLocal(i::Handle<i::Object>(message, isolate_));
1930 } else { 1930 } else {
1931 return v8::Local<v8::Message>(); 1931 return v8::Local<v8::Message>();
1932 } 1932 }
1933 } 1933 }
1934 1934
1935 1935
1936 void v8::TryCatch::Reset() { 1936 void v8::TryCatch::Reset() {
1937 ASSERT(isolate_ == i::Isolate::Current()); 1937 DCHECK(isolate_ == i::Isolate::Current());
1938 i::Object* the_hole = isolate_->heap()->the_hole_value(); 1938 i::Object* the_hole = isolate_->heap()->the_hole_value();
1939 exception_ = the_hole; 1939 exception_ = the_hole;
1940 message_obj_ = the_hole; 1940 message_obj_ = the_hole;
1941 message_script_ = the_hole; 1941 message_script_ = the_hole;
1942 message_start_pos_ = 0; 1942 message_start_pos_ = 0;
1943 message_end_pos_ = 0; 1943 message_end_pos_ = 0;
1944 } 1944 }
1945 1945
1946 1946
1947 void v8::TryCatch::SetVerbose(bool value) { 1947 void v8::TryCatch::SetVerbose(bool value) {
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
2279 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>()); 2279 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>());
2280 return Utils::ToLocal( 2280 return Utils::ToLocal(
2281 i::Handle<i::Object>::cast(scope.CloseAndEscape(result))); 2281 i::Handle<i::Object>::cast(scope.CloseAndEscape(result)));
2282 } 2282 }
2283 2283
2284 2284
2285 // --- D a t a --- 2285 // --- D a t a ---
2286 2286
2287 bool Value::FullIsUndefined() const { 2287 bool Value::FullIsUndefined() const {
2288 bool result = Utils::OpenHandle(this)->IsUndefined(); 2288 bool result = Utils::OpenHandle(this)->IsUndefined();
2289 ASSERT_EQ(result, QuickIsUndefined()); 2289 DCHECK_EQ(result, QuickIsUndefined());
2290 return result; 2290 return result;
2291 } 2291 }
2292 2292
2293 2293
2294 bool Value::FullIsNull() const { 2294 bool Value::FullIsNull() const {
2295 bool result = Utils::OpenHandle(this)->IsNull(); 2295 bool result = Utils::OpenHandle(this)->IsNull();
2296 ASSERT_EQ(result, QuickIsNull()); 2296 DCHECK_EQ(result, QuickIsNull());
2297 return result; 2297 return result;
2298 } 2298 }
2299 2299
2300 2300
2301 bool Value::IsTrue() const { 2301 bool Value::IsTrue() const {
2302 return Utils::OpenHandle(this)->IsTrue(); 2302 return Utils::OpenHandle(this)->IsTrue();
2303 } 2303 }
2304 2304
2305 2305
2306 bool Value::IsFalse() const { 2306 bool Value::IsFalse() const {
2307 return Utils::OpenHandle(this)->IsFalse(); 2307 return Utils::OpenHandle(this)->IsFalse();
2308 } 2308 }
2309 2309
2310 2310
2311 bool Value::IsFunction() const { 2311 bool Value::IsFunction() const {
2312 return Utils::OpenHandle(this)->IsJSFunction(); 2312 return Utils::OpenHandle(this)->IsJSFunction();
2313 } 2313 }
2314 2314
2315 2315
2316 bool Value::FullIsString() const { 2316 bool Value::FullIsString() const {
2317 bool result = Utils::OpenHandle(this)->IsString(); 2317 bool result = Utils::OpenHandle(this)->IsString();
2318 ASSERT_EQ(result, QuickIsString()); 2318 DCHECK_EQ(result, QuickIsString());
2319 return result; 2319 return result;
2320 } 2320 }
2321 2321
2322 2322
2323 bool Value::IsSymbol() const { 2323 bool Value::IsSymbol() const {
2324 return Utils::OpenHandle(this)->IsSymbol(); 2324 return Utils::OpenHandle(this)->IsSymbol();
2325 } 2325 }
2326 2326
2327 2327
2328 bool Value::IsArray() const { 2328 bool Value::IsArray() const {
(...skipping 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after
3462 this, name, descriptor, null, null, settings, attributes); 3462 this, name, descriptor, null, null, settings, attributes);
3463 } 3463 }
3464 3464
3465 3465
3466 void Object::SetAccessorProperty(Local<String> name, 3466 void Object::SetAccessorProperty(Local<String> name,
3467 Local<Function> getter, 3467 Local<Function> getter,
3468 Handle<Function> setter, 3468 Handle<Function> setter,
3469 PropertyAttribute attribute, 3469 PropertyAttribute attribute,
3470 AccessControl settings) { 3470 AccessControl settings) {
3471 // TODO(verwaest): Remove |settings|. 3471 // TODO(verwaest): Remove |settings|.
3472 ASSERT_EQ(v8::DEFAULT, settings); 3472 DCHECK_EQ(v8::DEFAULT, settings);
3473 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3473 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3474 ON_BAILOUT(isolate, "v8::Object::SetAccessorProperty()", return); 3474 ON_BAILOUT(isolate, "v8::Object::SetAccessorProperty()", return);
3475 ENTER_V8(isolate); 3475 ENTER_V8(isolate);
3476 i::HandleScope scope(isolate); 3476 i::HandleScope scope(isolate);
3477 i::Handle<i::Object> getter_i = v8::Utils::OpenHandle(*getter); 3477 i::Handle<i::Object> getter_i = v8::Utils::OpenHandle(*getter);
3478 i::Handle<i::Object> setter_i = v8::Utils::OpenHandle(*setter, true); 3478 i::Handle<i::Object> setter_i = v8::Utils::OpenHandle(*setter, true);
3479 if (setter_i.is_null()) setter_i = isolate->factory()->null_value(); 3479 if (setter_i.is_null()) setter_i = isolate->factory()->null_value();
3480 i::JSObject::DefineAccessor(v8::Utils::OpenHandle(this), 3480 i::JSObject::DefineAccessor(v8::Utils::OpenHandle(this),
3481 v8::Utils::OpenHandle(*name), 3481 v8::Utils::OpenHandle(*name),
3482 getter_i, 3482 getter_i,
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
3949 has_pending_exception = !i::Execution::TryGetConstructorDelegate( 3949 has_pending_exception = !i::Execution::TryGetConstructorDelegate(
3950 isolate, obj).ToHandle(&delegate); 3950 isolate, obj).ToHandle(&delegate);
3951 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>()); 3951 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>());
3952 if (!delegate->IsUndefined()) { 3952 if (!delegate->IsUndefined()) {
3953 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(delegate); 3953 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(delegate);
3954 EXCEPTION_PREAMBLE(isolate); 3954 EXCEPTION_PREAMBLE(isolate);
3955 i::Handle<i::Object> returned; 3955 i::Handle<i::Object> returned;
3956 has_pending_exception = !i::Execution::Call( 3956 has_pending_exception = !i::Execution::Call(
3957 isolate, fun, obj, argc, args).ToHandle(&returned); 3957 isolate, fun, obj, argc, args).ToHandle(&returned);
3958 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<v8::Object>()); 3958 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<v8::Object>());
3959 ASSERT(!delegate->IsUndefined()); 3959 DCHECK(!delegate->IsUndefined());
3960 return Utils::ToLocal(scope.CloseAndEscape(returned)); 3960 return Utils::ToLocal(scope.CloseAndEscape(returned));
3961 } 3961 }
3962 return Local<v8::Object>(); 3962 return Local<v8::Object>();
3963 } 3963 }
3964 3964
3965 3965
3966 Local<Function> Function::New(Isolate* v8_isolate, 3966 Local<Function> Function::New(Isolate* v8_isolate,
3967 FunctionCallback callback, 3967 FunctionCallback callback,
3968 Local<Value> data, 3968 Local<Value> data,
3969 int length) { 3969 int length) {
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
4338 int utf8_length_; 4338 int utf8_length_;
4339 uint8_t state_; 4339 uint8_t state_;
4340 DISALLOW_COPY_AND_ASSIGN(Visitor); 4340 DISALLOW_COPY_AND_ASSIGN(Visitor);
4341 }; 4341 };
4342 4342
4343 static inline void MergeLeafLeft(int* length, 4343 static inline void MergeLeafLeft(int* length,
4344 uint8_t* state, 4344 uint8_t* state,
4345 uint8_t leaf_state) { 4345 uint8_t leaf_state) {
4346 bool edge_surrogate = StartsWithSurrogate(leaf_state); 4346 bool edge_surrogate = StartsWithSurrogate(leaf_state);
4347 if (!(*state & kLeftmostEdgeIsCalculated)) { 4347 if (!(*state & kLeftmostEdgeIsCalculated)) {
4348 ASSERT(!(*state & kLeftmostEdgeIsSurrogate)); 4348 DCHECK(!(*state & kLeftmostEdgeIsSurrogate));
4349 *state |= kLeftmostEdgeIsCalculated 4349 *state |= kLeftmostEdgeIsCalculated
4350 | (edge_surrogate ? kLeftmostEdgeIsSurrogate : 0); 4350 | (edge_surrogate ? kLeftmostEdgeIsSurrogate : 0);
4351 } else if (EndsWithSurrogate(*state) && edge_surrogate) { 4351 } else if (EndsWithSurrogate(*state) && edge_surrogate) {
4352 *length -= unibrow::Utf8::kBytesSavedByCombiningSurrogates; 4352 *length -= unibrow::Utf8::kBytesSavedByCombiningSurrogates;
4353 } 4353 }
4354 if (EndsWithSurrogate(leaf_state)) { 4354 if (EndsWithSurrogate(leaf_state)) {
4355 *state |= kEndsWithLeadingSurrogate; 4355 *state |= kEndsWithLeadingSurrogate;
4356 } else { 4356 } else {
4357 *state &= ~kEndsWithLeadingSurrogate; 4357 *state &= ~kEndsWithLeadingSurrogate;
4358 } 4358 }
4359 } 4359 }
4360 4360
4361 static inline void MergeLeafRight(int* length, 4361 static inline void MergeLeafRight(int* length,
4362 uint8_t* state, 4362 uint8_t* state,
4363 uint8_t leaf_state) { 4363 uint8_t leaf_state) {
4364 bool edge_surrogate = EndsWithSurrogate(leaf_state); 4364 bool edge_surrogate = EndsWithSurrogate(leaf_state);
4365 if (!(*state & kRightmostEdgeIsCalculated)) { 4365 if (!(*state & kRightmostEdgeIsCalculated)) {
4366 ASSERT(!(*state & kRightmostEdgeIsSurrogate)); 4366 DCHECK(!(*state & kRightmostEdgeIsSurrogate));
4367 *state |= (kRightmostEdgeIsCalculated 4367 *state |= (kRightmostEdgeIsCalculated
4368 | (edge_surrogate ? kRightmostEdgeIsSurrogate : 0)); 4368 | (edge_surrogate ? kRightmostEdgeIsSurrogate : 0));
4369 } else if (edge_surrogate && StartsWithSurrogate(*state)) { 4369 } else if (edge_surrogate && StartsWithSurrogate(*state)) {
4370 *length -= unibrow::Utf8::kBytesSavedByCombiningSurrogates; 4370 *length -= unibrow::Utf8::kBytesSavedByCombiningSurrogates;
4371 } 4371 }
4372 if (StartsWithSurrogate(leaf_state)) { 4372 if (StartsWithSurrogate(leaf_state)) {
4373 *state |= kStartsWithTrailingSurrogate; 4373 *state |= kStartsWithTrailingSurrogate;
4374 } else { 4374 } else {
4375 *state &= ~kStartsWithTrailingSurrogate; 4375 *state &= ~kStartsWithTrailingSurrogate;
4376 } 4376 }
4377 } 4377 }
4378 4378
4379 static inline void MergeTerminal(int* length, 4379 static inline void MergeTerminal(int* length,
4380 uint8_t state, 4380 uint8_t state,
4381 uint8_t* state_out) { 4381 uint8_t* state_out) {
4382 ASSERT((state & kLeftmostEdgeIsCalculated) && 4382 DCHECK((state & kLeftmostEdgeIsCalculated) &&
4383 (state & kRightmostEdgeIsCalculated)); 4383 (state & kRightmostEdgeIsCalculated));
4384 if (EndsWithSurrogate(state) && StartsWithSurrogate(state)) { 4384 if (EndsWithSurrogate(state) && StartsWithSurrogate(state)) {
4385 *length -= unibrow::Utf8::kBytesSavedByCombiningSurrogates; 4385 *length -= unibrow::Utf8::kBytesSavedByCombiningSurrogates;
4386 } 4386 }
4387 *state_out = kInitialState | 4387 *state_out = kInitialState |
4388 (state & kLeftmostEdgeIsSurrogate ? kStartsWithTrailingSurrogate : 0) | 4388 (state & kLeftmostEdgeIsSurrogate ? kStartsWithTrailingSurrogate : 0) |
4389 (state & kRightmostEdgeIsSurrogate ? kEndsWithLeadingSurrogate : 0); 4389 (state & kRightmostEdgeIsSurrogate ? kEndsWithLeadingSurrogate : 0);
4390 } 4390 }
4391 4391
4392 static int Calculate(i::ConsString* current, uint8_t* state_out) { 4392 static int Calculate(i::ConsString* current, uint8_t* state_out) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
4484 replace_invalid_utf8_(replace_invalid_utf8), 4484 replace_invalid_utf8_(replace_invalid_utf8),
4485 utf16_chars_read_(0) { 4485 utf16_chars_read_(0) {
4486 } 4486 }
4487 4487
4488 static int WriteEndCharacter(uint16_t character, 4488 static int WriteEndCharacter(uint16_t character,
4489 int last_character, 4489 int last_character,
4490 int remaining, 4490 int remaining,
4491 char* const buffer, 4491 char* const buffer,
4492 bool replace_invalid_utf8) { 4492 bool replace_invalid_utf8) {
4493 using namespace unibrow; 4493 using namespace unibrow;
4494 ASSERT(remaining > 0); 4494 DCHECK(remaining > 0);
4495 // We can't use a local buffer here because Encode needs to modify 4495 // We can't use a local buffer here because Encode needs to modify
4496 // previous characters in the stream. We know, however, that 4496 // previous characters in the stream. We know, however, that
4497 // exactly one character will be advanced. 4497 // exactly one character will be advanced.
4498 if (Utf16::IsSurrogatePair(last_character, character)) { 4498 if (Utf16::IsSurrogatePair(last_character, character)) {
4499 int written = Utf8::Encode(buffer, 4499 int written = Utf8::Encode(buffer,
4500 character, 4500 character,
4501 last_character, 4501 last_character,
4502 replace_invalid_utf8); 4502 replace_invalid_utf8);
4503 ASSERT(written == 1); 4503 DCHECK(written == 1);
4504 return written; 4504 return written;
4505 } 4505 }
4506 // Use a scratch buffer to check the required characters. 4506 // Use a scratch buffer to check the required characters.
4507 char temp_buffer[Utf8::kMaxEncodedSize]; 4507 char temp_buffer[Utf8::kMaxEncodedSize];
4508 // Can't encode using last_character as gcc has array bounds issues. 4508 // Can't encode using last_character as gcc has array bounds issues.
4509 int written = Utf8::Encode(temp_buffer, 4509 int written = Utf8::Encode(temp_buffer,
4510 character, 4510 character,
4511 Utf16::kNoPreviousCharacter, 4511 Utf16::kNoPreviousCharacter,
4512 replace_invalid_utf8); 4512 replace_invalid_utf8);
4513 // Won't fit. 4513 // Won't fit.
(...skipping 11 matching lines...) Expand all
4525 // written without exceeding the buffer capacity and without writing the last 4525 // written without exceeding the buffer capacity and without writing the last
4526 // code unit (it could be a lead surrogate). The estimated number of code 4526 // code unit (it could be a lead surrogate). The estimated number of code
4527 // units is then written out in one go, and the reported byte usage is used 4527 // units is then written out in one go, and the reported byte usage is used
4528 // to correct the estimate. This is repeated until the estimate becomes <= 0 4528 // to correct the estimate. This is repeated until the estimate becomes <= 0
4529 // or all code units have been written out. The second phase writes out code 4529 // or all code units have been written out. The second phase writes out code
4530 // units until the buffer capacity is reached, would be exceeded by the next 4530 // units until the buffer capacity is reached, would be exceeded by the next
4531 // unit, or all units have been written out. 4531 // unit, or all units have been written out.
4532 template<typename Char> 4532 template<typename Char>
4533 void Visit(const Char* chars, const int length) { 4533 void Visit(const Char* chars, const int length) {
4534 using namespace unibrow; 4534 using namespace unibrow;
4535 ASSERT(!early_termination_); 4535 DCHECK(!early_termination_);
4536 if (length == 0) return; 4536 if (length == 0) return;
4537 // Copy state to stack. 4537 // Copy state to stack.
4538 char* buffer = buffer_; 4538 char* buffer = buffer_;
4539 int last_character = 4539 int last_character =
4540 sizeof(Char) == 1 ? Utf16::kNoPreviousCharacter : last_character_; 4540 sizeof(Char) == 1 ? Utf16::kNoPreviousCharacter : last_character_;
4541 int i = 0; 4541 int i = 0;
4542 // Do a fast loop where there is no exit capacity check. 4542 // Do a fast loop where there is no exit capacity check.
4543 while (true) { 4543 while (true) {
4544 int fast_length; 4544 int fast_length;
4545 if (skip_capacity_check_) { 4545 if (skip_capacity_check_) {
4546 fast_length = length; 4546 fast_length = length;
4547 } else { 4547 } else {
4548 int remaining_capacity = capacity_ - static_cast<int>(buffer - start_); 4548 int remaining_capacity = capacity_ - static_cast<int>(buffer - start_);
4549 // Need enough space to write everything but one character. 4549 // Need enough space to write everything but one character.
4550 STATIC_ASSERT(Utf16::kMaxExtraUtf8BytesForOneUtf16CodeUnit == 3); 4550 STATIC_ASSERT(Utf16::kMaxExtraUtf8BytesForOneUtf16CodeUnit == 3);
4551 int max_size_per_char = sizeof(Char) == 1 ? 2 : 3; 4551 int max_size_per_char = sizeof(Char) == 1 ? 2 : 3;
4552 int writable_length = 4552 int writable_length =
4553 (remaining_capacity - max_size_per_char)/max_size_per_char; 4553 (remaining_capacity - max_size_per_char)/max_size_per_char;
4554 // Need to drop into slow loop. 4554 // Need to drop into slow loop.
4555 if (writable_length <= 0) break; 4555 if (writable_length <= 0) break;
4556 fast_length = i + writable_length; 4556 fast_length = i + writable_length;
4557 if (fast_length > length) fast_length = length; 4557 if (fast_length > length) fast_length = length;
4558 } 4558 }
4559 // Write the characters to the stream. 4559 // Write the characters to the stream.
4560 if (sizeof(Char) == 1) { 4560 if (sizeof(Char) == 1) {
4561 for (; i < fast_length; i++) { 4561 for (; i < fast_length; i++) {
4562 buffer += 4562 buffer +=
4563 Utf8::EncodeOneByte(buffer, static_cast<uint8_t>(*chars++)); 4563 Utf8::EncodeOneByte(buffer, static_cast<uint8_t>(*chars++));
4564 ASSERT(capacity_ == -1 || (buffer - start_) <= capacity_); 4564 DCHECK(capacity_ == -1 || (buffer - start_) <= capacity_);
4565 } 4565 }
4566 } else { 4566 } else {
4567 for (; i < fast_length; i++) { 4567 for (; i < fast_length; i++) {
4568 uint16_t character = *chars++; 4568 uint16_t character = *chars++;
4569 buffer += Utf8::Encode(buffer, 4569 buffer += Utf8::Encode(buffer,
4570 character, 4570 character,
4571 last_character, 4571 last_character,
4572 replace_invalid_utf8_); 4572 replace_invalid_utf8_);
4573 last_character = character; 4573 last_character = character;
4574 ASSERT(capacity_ == -1 || (buffer - start_) <= capacity_); 4574 DCHECK(capacity_ == -1 || (buffer - start_) <= capacity_);
4575 } 4575 }
4576 } 4576 }
4577 // Array is fully written. Exit. 4577 // Array is fully written. Exit.
4578 if (fast_length == length) { 4578 if (fast_length == length) {
4579 // Write state back out to object. 4579 // Write state back out to object.
4580 last_character_ = last_character; 4580 last_character_ = last_character;
4581 buffer_ = buffer; 4581 buffer_ = buffer;
4582 utf16_chars_read_ += length; 4582 utf16_chars_read_ += length;
4583 return; 4583 return;
4584 } 4584 }
4585 } 4585 }
4586 ASSERT(!skip_capacity_check_); 4586 DCHECK(!skip_capacity_check_);
4587 // Slow loop. Must check capacity on each iteration. 4587 // Slow loop. Must check capacity on each iteration.
4588 int remaining_capacity = capacity_ - static_cast<int>(buffer - start_); 4588 int remaining_capacity = capacity_ - static_cast<int>(buffer - start_);
4589 ASSERT(remaining_capacity >= 0); 4589 DCHECK(remaining_capacity >= 0);
4590 for (; i < length && remaining_capacity > 0; i++) { 4590 for (; i < length && remaining_capacity > 0; i++) {
4591 uint16_t character = *chars++; 4591 uint16_t character = *chars++;
4592 // remaining_capacity is <= 3 bytes at this point, so we do not write out 4592 // remaining_capacity is <= 3 bytes at this point, so we do not write out
4593 // an umatched lead surrogate. 4593 // an umatched lead surrogate.
4594 if (replace_invalid_utf8_ && Utf16::IsLeadSurrogate(character)) { 4594 if (replace_invalid_utf8_ && Utf16::IsLeadSurrogate(character)) {
4595 early_termination_ = true; 4595 early_termination_ = true;
4596 break; 4596 break;
4597 } 4597 }
4598 int written = WriteEndCharacter(character, 4598 int written = WriteEndCharacter(character,
4599 last_character, 4599 last_character,
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
4726 4726
4727 template<typename CharType> 4727 template<typename CharType>
4728 static inline int WriteHelper(const String* string, 4728 static inline int WriteHelper(const String* string,
4729 CharType* buffer, 4729 CharType* buffer,
4730 int start, 4730 int start,
4731 int length, 4731 int length,
4732 int options) { 4732 int options) {
4733 i::Isolate* isolate = Utils::OpenHandle(string)->GetIsolate(); 4733 i::Isolate* isolate = Utils::OpenHandle(string)->GetIsolate();
4734 LOG_API(isolate, "String::Write"); 4734 LOG_API(isolate, "String::Write");
4735 ENTER_V8(isolate); 4735 ENTER_V8(isolate);
4736 ASSERT(start >= 0 && length >= -1); 4736 DCHECK(start >= 0 && length >= -1);
4737 i::Handle<i::String> str = Utils::OpenHandle(string); 4737 i::Handle<i::String> str = Utils::OpenHandle(string);
4738 isolate->string_tracker()->RecordWrite(str); 4738 isolate->string_tracker()->RecordWrite(str);
4739 if (options & String::HINT_MANY_WRITES_EXPECTED) { 4739 if (options & String::HINT_MANY_WRITES_EXPECTED) {
4740 // Flatten the string for efficiency. This applies whether we are 4740 // Flatten the string for efficiency. This applies whether we are
4741 // using StringCharacterStream or Get(i) to access the characters. 4741 // using StringCharacterStream or Get(i) to access the characters.
4742 str = i::String::Flatten(str); 4742 str = i::String::Flatten(str);
4743 } 4743 }
4744 int end = start + length; 4744 int end = start + length;
4745 if ((length == -1) || (length > str->length() - start) ) 4745 if ((length == -1) || (length > str->length() - start) )
4746 end = str->length(); 4746 end = str->length();
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
4911 return Utils::ToLocal(value); 4911 return Utils::ToLocal(value);
4912 } 4912 }
4913 4913
4914 4914
4915 void v8::Object::SetInternalField(int index, v8::Handle<Value> value) { 4915 void v8::Object::SetInternalField(int index, v8::Handle<Value> value) {
4916 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 4916 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
4917 const char* location = "v8::Object::SetInternalField()"; 4917 const char* location = "v8::Object::SetInternalField()";
4918 if (!InternalFieldOK(obj, index, location)) return; 4918 if (!InternalFieldOK(obj, index, location)) return;
4919 i::Handle<i::Object> val = Utils::OpenHandle(*value); 4919 i::Handle<i::Object> val = Utils::OpenHandle(*value);
4920 obj->SetInternalField(index, *val); 4920 obj->SetInternalField(index, *val);
4921 ASSERT_EQ(value, GetInternalField(index)); 4921 DCHECK_EQ(value, GetInternalField(index));
4922 } 4922 }
4923 4923
4924 4924
4925 void* v8::Object::SlowGetAlignedPointerFromInternalField(int index) { 4925 void* v8::Object::SlowGetAlignedPointerFromInternalField(int index) {
4926 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 4926 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
4927 const char* location = "v8::Object::GetAlignedPointerFromInternalField()"; 4927 const char* location = "v8::Object::GetAlignedPointerFromInternalField()";
4928 if (!InternalFieldOK(obj, index, location)) return NULL; 4928 if (!InternalFieldOK(obj, index, location)) return NULL;
4929 return DecodeSmiToAligned(obj->GetInternalField(index), location); 4929 return DecodeSmiToAligned(obj->GetInternalField(index), location);
4930 } 4930 }
4931 4931
4932 4932
4933 void v8::Object::SetAlignedPointerInInternalField(int index, void* value) { 4933 void v8::Object::SetAlignedPointerInInternalField(int index, void* value) {
4934 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 4934 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
4935 const char* location = "v8::Object::SetAlignedPointerInInternalField()"; 4935 const char* location = "v8::Object::SetAlignedPointerInInternalField()";
4936 if (!InternalFieldOK(obj, index, location)) return; 4936 if (!InternalFieldOK(obj, index, location)) return;
4937 obj->SetInternalField(index, EncodeAlignedAsSmi(value, location)); 4937 obj->SetInternalField(index, EncodeAlignedAsSmi(value, location));
4938 ASSERT_EQ(value, GetAlignedPointerFromInternalField(index)); 4938 DCHECK_EQ(value, GetAlignedPointerFromInternalField(index));
4939 } 4939 }
4940 4940
4941 4941
4942 static void* ExternalValue(i::Object* obj) { 4942 static void* ExternalValue(i::Object* obj) {
4943 // Obscure semantics for undefined, but somehow checked in our unit tests... 4943 // Obscure semantics for undefined, but somehow checked in our unit tests...
4944 if (obj->IsUndefined()) return NULL; 4944 if (obj->IsUndefined()) return NULL;
4945 i::Object* foreign = i::JSObject::cast(obj)->GetInternalField(0); 4945 i::Object* foreign = i::JSObject::cast(obj)->GetInternalField(0);
4946 return i::Foreign::cast(foreign)->foreign_address(); 4946 return i::Foreign::cast(foreign)->foreign_address();
4947 } 4947 }
4948 4948
(...skipping 26 matching lines...) Expand all
4975 4975
4976 4976
4977 void v8::V8::SetReturnAddressLocationResolver( 4977 void v8::V8::SetReturnAddressLocationResolver(
4978 ReturnAddressLocationResolver return_address_resolver) { 4978 ReturnAddressLocationResolver return_address_resolver) {
4979 i::V8::SetReturnAddressLocationResolver(return_address_resolver); 4979 i::V8::SetReturnAddressLocationResolver(return_address_resolver);
4980 } 4980 }
4981 4981
4982 4982
4983 bool v8::V8::SetFunctionEntryHook(Isolate* ext_isolate, 4983 bool v8::V8::SetFunctionEntryHook(Isolate* ext_isolate,
4984 FunctionEntryHook entry_hook) { 4984 FunctionEntryHook entry_hook) {
4985 ASSERT(ext_isolate != NULL); 4985 DCHECK(ext_isolate != NULL);
4986 ASSERT(entry_hook != NULL); 4986 DCHECK(entry_hook != NULL);
4987 4987
4988 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(ext_isolate); 4988 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(ext_isolate);
4989 4989
4990 // The entry hook can only be set before the Isolate is initialized, as 4990 // The entry hook can only be set before the Isolate is initialized, as
4991 // otherwise the Isolate's code stubs generated at initialization won't 4991 // otherwise the Isolate's code stubs generated at initialization won't
4992 // contain entry hooks. 4992 // contain entry hooks.
4993 if (isolate->IsInitialized()) 4993 if (isolate->IsInitialized())
4994 return false; 4994 return false;
4995 4995
4996 // Setting an entry hook is a one-way operation, once set, it cannot be 4996 // Setting an entry hook is a one-way operation, once set, it cannot be
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
5062 i::DisallowHeapAllocation no_allocation; 5062 i::DisallowHeapAllocation no_allocation;
5063 5063
5064 VisitorAdapter visitor_adapter(visitor); 5064 VisitorAdapter visitor_adapter(visitor);
5065 isolate->global_handles()->IterateAllRootsWithClassIds(&visitor_adapter); 5065 isolate->global_handles()->IterateAllRootsWithClassIds(&visitor_adapter);
5066 } 5066 }
5067 5067
5068 5068
5069 void v8::V8::VisitHandlesForPartialDependence( 5069 void v8::V8::VisitHandlesForPartialDependence(
5070 Isolate* exported_isolate, PersistentHandleVisitor* visitor) { 5070 Isolate* exported_isolate, PersistentHandleVisitor* visitor) {
5071 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(exported_isolate); 5071 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(exported_isolate);
5072 ASSERT(isolate == i::Isolate::Current()); 5072 DCHECK(isolate == i::Isolate::Current());
5073 i::DisallowHeapAllocation no_allocation; 5073 i::DisallowHeapAllocation no_allocation;
5074 5074
5075 VisitorAdapter visitor_adapter(visitor); 5075 VisitorAdapter visitor_adapter(visitor);
5076 isolate->global_handles()->IterateAllRootsInNewSpaceWithClassIds( 5076 isolate->global_handles()->IterateAllRootsInNewSpaceWithClassIds(
5077 &visitor_adapter); 5077 &visitor_adapter);
5078 } 5078 }
5079 5079
5080 5080
5081 bool v8::V8::InitializeICU(const char* icu_data_file) { 5081 bool v8::V8::InitializeICU(const char* icu_data_file) {
5082 return i::InitializeICU(icu_data_file); 5082 return i::InitializeICU(icu_data_file);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
5134 i::MaybeHandle<i::JSGlobalProxy> maybe_proxy; 5134 i::MaybeHandle<i::JSGlobalProxy> maybe_proxy;
5135 if (!proxy.is_null()) { 5135 if (!proxy.is_null()) {
5136 maybe_proxy = i::Handle<i::JSGlobalProxy>::cast(proxy); 5136 maybe_proxy = i::Handle<i::JSGlobalProxy>::cast(proxy);
5137 } 5137 }
5138 // Create the environment. 5138 // Create the environment.
5139 env = isolate->bootstrapper()->CreateEnvironment( 5139 env = isolate->bootstrapper()->CreateEnvironment(
5140 maybe_proxy, proxy_template, extensions); 5140 maybe_proxy, proxy_template, extensions);
5141 5141
5142 // Restore the access check info on the global template. 5142 // Restore the access check info on the global template.
5143 if (!global_template.IsEmpty()) { 5143 if (!global_template.IsEmpty()) {
5144 ASSERT(!global_constructor.is_null()); 5144 DCHECK(!global_constructor.is_null());
5145 ASSERT(!proxy_constructor.is_null()); 5145 DCHECK(!proxy_constructor.is_null());
5146 global_constructor->set_access_check_info( 5146 global_constructor->set_access_check_info(
5147 proxy_constructor->access_check_info()); 5147 proxy_constructor->access_check_info());
5148 global_constructor->set_needs_access_check( 5148 global_constructor->set_needs_access_check(
5149 proxy_constructor->needs_access_check()); 5149 proxy_constructor->needs_access_check());
5150 } 5150 }
5151 } 5151 }
5152 // Leave V8. 5152 // Leave V8.
5153 5153
5154 return env; 5154 return env;
5155 } 5155 }
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
5482 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { 5482 if (isolate->string_tracker()->IsFreshUnusedString(obj)) {
5483 return false; 5483 return false;
5484 } 5484 }
5485 if (isolate->heap()->IsInGCPostProcessing()) { 5485 if (isolate->heap()->IsInGCPostProcessing()) {
5486 return false; 5486 return false;
5487 } 5487 }
5488 CHECK(resource && resource->data()); 5488 CHECK(resource && resource->data());
5489 5489
5490 bool result = obj->MakeExternal(resource); 5490 bool result = obj->MakeExternal(resource);
5491 if (result) { 5491 if (result) {
5492 ASSERT(obj->IsExternalString()); 5492 DCHECK(obj->IsExternalString());
5493 isolate->heap()->external_string_table()->AddString(*obj); 5493 isolate->heap()->external_string_table()->AddString(*obj);
5494 } 5494 }
5495 return result; 5495 return result;
5496 } 5496 }
5497 5497
5498 5498
5499 Local<String> v8::String::NewExternal( 5499 Local<String> v8::String::NewExternal(
5500 Isolate* isolate, 5500 Isolate* isolate,
5501 v8::String::ExternalAsciiStringResource* resource) { 5501 v8::String::ExternalAsciiStringResource* resource) {
5502 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 5502 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
(...skipping 19 matching lines...) Expand all
5522 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { 5522 if (isolate->string_tracker()->IsFreshUnusedString(obj)) {
5523 return false; 5523 return false;
5524 } 5524 }
5525 if (isolate->heap()->IsInGCPostProcessing()) { 5525 if (isolate->heap()->IsInGCPostProcessing()) {
5526 return false; 5526 return false;
5527 } 5527 }
5528 CHECK(resource && resource->data()); 5528 CHECK(resource && resource->data());
5529 5529
5530 bool result = obj->MakeExternal(resource); 5530 bool result = obj->MakeExternal(resource);
5531 if (result) { 5531 if (result) {
5532 ASSERT(obj->IsExternalString()); 5532 DCHECK(obj->IsExternalString());
5533 isolate->heap()->external_string_table()->AddString(*obj); 5533 isolate->heap()->external_string_table()->AddString(*obj);
5534 } 5534 }
5535 return result; 5535 return result;
5536 } 5536 }
5537 5537
5538 5538
5539 bool v8::String::CanMakeExternal() { 5539 bool v8::String::CanMakeExternal() {
5540 if (!internal::FLAG_clever_optimizations) return false; 5540 if (!internal::FLAG_clever_optimizations) return false;
5541 i::Handle<i::String> obj = Utils::OpenHandle(this); 5541 i::Handle<i::String> obj = Utils::OpenHandle(this);
5542 i::Isolate* isolate = obj->GetIsolate(); 5542 i::Isolate* isolate = obj->GetIsolate();
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
5690 5690
5691 i_isolate->date_cache()->ResetDateCache(); 5691 i_isolate->date_cache()->ResetDateCache();
5692 5692
5693 if (!i_isolate->eternal_handles()->Exists( 5693 if (!i_isolate->eternal_handles()->Exists(
5694 i::EternalHandles::DATE_CACHE_VERSION)) { 5694 i::EternalHandles::DATE_CACHE_VERSION)) {
5695 return; 5695 return;
5696 } 5696 }
5697 i::Handle<i::FixedArray> date_cache_version = 5697 i::Handle<i::FixedArray> date_cache_version =
5698 i::Handle<i::FixedArray>::cast(i_isolate->eternal_handles()->GetSingleton( 5698 i::Handle<i::FixedArray>::cast(i_isolate->eternal_handles()->GetSingleton(
5699 i::EternalHandles::DATE_CACHE_VERSION)); 5699 i::EternalHandles::DATE_CACHE_VERSION));
5700 ASSERT_EQ(1, date_cache_version->length()); 5700 DCHECK_EQ(1, date_cache_version->length());
5701 CHECK(date_cache_version->get(0)->IsSmi()); 5701 CHECK(date_cache_version->get(0)->IsSmi());
5702 date_cache_version->set( 5702 date_cache_version->set(
5703 0, 5703 0,
5704 i::Smi::FromInt(i::Smi::cast(date_cache_version->get(0))->value() + 1)); 5704 i::Smi::FromInt(i::Smi::cast(date_cache_version->get(0))->value() + 1));
5705 } 5705 }
5706 5706
5707 5707
5708 static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) { 5708 static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) {
5709 i::Isolate* isolate = i::Isolate::Current(); 5709 i::Isolate* isolate = i::Isolate::Current();
5710 uint8_t flags_buf[3]; 5710 uint8_t flags_buf[3];
5711 int num_flags = 0; 5711 int num_flags = 0;
5712 if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g'; 5712 if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g';
5713 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm'; 5713 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm';
5714 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; 5714 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i';
5715 ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf))); 5715 DCHECK(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf)));
5716 return isolate->factory()->InternalizeOneByteString( 5716 return isolate->factory()->InternalizeOneByteString(
5717 i::Vector<const uint8_t>(flags_buf, num_flags)); 5717 i::Vector<const uint8_t>(flags_buf, num_flags));
5718 } 5718 }
5719 5719
5720 5720
5721 Local<v8::RegExp> v8::RegExp::New(Handle<String> pattern, 5721 Local<v8::RegExp> v8::RegExp::New(Handle<String> pattern,
5722 Flags flags) { 5722 Flags flags) {
5723 i::Isolate* isolate = Utils::OpenHandle(*pattern)->GetIsolate(); 5723 i::Isolate* isolate = Utils::OpenHandle(*pattern)->GetIsolate();
5724 EnsureInitializedForIsolate(isolate, "v8::RegExp::New()"); 5724 EnsureInitializedForIsolate(isolate, "v8::RegExp::New()");
5725 LOG_API(isolate, "RegExp::New"); 5725 LOG_API(isolate, "RegExp::New");
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
5999 i::Runtime::SetupArrayBuffer(i_isolate, obj, true, data, byte_length); 5999 i::Runtime::SetupArrayBuffer(i_isolate, obj, true, data, byte_length);
6000 return Utils::ToLocal(obj); 6000 return Utils::ToLocal(obj);
6001 } 6001 }
6002 6002
6003 6003
6004 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() { 6004 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() {
6005 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); 6005 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this);
6006 i::Handle<i::JSArrayBuffer> buffer; 6006 i::Handle<i::JSArrayBuffer> buffer;
6007 if (obj->IsJSDataView()) { 6007 if (obj->IsJSDataView()) {
6008 i::Handle<i::JSDataView> data_view(i::JSDataView::cast(*obj)); 6008 i::Handle<i::JSDataView> data_view(i::JSDataView::cast(*obj));
6009 ASSERT(data_view->buffer()->IsJSArrayBuffer()); 6009 DCHECK(data_view->buffer()->IsJSArrayBuffer());
6010 buffer = i::handle(i::JSArrayBuffer::cast(data_view->buffer())); 6010 buffer = i::handle(i::JSArrayBuffer::cast(data_view->buffer()));
6011 } else { 6011 } else {
6012 ASSERT(obj->IsJSTypedArray()); 6012 DCHECK(obj->IsJSTypedArray());
6013 buffer = i::JSTypedArray::cast(*obj)->GetBuffer(); 6013 buffer = i::JSTypedArray::cast(*obj)->GetBuffer();
6014 } 6014 }
6015 return Utils::ToLocal(buffer); 6015 return Utils::ToLocal(buffer);
6016 } 6016 }
6017 6017
6018 6018
6019 size_t v8::ArrayBufferView::ByteOffset() { 6019 size_t v8::ArrayBufferView::ByteOffset() {
6020 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); 6020 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this);
6021 return static_cast<size_t>(obj->byte_offset()->Number()); 6021 return static_cast<size_t>(obj->byte_offset()->Number());
6022 } 6022 }
(...skipping 10 matching lines...) Expand all
6033 return static_cast<size_t>(obj->length()->Number()); 6033 return static_cast<size_t>(obj->length()->Number());
6034 } 6034 }
6035 6035
6036 6036
6037 static inline void SetupArrayBufferView( 6037 static inline void SetupArrayBufferView(
6038 i::Isolate* isolate, 6038 i::Isolate* isolate,
6039 i::Handle<i::JSArrayBufferView> obj, 6039 i::Handle<i::JSArrayBufferView> obj,
6040 i::Handle<i::JSArrayBuffer> buffer, 6040 i::Handle<i::JSArrayBuffer> buffer,
6041 size_t byte_offset, 6041 size_t byte_offset,
6042 size_t byte_length) { 6042 size_t byte_length) {
6043 ASSERT(byte_offset + byte_length <= 6043 DCHECK(byte_offset + byte_length <=
6044 static_cast<size_t>(buffer->byte_length()->Number())); 6044 static_cast<size_t>(buffer->byte_length()->Number()));
6045 6045
6046 obj->set_buffer(*buffer); 6046 obj->set_buffer(*buffer);
6047 6047
6048 obj->set_weak_next(buffer->weak_first_view()); 6048 obj->set_weak_next(buffer->weak_first_view());
6049 buffer->set_weak_first_view(*obj); 6049 buffer->set_weak_first_view(*obj);
6050 6050
6051 i::Handle<i::Object> byte_offset_object = 6051 i::Handle<i::Object> byte_offset_object =
6052 isolate->factory()->NewNumberFromSize(byte_offset); 6052 isolate->factory()->NewNumberFromSize(byte_offset);
6053 obj->set_byte_offset(*byte_offset_object); 6053 obj->set_byte_offset(*byte_offset_object);
6054 6054
6055 i::Handle<i::Object> byte_length_object = 6055 i::Handle<i::Object> byte_length_object =
6056 isolate->factory()->NewNumberFromSize(byte_length); 6056 isolate->factory()->NewNumberFromSize(byte_length);
6057 obj->set_byte_length(*byte_length_object); 6057 obj->set_byte_length(*byte_length_object);
6058 } 6058 }
6059 6059
6060 template<typename ElementType, 6060 template<typename ElementType,
6061 ExternalArrayType array_type, 6061 ExternalArrayType array_type,
6062 i::ElementsKind elements_kind> 6062 i::ElementsKind elements_kind>
6063 i::Handle<i::JSTypedArray> NewTypedArray( 6063 i::Handle<i::JSTypedArray> NewTypedArray(
6064 i::Isolate* isolate, 6064 i::Isolate* isolate,
6065 Handle<ArrayBuffer> array_buffer, size_t byte_offset, size_t length) { 6065 Handle<ArrayBuffer> array_buffer, size_t byte_offset, size_t length) {
6066 i::Handle<i::JSTypedArray> obj = 6066 i::Handle<i::JSTypedArray> obj =
6067 isolate->factory()->NewJSTypedArray(array_type); 6067 isolate->factory()->NewJSTypedArray(array_type);
6068 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer); 6068 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer);
6069 6069
6070 ASSERT(byte_offset % sizeof(ElementType) == 0); 6070 DCHECK(byte_offset % sizeof(ElementType) == 0);
6071 6071
6072 CHECK(length <= (std::numeric_limits<size_t>::max() / sizeof(ElementType))); 6072 CHECK(length <= (std::numeric_limits<size_t>::max() / sizeof(ElementType)));
6073 CHECK(length <= static_cast<size_t>(i::Smi::kMaxValue)); 6073 CHECK(length <= static_cast<size_t>(i::Smi::kMaxValue));
6074 size_t byte_length = length * sizeof(ElementType); 6074 size_t byte_length = length * sizeof(ElementType);
6075 SetupArrayBufferView( 6075 SetupArrayBufferView(
6076 isolate, obj, buffer, byte_offset, byte_length); 6076 isolate, obj, buffer, byte_offset, byte_length);
6077 6077
6078 i::Handle<i::Object> length_object = 6078 i::Handle<i::Object> length_object =
6079 isolate->factory()->NewNumberFromSize(length); 6079 isolate->factory()->NewNumberFromSize(length);
6080 obj->set_length(*length_object); 6080 obj->set_length(*length_object);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
6145 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6145 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6146 i::Handle<i::String> i_name = Utils::OpenHandle(*name); 6146 i::Handle<i::String> i_name = Utils::OpenHandle(*name);
6147 i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry(); 6147 i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry();
6148 i::Handle<i::String> part = i_isolate->factory()->for_string(); 6148 i::Handle<i::String> part = i_isolate->factory()->for_string();
6149 i::Handle<i::JSObject> symbols = 6149 i::Handle<i::JSObject> symbols =
6150 i::Handle<i::JSObject>::cast( 6150 i::Handle<i::JSObject>::cast(
6151 i::Object::GetPropertyOrElement(registry, part).ToHandleChecked()); 6151 i::Object::GetPropertyOrElement(registry, part).ToHandleChecked());
6152 i::Handle<i::Object> symbol = 6152 i::Handle<i::Object> symbol =
6153 i::Object::GetPropertyOrElement(symbols, i_name).ToHandleChecked(); 6153 i::Object::GetPropertyOrElement(symbols, i_name).ToHandleChecked();
6154 if (!symbol->IsSymbol()) { 6154 if (!symbol->IsSymbol()) {
6155 ASSERT(symbol->IsUndefined()); 6155 DCHECK(symbol->IsUndefined());
6156 symbol = i_isolate->factory()->NewSymbol(); 6156 symbol = i_isolate->factory()->NewSymbol();
6157 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name); 6157 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name);
6158 i::JSObject::SetProperty(symbols, i_name, symbol, i::STRICT).Assert(); 6158 i::JSObject::SetProperty(symbols, i_name, symbol, i::STRICT).Assert();
6159 } 6159 }
6160 return Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol)); 6160 return Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol));
6161 } 6161 }
6162 6162
6163 6163
6164 Local<Symbol> v8::Symbol::ForApi(Isolate* isolate, Local<String> name) { 6164 Local<Symbol> v8::Symbol::ForApi(Isolate* isolate, Local<String> name) {
6165 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6165 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6166 i::Handle<i::String> i_name = Utils::OpenHandle(*name); 6166 i::Handle<i::String> i_name = Utils::OpenHandle(*name);
6167 i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry(); 6167 i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry();
6168 i::Handle<i::String> part = i_isolate->factory()->for_api_string(); 6168 i::Handle<i::String> part = i_isolate->factory()->for_api_string();
6169 i::Handle<i::JSObject> symbols = 6169 i::Handle<i::JSObject> symbols =
6170 i::Handle<i::JSObject>::cast( 6170 i::Handle<i::JSObject>::cast(
6171 i::Object::GetPropertyOrElement(registry, part).ToHandleChecked()); 6171 i::Object::GetPropertyOrElement(registry, part).ToHandleChecked());
6172 i::Handle<i::Object> symbol = 6172 i::Handle<i::Object> symbol =
6173 i::Object::GetPropertyOrElement(symbols, i_name).ToHandleChecked(); 6173 i::Object::GetPropertyOrElement(symbols, i_name).ToHandleChecked();
6174 if (!symbol->IsSymbol()) { 6174 if (!symbol->IsSymbol()) {
6175 ASSERT(symbol->IsUndefined()); 6175 DCHECK(symbol->IsUndefined());
6176 symbol = i_isolate->factory()->NewSymbol(); 6176 symbol = i_isolate->factory()->NewSymbol();
6177 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name); 6177 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name);
6178 i::JSObject::SetProperty(symbols, i_name, symbol, i::STRICT).Assert(); 6178 i::JSObject::SetProperty(symbols, i_name, symbol, i::STRICT).Assert();
6179 } 6179 }
6180 return Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol)); 6180 return Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol));
6181 } 6181 }
6182 6182
6183 6183
6184 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) { 6184 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) {
6185 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6185 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
(...skipping 11 matching lines...) Expand all
6197 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6197 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6198 i::Handle<i::String> i_name = Utils::OpenHandle(*name); 6198 i::Handle<i::String> i_name = Utils::OpenHandle(*name);
6199 i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry(); 6199 i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry();
6200 i::Handle<i::String> part = i_isolate->factory()->private_api_string(); 6200 i::Handle<i::String> part = i_isolate->factory()->private_api_string();
6201 i::Handle<i::JSObject> privates = 6201 i::Handle<i::JSObject> privates =
6202 i::Handle<i::JSObject>::cast( 6202 i::Handle<i::JSObject>::cast(
6203 i::Object::GetPropertyOrElement(registry, part).ToHandleChecked()); 6203 i::Object::GetPropertyOrElement(registry, part).ToHandleChecked());
6204 i::Handle<i::Object> symbol = 6204 i::Handle<i::Object> symbol =
6205 i::Object::GetPropertyOrElement(privates, i_name).ToHandleChecked(); 6205 i::Object::GetPropertyOrElement(privates, i_name).ToHandleChecked();
6206 if (!symbol->IsSymbol()) { 6206 if (!symbol->IsSymbol()) {
6207 ASSERT(symbol->IsUndefined()); 6207 DCHECK(symbol->IsUndefined());
6208 symbol = i_isolate->factory()->NewPrivateSymbol(); 6208 symbol = i_isolate->factory()->NewPrivateSymbol();
6209 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name); 6209 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name);
6210 i::JSObject::SetProperty(privates, i_name, symbol, i::STRICT).Assert(); 6210 i::JSObject::SetProperty(privates, i_name, symbol, i::STRICT).Assert();
6211 } 6211 }
6212 Local<Symbol> result = Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol)); 6212 Local<Symbol> result = Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol));
6213 return v8::Handle<Private>(reinterpret_cast<Private*>(*result)); 6213 return v8::Handle<Private>(reinterpret_cast<Private*>(*result));
6214 } 6214 }
6215 6215
6216 6216
6217 Local<Number> v8::Number::New(Isolate* isolate, double value) { 6217 Local<Number> v8::Number::New(Isolate* isolate, double value) {
6218 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); 6218 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
6219 ASSERT(internal_isolate->IsInitialized()); 6219 DCHECK(internal_isolate->IsInitialized());
6220 if (std::isnan(value)) { 6220 if (std::isnan(value)) {
6221 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. 6221 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs.
6222 value = base::OS::nan_value(); 6222 value = base::OS::nan_value();
6223 } 6223 }
6224 ENTER_V8(internal_isolate); 6224 ENTER_V8(internal_isolate);
6225 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); 6225 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value);
6226 return Utils::NumberToLocal(result); 6226 return Utils::NumberToLocal(result);
6227 } 6227 }
6228 6228
6229 6229
6230 Local<Integer> v8::Integer::New(Isolate* isolate, int32_t value) { 6230 Local<Integer> v8::Integer::New(Isolate* isolate, int32_t value) {
6231 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); 6231 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
6232 ASSERT(internal_isolate->IsInitialized()); 6232 DCHECK(internal_isolate->IsInitialized());
6233 if (i::Smi::IsValid(value)) { 6233 if (i::Smi::IsValid(value)) {
6234 return Utils::IntegerToLocal(i::Handle<i::Object>(i::Smi::FromInt(value), 6234 return Utils::IntegerToLocal(i::Handle<i::Object>(i::Smi::FromInt(value),
6235 internal_isolate)); 6235 internal_isolate));
6236 } 6236 }
6237 ENTER_V8(internal_isolate); 6237 ENTER_V8(internal_isolate);
6238 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); 6238 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value);
6239 return Utils::IntegerToLocal(result); 6239 return Utils::IntegerToLocal(result);
6240 } 6240 }
6241 6241
6242 6242
6243 Local<Integer> v8::Integer::NewFromUnsigned(Isolate* isolate, uint32_t value) { 6243 Local<Integer> v8::Integer::NewFromUnsigned(Isolate* isolate, uint32_t value) {
6244 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); 6244 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
6245 ASSERT(internal_isolate->IsInitialized()); 6245 DCHECK(internal_isolate->IsInitialized());
6246 bool fits_into_int32_t = (value & (1 << 31)) == 0; 6246 bool fits_into_int32_t = (value & (1 << 31)) == 0;
6247 if (fits_into_int32_t) { 6247 if (fits_into_int32_t) {
6248 return Integer::New(isolate, static_cast<int32_t>(value)); 6248 return Integer::New(isolate, static_cast<int32_t>(value));
6249 } 6249 }
6250 ENTER_V8(internal_isolate); 6250 ENTER_V8(internal_isolate);
6251 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); 6251 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value);
6252 return Utils::IntegerToLocal(result); 6252 return Utils::IntegerToLocal(result);
6253 } 6253 }
6254 6254
6255 6255
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
6510 } 6510 }
6511 6511
6512 6512
6513 void Isolate::RequestGarbageCollectionForTesting(GarbageCollectionType type) { 6513 void Isolate::RequestGarbageCollectionForTesting(GarbageCollectionType type) {
6514 CHECK(i::FLAG_expose_gc); 6514 CHECK(i::FLAG_expose_gc);
6515 if (type == kMinorGarbageCollection) { 6515 if (type == kMinorGarbageCollection) {
6516 reinterpret_cast<i::Isolate*>(this)->heap()->CollectGarbage( 6516 reinterpret_cast<i::Isolate*>(this)->heap()->CollectGarbage(
6517 i::NEW_SPACE, "Isolate::RequestGarbageCollection", 6517 i::NEW_SPACE, "Isolate::RequestGarbageCollection",
6518 kGCCallbackFlagForced); 6518 kGCCallbackFlagForced);
6519 } else { 6519 } else {
6520 ASSERT_EQ(kFullGarbageCollection, type); 6520 DCHECK_EQ(kFullGarbageCollection, type);
6521 reinterpret_cast<i::Isolate*>(this)->heap()->CollectAllGarbage( 6521 reinterpret_cast<i::Isolate*>(this)->heap()->CollectAllGarbage(
6522 i::Heap::kAbortIncrementalMarkingMask, 6522 i::Heap::kAbortIncrementalMarkingMask,
6523 "Isolate::RequestGarbageCollection", kGCCallbackFlagForced); 6523 "Isolate::RequestGarbageCollection", kGCCallbackFlagForced);
6524 } 6524 }
6525 } 6525 }
6526 6526
6527 6527
6528 Isolate* Isolate::GetCurrent() { 6528 Isolate* Isolate::GetCurrent() {
6529 i::Isolate* isolate = i::Isolate::Current(); 6529 i::Isolate* isolate = i::Isolate::Current();
6530 return reinterpret_cast<Isolate*>(isolate); 6530 return reinterpret_cast<Isolate*>(isolate);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
6562 6562
6563 Isolate::DisallowJavascriptExecutionScope::DisallowJavascriptExecutionScope( 6563 Isolate::DisallowJavascriptExecutionScope::DisallowJavascriptExecutionScope(
6564 Isolate* isolate, 6564 Isolate* isolate,
6565 Isolate::DisallowJavascriptExecutionScope::OnFailure on_failure) 6565 Isolate::DisallowJavascriptExecutionScope::OnFailure on_failure)
6566 : on_failure_(on_failure) { 6566 : on_failure_(on_failure) {
6567 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6567 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6568 if (on_failure_ == CRASH_ON_FAILURE) { 6568 if (on_failure_ == CRASH_ON_FAILURE) {
6569 internal_ = reinterpret_cast<void*>( 6569 internal_ = reinterpret_cast<void*>(
6570 new i::DisallowJavascriptExecution(i_isolate)); 6570 new i::DisallowJavascriptExecution(i_isolate));
6571 } else { 6571 } else {
6572 ASSERT_EQ(THROW_ON_FAILURE, on_failure); 6572 DCHECK_EQ(THROW_ON_FAILURE, on_failure);
6573 internal_ = reinterpret_cast<void*>( 6573 internal_ = reinterpret_cast<void*>(
6574 new i::ThrowOnJavascriptExecution(i_isolate)); 6574 new i::ThrowOnJavascriptExecution(i_isolate));
6575 } 6575 }
6576 } 6576 }
6577 6577
6578 6578
6579 Isolate::DisallowJavascriptExecutionScope::~DisallowJavascriptExecutionScope() { 6579 Isolate::DisallowJavascriptExecutionScope::~DisallowJavascriptExecutionScope() {
6580 if (on_failure_ == CRASH_ON_FAILURE) { 6580 if (on_failure_ == CRASH_ON_FAILURE) {
6581 delete reinterpret_cast<i::DisallowJavascriptExecution*>(internal_); 6581 delete reinterpret_cast<i::DisallowJavascriptExecution*>(internal_);
6582 } else { 6582 } else {
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
7064 const CpuProfileNode* CpuProfileNode::GetChild(int index) const { 7064 const CpuProfileNode* CpuProfileNode::GetChild(int index) const {
7065 const i::ProfileNode* child = 7065 const i::ProfileNode* child =
7066 reinterpret_cast<const i::ProfileNode*>(this)->children()->at(index); 7066 reinterpret_cast<const i::ProfileNode*>(this)->children()->at(index);
7067 return reinterpret_cast<const CpuProfileNode*>(child); 7067 return reinterpret_cast<const CpuProfileNode*>(child);
7068 } 7068 }
7069 7069
7070 7070
7071 void CpuProfile::Delete() { 7071 void CpuProfile::Delete() {
7072 i::Isolate* isolate = i::Isolate::Current(); 7072 i::Isolate* isolate = i::Isolate::Current();
7073 i::CpuProfiler* profiler = isolate->cpu_profiler(); 7073 i::CpuProfiler* profiler = isolate->cpu_profiler();
7074 ASSERT(profiler != NULL); 7074 DCHECK(profiler != NULL);
7075 profiler->DeleteProfile(reinterpret_cast<i::CpuProfile*>(this)); 7075 profiler->DeleteProfile(reinterpret_cast<i::CpuProfile*>(this));
7076 } 7076 }
7077 7077
7078 7078
7079 Handle<String> CpuProfile::GetTitle() const { 7079 Handle<String> CpuProfile::GetTitle() const {
7080 i::Isolate* isolate = i::Isolate::Current(); 7080 i::Isolate* isolate = i::Isolate::Current();
7081 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); 7081 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
7082 return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String( 7082 return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String(
7083 profile->title())); 7083 profile->title()));
7084 } 7084 }
(...skipping 29 matching lines...) Expand all
7114 return (profile->end_time() - base::TimeTicks()).InMicroseconds(); 7114 return (profile->end_time() - base::TimeTicks()).InMicroseconds();
7115 } 7115 }
7116 7116
7117 7117
7118 int CpuProfile::GetSamplesCount() const { 7118 int CpuProfile::GetSamplesCount() const {
7119 return reinterpret_cast<const i::CpuProfile*>(this)->samples_count(); 7119 return reinterpret_cast<const i::CpuProfile*>(this)->samples_count();
7120 } 7120 }
7121 7121
7122 7122
7123 void CpuProfiler::SetSamplingInterval(int us) { 7123 void CpuProfiler::SetSamplingInterval(int us) {
7124 ASSERT(us >= 0); 7124 DCHECK(us >= 0);
7125 return reinterpret_cast<i::CpuProfiler*>(this)->set_sampling_interval( 7125 return reinterpret_cast<i::CpuProfiler*>(this)->set_sampling_interval(
7126 base::TimeDelta::FromMicroseconds(us)); 7126 base::TimeDelta::FromMicroseconds(us));
7127 } 7127 }
7128 7128
7129 7129
7130 void CpuProfiler::StartProfiling(Handle<String> title, bool record_samples) { 7130 void CpuProfiler::StartProfiling(Handle<String> title, bool record_samples) {
7131 reinterpret_cast<i::CpuProfiler*>(this)->StartProfiling( 7131 reinterpret_cast<i::CpuProfiler*>(this)->StartProfiling(
7132 *Utils::OpenHandle(*title), record_samples); 7132 *Utils::OpenHandle(*title), record_samples);
7133 } 7133 }
7134 7134
(...skipping 11 matching lines...) Expand all
7146 7146
7147 7147
7148 const CpuProfile* CpuProfiler::StopCpuProfiling(Handle<String> title) { 7148 const CpuProfile* CpuProfiler::StopCpuProfiling(Handle<String> title) {
7149 return StopProfiling(title); 7149 return StopProfiling(title);
7150 } 7150 }
7151 7151
7152 7152
7153 void CpuProfiler::SetIdle(bool is_idle) { 7153 void CpuProfiler::SetIdle(bool is_idle) {
7154 i::Isolate* isolate = reinterpret_cast<i::CpuProfiler*>(this)->isolate(); 7154 i::Isolate* isolate = reinterpret_cast<i::CpuProfiler*>(this)->isolate();
7155 i::StateTag state = isolate->current_vm_state(); 7155 i::StateTag state = isolate->current_vm_state();
7156 ASSERT(state == i::EXTERNAL || state == i::IDLE); 7156 DCHECK(state == i::EXTERNAL || state == i::IDLE);
7157 if (isolate->js_entry_sp() != NULL) return; 7157 if (isolate->js_entry_sp() != NULL) return;
7158 if (is_idle) { 7158 if (is_idle) {
7159 isolate->set_current_vm_state(i::IDLE); 7159 isolate->set_current_vm_state(i::IDLE);
7160 } else if (state == i::IDLE) { 7160 } else if (state == i::IDLE) {
7161 isolate->set_current_vm_state(i::EXTERNAL); 7161 isolate->set_current_vm_state(i::EXTERNAL);
7162 } 7162 }
7163 } 7163 }
7164 7164
7165 7165
7166 static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) { 7166 static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) {
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
7507 #ifdef DEBUG 7507 #ifdef DEBUG
7508 bool found_block_before_deferred = false; 7508 bool found_block_before_deferred = false;
7509 #endif 7509 #endif
7510 // Iterate over all handles in the blocks except for the last. 7510 // Iterate over all handles in the blocks except for the last.
7511 for (int i = blocks()->length() - 2; i >= 0; --i) { 7511 for (int i = blocks()->length() - 2; i >= 0; --i) {
7512 Object** block = blocks()->at(i); 7512 Object** block = blocks()->at(i);
7513 if (last_handle_before_deferred_block_ != NULL && 7513 if (last_handle_before_deferred_block_ != NULL &&
7514 (last_handle_before_deferred_block_ <= &block[kHandleBlockSize]) && 7514 (last_handle_before_deferred_block_ <= &block[kHandleBlockSize]) &&
7515 (last_handle_before_deferred_block_ >= block)) { 7515 (last_handle_before_deferred_block_ >= block)) {
7516 v->VisitPointers(block, last_handle_before_deferred_block_); 7516 v->VisitPointers(block, last_handle_before_deferred_block_);
7517 ASSERT(!found_block_before_deferred); 7517 DCHECK(!found_block_before_deferred);
7518 #ifdef DEBUG 7518 #ifdef DEBUG
7519 found_block_before_deferred = true; 7519 found_block_before_deferred = true;
7520 #endif 7520 #endif
7521 } else { 7521 } else {
7522 v->VisitPointers(block, &block[kHandleBlockSize]); 7522 v->VisitPointers(block, &block[kHandleBlockSize]);
7523 } 7523 }
7524 } 7524 }
7525 7525
7526 ASSERT(last_handle_before_deferred_block_ == NULL || 7526 DCHECK(last_handle_before_deferred_block_ == NULL ||
7527 found_block_before_deferred); 7527 found_block_before_deferred);
7528 7528
7529 // Iterate over live handles in the last block (if any). 7529 // Iterate over live handles in the last block (if any).
7530 if (!blocks()->is_empty()) { 7530 if (!blocks()->is_empty()) {
7531 v->VisitPointers(blocks()->last(), handle_scope_data_.next); 7531 v->VisitPointers(blocks()->last(), handle_scope_data_.next);
7532 } 7532 }
7533 7533
7534 List<Context*>* context_lists[2] = { &saved_contexts_, &entered_contexts_}; 7534 List<Context*>* context_lists[2] = { &saved_contexts_, &entered_contexts_};
7535 for (unsigned i = 0; i < ARRAY_SIZE(context_lists); i++) { 7535 for (unsigned i = 0; i < ARRAY_SIZE(context_lists); i++) {
7536 if (context_lists[i]->is_empty()) continue; 7536 if (context_lists[i]->is_empty()) continue;
(...skipping 19 matching lines...) Expand all
7556 7556
7557 7557
7558 DeferredHandles* HandleScopeImplementer::Detach(Object** prev_limit) { 7558 DeferredHandles* HandleScopeImplementer::Detach(Object** prev_limit) {
7559 DeferredHandles* deferred = 7559 DeferredHandles* deferred =
7560 new DeferredHandles(isolate()->handle_scope_data()->next, isolate()); 7560 new DeferredHandles(isolate()->handle_scope_data()->next, isolate());
7561 7561
7562 while (!blocks_.is_empty()) { 7562 while (!blocks_.is_empty()) {
7563 Object** block_start = blocks_.last(); 7563 Object** block_start = blocks_.last();
7564 Object** block_limit = &block_start[kHandleBlockSize]; 7564 Object** block_limit = &block_start[kHandleBlockSize];
7565 // We should not need to check for SealHandleScope here. Assert this. 7565 // We should not need to check for SealHandleScope here. Assert this.
7566 ASSERT(prev_limit == block_limit || 7566 DCHECK(prev_limit == block_limit ||
7567 !(block_start <= prev_limit && prev_limit <= block_limit)); 7567 !(block_start <= prev_limit && prev_limit <= block_limit));
7568 if (prev_limit == block_limit) break; 7568 if (prev_limit == block_limit) break;
7569 deferred->blocks_.Add(blocks_.last()); 7569 deferred->blocks_.Add(blocks_.last());
7570 blocks_.RemoveLast(); 7570 blocks_.RemoveLast();
7571 } 7571 }
7572 7572
7573 // deferred->blocks_ now contains the blocks installed on the 7573 // deferred->blocks_ now contains the blocks installed on the
7574 // HandleScope stack since BeginDeferredScope was called, but in 7574 // HandleScope stack since BeginDeferredScope was called, but in
7575 // reverse order. 7575 // reverse order.
7576 7576
7577 ASSERT(prev_limit == NULL || !blocks_.is_empty()); 7577 DCHECK(prev_limit == NULL || !blocks_.is_empty());
7578 7578
7579 ASSERT(!blocks_.is_empty() && prev_limit != NULL); 7579 DCHECK(!blocks_.is_empty() && prev_limit != NULL);
7580 ASSERT(last_handle_before_deferred_block_ != NULL); 7580 DCHECK(last_handle_before_deferred_block_ != NULL);
7581 last_handle_before_deferred_block_ = NULL; 7581 last_handle_before_deferred_block_ = NULL;
7582 return deferred; 7582 return deferred;
7583 } 7583 }
7584 7584
7585 7585
7586 void HandleScopeImplementer::BeginDeferredScope() { 7586 void HandleScopeImplementer::BeginDeferredScope() {
7587 ASSERT(last_handle_before_deferred_block_ == NULL); 7587 DCHECK(last_handle_before_deferred_block_ == NULL);
7588 last_handle_before_deferred_block_ = isolate()->handle_scope_data()->next; 7588 last_handle_before_deferred_block_ = isolate()->handle_scope_data()->next;
7589 } 7589 }
7590 7590
7591 7591
7592 DeferredHandles::~DeferredHandles() { 7592 DeferredHandles::~DeferredHandles() {
7593 isolate_->UnlinkDeferredHandles(this); 7593 isolate_->UnlinkDeferredHandles(this);
7594 7594
7595 for (int i = 0; i < blocks_.length(); i++) { 7595 for (int i = 0; i < blocks_.length(); i++) {
7596 #ifdef ENABLE_HANDLE_ZAPPING 7596 #ifdef ENABLE_HANDLE_ZAPPING
7597 HandleScope::ZapRange(blocks_[i], &blocks_[i][kHandleBlockSize]); 7597 HandleScope::ZapRange(blocks_[i], &blocks_[i][kHandleBlockSize]);
7598 #endif 7598 #endif
7599 isolate_->handle_scope_implementer()->ReturnBlock(blocks_[i]); 7599 isolate_->handle_scope_implementer()->ReturnBlock(blocks_[i]);
7600 } 7600 }
7601 } 7601 }
7602 7602
7603 7603
7604 void DeferredHandles::Iterate(ObjectVisitor* v) { 7604 void DeferredHandles::Iterate(ObjectVisitor* v) {
7605 ASSERT(!blocks_.is_empty()); 7605 DCHECK(!blocks_.is_empty());
7606 7606
7607 ASSERT((first_block_limit_ >= blocks_.first()) && 7607 DCHECK((first_block_limit_ >= blocks_.first()) &&
7608 (first_block_limit_ <= &(blocks_.first())[kHandleBlockSize])); 7608 (first_block_limit_ <= &(blocks_.first())[kHandleBlockSize]));
7609 7609
7610 v->VisitPointers(blocks_.first(), first_block_limit_); 7610 v->VisitPointers(blocks_.first(), first_block_limit_);
7611 7611
7612 for (int i = 1; i < blocks_.length(); i++) { 7612 for (int i = 1; i < blocks_.length(); i++) {
7613 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); 7613 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]);
7614 } 7614 }
7615 } 7615 }
7616 7616
7617 7617
(...skipping 16 matching lines...) Expand all
7634 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7634 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7635 Address callback_address = 7635 Address callback_address =
7636 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7636 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7637 VMState<EXTERNAL> state(isolate); 7637 VMState<EXTERNAL> state(isolate);
7638 ExternalCallbackScope call_scope(isolate, callback_address); 7638 ExternalCallbackScope call_scope(isolate, callback_address);
7639 callback(info); 7639 callback(info);
7640 } 7640 }
7641 7641
7642 7642
7643 } } // namespace v8::internal 7643 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.h ('k') | src/arguments.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698