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

Side by Side Diff: src/api.cc

Issue 157543002: A64: Synchronize with r18581. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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/arm/builtins-arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 #define EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, value) \ 112 #define EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, value) \
113 EXCEPTION_BAILOUT_CHECK_GENERIC( \ 113 EXCEPTION_BAILOUT_CHECK_GENERIC( \
114 isolate, value, i::V8::FireCallCompletedCallback(isolate);) 114 isolate, value, i::V8::FireCallCompletedCallback(isolate);)
115 115
116 116
117 #define EXCEPTION_BAILOUT_CHECK(isolate, value) \ 117 #define EXCEPTION_BAILOUT_CHECK(isolate, value) \
118 EXCEPTION_BAILOUT_CHECK_GENERIC(isolate, value, ;) 118 EXCEPTION_BAILOUT_CHECK_GENERIC(isolate, value, ;)
119 119
120 120
121 #define API_ENTRY_CHECK(isolate, msg) \
122 do { \
123 if (v8::Locker::IsActive()) { \
124 ApiCheck(isolate->thread_manager()->IsLockedByCurrentThread(), \
125 msg, \
126 "Entering the V8 API without proper locking in place"); \
127 } \
128 } while (false)
129
130
131 // --- E x c e p t i o n B e h a v i o r --- 121 // --- E x c e p t i o n B e h a v i o r ---
132 122
133 123
134 static void DefaultFatalErrorHandler(const char* location,
135 const char* message) {
136 i::Isolate* isolate = i::Isolate::Current();
137 if (isolate->IsInitialized()) {
138 i::VMState<i::OTHER> state(isolate);
139 API_Fatal(location, message);
140 } else {
141 API_Fatal(location, message);
142 }
143 }
144
145
146 static FatalErrorCallback GetFatalErrorHandler() {
147 i::Isolate* isolate = i::Isolate::Current();
148 if (isolate->exception_behavior() == NULL) {
149 isolate->set_exception_behavior(DefaultFatalErrorHandler);
150 }
151 return isolate->exception_behavior();
152 }
153
154
155 void i::FatalProcessOutOfMemory(const char* location) { 124 void i::FatalProcessOutOfMemory(const char* location) {
156 i::V8::FatalProcessOutOfMemory(location, false); 125 i::V8::FatalProcessOutOfMemory(location, false);
157 } 126 }
158 127
159 128
160 // When V8 cannot allocated memory FatalProcessOutOfMemory is called. 129 // When V8 cannot allocated memory FatalProcessOutOfMemory is called.
161 // The default fatal error handler is called and execution is stopped. 130 // The default fatal error handler is called and execution is stopped.
162 void i::V8::FatalProcessOutOfMemory(const char* location, bool take_snapshot) { 131 void i::V8::FatalProcessOutOfMemory(const char* location, bool take_snapshot) {
163 i::HeapStats heap_stats; 132 i::HeapStats heap_stats;
164 int start_marker; 133 int start_marker;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 int os_error; 183 int os_error;
215 heap_stats.os_error = &os_error; 184 heap_stats.os_error = &os_error;
216 int end_marker; 185 int end_marker;
217 heap_stats.end_marker = &end_marker; 186 heap_stats.end_marker = &end_marker;
218 i::Isolate* isolate = i::Isolate::Current(); 187 i::Isolate* isolate = i::Isolate::Current();
219 if (isolate->heap()->HasBeenSetUp()) { 188 if (isolate->heap()->HasBeenSetUp()) {
220 // BUG(1718): Don't use the take_snapshot since we don't support 189 // BUG(1718): Don't use the take_snapshot since we don't support
221 // HeapIterator here without doing a special GC. 190 // HeapIterator here without doing a special GC.
222 isolate->heap()->RecordStats(&heap_stats, false); 191 isolate->heap()->RecordStats(&heap_stats, false);
223 } 192 }
224 isolate->SignalFatalError(); 193 Utils::ApiCheck(false, location, "Allocation failed - process out of memory");
225 FatalErrorCallback callback = GetFatalErrorHandler(); 194 // If the fatal error handler returns, we stop execution.
226 const char* message = "Allocation failed - process out of memory";
227 callback(location, message);
228 // If the callback returns, we stop execution.
229 FATAL("API fatal error handler returned after process out of memory"); 195 FATAL("API fatal error handler returned after process out of memory");
230 } 196 }
231 197
232 198
233 bool Utils::ReportApiFailure(const char* location, const char* message) { 199 void Utils::ReportApiFailure(const char* location, const char* message) {
234 FatalErrorCallback callback = GetFatalErrorHandler();
235 callback(location, message);
236 i::Isolate* isolate = i::Isolate::Current(); 200 i::Isolate* isolate = i::Isolate::Current();
201 FatalErrorCallback callback = isolate->exception_behavior();
202 if (callback == NULL) {
203 i::OS::PrintError("\n#\n# Fatal error in %s\n# %s\n#\n\n",
204 location, message);
205 i::OS::Abort();
206 } else {
207 callback(location, message);
208 }
237 isolate->SignalFatalError(); 209 isolate->SignalFatalError();
238 return false;
239 } 210 }
240 211
241 212
242 bool V8::IsDead() { 213 bool V8::IsDead() {
243 i::Isolate* isolate = i::Isolate::Current(); 214 i::Isolate* isolate = i::Isolate::Current();
244 return isolate->IsDead(); 215 return isolate->IsDead();
245 } 216 }
246 217
247 218
248 static inline bool ApiCheck(bool condition,
249 const char* location,
250 const char* message) {
251 return condition ? true : Utils::ReportApiFailure(location, message);
252 }
253
254
255 static bool ReportEmptyHandle(const char* location) {
256 FatalErrorCallback callback = GetFatalErrorHandler();
257 callback(location, "Reading from empty handle");
258 return true;
259 }
260
261
262 static inline bool IsExecutionTerminatingCheck(i::Isolate* isolate) { 219 static inline bool IsExecutionTerminatingCheck(i::Isolate* isolate) {
263 if (!isolate->IsInitialized()) return false; 220 if (!isolate->IsInitialized()) return false;
264 if (isolate->has_scheduled_exception()) { 221 if (isolate->has_scheduled_exception()) {
265 return isolate->scheduled_exception() == 222 return isolate->scheduled_exception() ==
266 isolate->heap()->termination_exception(); 223 isolate->heap()->termination_exception();
267 } 224 }
268 return false; 225 return false;
269 } 226 }
270 227
271 228
272 static inline bool EmptyCheck(const char* location, v8::Handle<v8::Data> obj) {
273 return obj.IsEmpty() ? ReportEmptyHandle(location) : false;
274 }
275
276
277 static inline bool EmptyCheck(const char* location, const v8::Data* obj) {
278 return (obj == 0) ? ReportEmptyHandle(location) : false;
279 }
280
281
282 // --- S t a t i c s --- 229 // --- S t a t i c s ---
283 230
284 231
285 static bool InitializeHelper(i::Isolate* isolate) { 232 static bool InitializeHelper(i::Isolate* isolate) {
286 // If the isolate has a function entry hook, it needs to re-build all its 233 // If the isolate has a function entry hook, it needs to re-build all its
287 // code stubs with entry hooks embedded, so let's deserialize a snapshot. 234 // code stubs with entry hooks embedded, so let's deserialize a snapshot.
288 if (isolate == NULL || isolate->function_entry_hook() == NULL) { 235 if (isolate == NULL || isolate->function_entry_hook() == NULL) {
289 if (i::Snapshot::Initialize()) 236 if (i::Snapshot::Initialize())
290 return true; 237 return true;
291 } 238 }
292 return i::V8::Initialize(NULL); 239 return i::V8::Initialize(NULL);
293 } 240 }
294 241
295 242
296 static inline bool EnsureInitializedForIsolate(i::Isolate* isolate, 243 static inline bool EnsureInitializedForIsolate(i::Isolate* isolate,
297 const char* location) { 244 const char* location) {
298 if (isolate != NULL) { 245 return (isolate != NULL && isolate->IsInitialized()) ||
299 if (isolate->IsInitialized()) return true; 246 Utils::ApiCheck(InitializeHelper(isolate),
300 } 247 location,
301 ASSERT(isolate == i::Isolate::Current()); 248 "Error initializing V8");
302 return ApiCheck(InitializeHelper(isolate), location, "Error initializing V8");
303 } 249 }
304 250
305 251
306 // Some initializing API functions are called early and may be 252 // Some initializing API functions are called early and may be
307 // called on a thread different from static initializer thread. 253 // called on a thread different from static initializer thread.
308 // If Isolate API is used, Isolate::Enter() will initialize TLS so 254 // If Isolate API is used, Isolate::Enter() will initialize TLS so
309 // Isolate::Current() works. If it's a legacy case, then the thread 255 // Isolate::Current() works. If it's a legacy case, then the thread
310 // may not have TLS initialized yet. However, in initializing APIs it 256 // may not have TLS initialized yet. However, in initializing APIs it
311 // may be too early to call EnsureInitialized() - some pre-init 257 // may be too early to call EnsureInitialized() - some pre-init
312 // parameters still have to be configured. 258 // parameters still have to be configured.
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 (source ? static_cast<int>(strlen(source)) : 0)), 458 (source ? static_cast<int>(strlen(source)) : 0)),
513 source_(source, source_length_), 459 source_(source, source_length_),
514 dep_count_(dep_count), 460 dep_count_(dep_count),
515 deps_(deps), 461 deps_(deps),
516 auto_enable_(false) { 462 auto_enable_(false) {
517 CHECK(source != NULL || source_length_ == 0); 463 CHECK(source != NULL || source_length_ == 0);
518 } 464 }
519 465
520 466
521 ResourceConstraints::ResourceConstraints() 467 ResourceConstraints::ResourceConstraints()
522 : max_young_space_size_(0), 468 : max_young_space_size_(0),
523 max_old_space_size_(0), 469 max_old_space_size_(0),
524 max_executable_size_(0), 470 max_executable_size_(0),
525 stack_limit_(NULL), 471 stack_limit_(NULL),
526 max_available_threads_(0) { } 472 max_available_threads_(0) { }
527 473
528 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, 474 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory,
529 uint32_t number_of_processors) { 475 uint32_t number_of_processors) {
530 const int lump_of_memory = (i::kPointerSize / 4) * i::MB; 476 const int lump_of_memory = (i::kPointerSize / 4) * i::MB;
531 #if V8_OS_ANDROID 477 #if V8_OS_ANDROID
532 // Android has higher physical memory requirements before raising the maximum 478 // Android has higher physical memory requirements before raising the maximum
533 // heap size limits since it has no swap space. 479 // heap size limits since it has no swap space.
534 const uint64_t low_limit = 512ul * i::MB; 480 const uint64_t low_limit = 512ul * i::MB;
535 const uint64_t medium_limit = 1ul * i::GB; 481 const uint64_t medium_limit = 1ul * i::GB;
536 const uint64_t high_limit = 2ul * i::GB; 482 const uint64_t high_limit = 2ul * i::GB;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 // --- H a n d l e s --- 586 // --- H a n d l e s ---
641 587
642 588
643 HandleScope::HandleScope(Isolate* isolate) { 589 HandleScope::HandleScope(Isolate* isolate) {
644 Initialize(isolate); 590 Initialize(isolate);
645 } 591 }
646 592
647 593
648 void HandleScope::Initialize(Isolate* isolate) { 594 void HandleScope::Initialize(Isolate* isolate) {
649 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); 595 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
650 API_ENTRY_CHECK(internal_isolate, "HandleScope::HandleScope"); 596 // We do not want to check the correct usage of the Locker class all over the
597 // place, so we do it only here: Without a HandleScope, an embedder can do
598 // almost nothing, so it is enough to check in this central place.
599 Utils::ApiCheck(!v8::Locker::IsActive() ||
600 internal_isolate->thread_manager()->IsLockedByCurrentThread(),
601 "HandleScope::HandleScope",
602 "Entering the V8 API without proper locking in place");
651 v8::ImplementationUtilities::HandleScopeData* current = 603 v8::ImplementationUtilities::HandleScopeData* current =
652 internal_isolate->handle_scope_data(); 604 internal_isolate->handle_scope_data();
653 isolate_ = internal_isolate; 605 isolate_ = internal_isolate;
654 prev_next_ = current->next; 606 prev_next_ = current->next;
655 prev_limit_ = current->limit; 607 prev_limit_ = current->limit;
656 current->level++; 608 current->level++;
657 } 609 }
658 610
659 611
660 HandleScope::~HandleScope() { 612 HandleScope::~HandleScope() {
661 i::HandleScope::CloseScope(isolate_, prev_next_, prev_limit_); 613 i::HandleScope::CloseScope(isolate_, prev_next_, prev_limit_);
662 } 614 }
663 615
664 616
665 int HandleScope::NumberOfHandles() { 617 int HandleScope::NumberOfHandles(Isolate* isolate) {
666 i::Isolate* isolate = i::Isolate::Current(); 618 return i::HandleScope::NumberOfHandles(
667 if (!EnsureInitializedForIsolate(isolate, "HandleScope::NumberOfHandles")) { 619 reinterpret_cast<i::Isolate*>(isolate));
668 return 0;
669 }
670 return i::HandleScope::NumberOfHandles(isolate);
671 } 620 }
672 621
673 622
674 i::Object** HandleScope::CreateHandle(i::Isolate* isolate, i::Object* value) { 623 i::Object** HandleScope::CreateHandle(i::Isolate* isolate, i::Object* value) {
675 return i::HandleScope::CreateHandle(isolate, value); 624 return i::HandleScope::CreateHandle(isolate, value);
676 } 625 }
677 626
678 627
679 i::Object** HandleScope::CreateHandle(i::HeapObject* heap_object, 628 i::Object** HandleScope::CreateHandle(i::HeapObject* heap_object,
680 i::Object* value) { 629 i::Object* value) {
681 ASSERT(heap_object->IsHeapObject()); 630 ASSERT(heap_object->IsHeapObject());
682 return i::HandleScope::CreateHandle(heap_object->GetIsolate(), value); 631 return i::HandleScope::CreateHandle(heap_object->GetIsolate(), value);
683 } 632 }
684 633
685 634
686 EscapableHandleScope::EscapableHandleScope(Isolate* v8_isolate) { 635 EscapableHandleScope::EscapableHandleScope(Isolate* v8_isolate) {
687 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); 636 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
688 escape_slot_ = CreateHandle(isolate, isolate->heap()->the_hole_value()); 637 escape_slot_ = CreateHandle(isolate, isolate->heap()->the_hole_value());
689 Initialize(v8_isolate); 638 Initialize(v8_isolate);
690 } 639 }
691 640
692 641
693 i::Object** EscapableHandleScope::Escape(i::Object** escape_value) { 642 i::Object** EscapableHandleScope::Escape(i::Object** escape_value) {
694 ApiCheck(*escape_slot_ == isolate_->heap()->the_hole_value(), 643 Utils::ApiCheck(*escape_slot_ == isolate_->heap()->the_hole_value(),
695 "EscapeableHandleScope::Escape", 644 "EscapeableHandleScope::Escape",
696 "Escape value set twice"); 645 "Escape value set twice");
697 if (escape_value == NULL) { 646 if (escape_value == NULL) {
698 *escape_slot_ = isolate_->heap()->undefined_value(); 647 *escape_slot_ = isolate_->heap()->undefined_value();
699 return NULL; 648 return NULL;
700 } 649 }
701 *escape_slot_ = *escape_value; 650 *escape_slot_ = *escape_value;
702 return escape_slot_; 651 return escape_slot_;
703 } 652 }
704 653
705 654
706 void Context::Enter() { 655 void Context::Enter() {
707 i::Handle<i::Context> env = Utils::OpenHandle(this); 656 i::Handle<i::Context> env = Utils::OpenHandle(this);
708 i::Isolate* isolate = env->GetIsolate(); 657 i::Isolate* isolate = env->GetIsolate();
709 ENTER_V8(isolate); 658 ENTER_V8(isolate);
710 isolate->handle_scope_implementer()->EnterContext(env); 659 i::HandleScopeImplementer* impl = isolate->handle_scope_implementer();
711 isolate->handle_scope_implementer()->SaveContext(isolate->context()); 660 impl->EnterContext(env);
661 impl->SaveContext(isolate->context());
712 isolate->set_context(*env); 662 isolate->set_context(*env);
713 } 663 }
714 664
715 665
716 void Context::Exit() { 666 void Context::Exit() {
717 // TODO(dcarney): fix this once chrome is fixed. 667 i::Handle<i::Context> env = Utils::OpenHandle(this);
718 i::Isolate* isolate = i::Isolate::Current(); 668 i::Isolate* isolate = env->GetIsolate();
719 i::Handle<i::Context> context = i::Handle<i::Context>::null();
720 ENTER_V8(isolate); 669 ENTER_V8(isolate);
721 if (!ApiCheck(isolate->handle_scope_implementer()->LeaveContext(context), 670 i::HandleScopeImplementer* impl = isolate->handle_scope_implementer();
722 "v8::Context::Exit()", 671 if (!Utils::ApiCheck(impl->LastEnteredContextWas(env),
723 "Cannot exit non-entered context")) { 672 "v8::Context::Exit()",
673 "Cannot exit non-entered context")) {
724 return; 674 return;
725 } 675 }
726 // Content of 'last_context' could be NULL. 676 impl->LeaveContext();
727 i::Context* last_context = 677 isolate->set_context(impl->RestoreContext());
728 isolate->handle_scope_implementer()->RestoreContext();
729 isolate->set_context(last_context);
730 } 678 }
731 679
732 680
733 static void* DecodeSmiToAligned(i::Object* value, const char* location) { 681 static void* DecodeSmiToAligned(i::Object* value, const char* location) {
734 ApiCheck(value->IsSmi(), location, "Not a Smi"); 682 Utils::ApiCheck(value->IsSmi(), location, "Not a Smi");
735 return reinterpret_cast<void*>(value); 683 return reinterpret_cast<void*>(value);
736 } 684 }
737 685
738 686
739 static i::Smi* EncodeAlignedAsSmi(void* value, const char* location) { 687 static i::Smi* EncodeAlignedAsSmi(void* value, const char* location) {
740 i::Smi* smi = reinterpret_cast<i::Smi*>(value); 688 i::Smi* smi = reinterpret_cast<i::Smi*>(value);
741 ApiCheck(smi->IsSmi(), location, "Pointer is not aligned"); 689 Utils::ApiCheck(smi->IsSmi(), location, "Pointer is not aligned");
742 return smi; 690 return smi;
743 } 691 }
744 692
745 693
746 static i::Handle<i::FixedArray> EmbedderDataFor(Context* context, 694 static i::Handle<i::FixedArray> EmbedderDataFor(Context* context,
747 int index, 695 int index,
748 bool can_grow, 696 bool can_grow,
749 const char* location) { 697 const char* location) {
750 i::Handle<i::Context> env = Utils::OpenHandle(context); 698 i::Handle<i::Context> env = Utils::OpenHandle(context);
751 bool ok = 699 bool ok =
752 ApiCheck(env->IsNativeContext(), location, "Not a native context") && 700 Utils::ApiCheck(env->IsNativeContext(),
753 ApiCheck(index >= 0, location, "Negative index"); 701 location,
702 "Not a native context") &&
703 Utils::ApiCheck(index >= 0, location, "Negative index");
754 if (!ok) return i::Handle<i::FixedArray>(); 704 if (!ok) return i::Handle<i::FixedArray>();
755 i::Handle<i::FixedArray> data(env->embedder_data()); 705 i::Handle<i::FixedArray> data(env->embedder_data());
756 if (index < data->length()) return data; 706 if (index < data->length()) return data;
757 if (!can_grow) { 707 if (!Utils::ApiCheck(can_grow, location, "Index too large")) {
758 Utils::ReportApiFailure(location, "Index too large");
759 return i::Handle<i::FixedArray>(); 708 return i::Handle<i::FixedArray>();
760 } 709 }
761 int new_size = i::Max(index, data->length() << 1) + 1; 710 int new_size = i::Max(index, data->length() << 1) + 1;
762 data = env->GetIsolate()->factory()->CopySizeFixedArray(data, new_size); 711 data = env->GetIsolate()->factory()->CopySizeFixedArray(data, new_size);
763 env->set_embedder_data(*data); 712 env->set_embedder_data(*data);
764 return data; 713 return data;
765 } 714 }
766 715
767 716
768 v8::Local<v8::Value> Context::SlowGetEmbedderData(int index) { 717 v8::Local<v8::Value> Context::SlowGetEmbedderData(int index) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 751
803 752
804 // --- N e a n d e r --- 753 // --- N e a n d e r ---
805 754
806 755
807 // A constructor cannot easily return an error value, therefore it is necessary 756 // A constructor cannot easily return an error value, therefore it is necessary
808 // to check for a dead VM with ON_BAILOUT before constructing any Neander 757 // to check for a dead VM with ON_BAILOUT before constructing any Neander
809 // objects. To remind you about this there is no HandleScope in the 758 // objects. To remind you about this there is no HandleScope in the
810 // NeanderObject constructor. When you add one to the site calling the 759 // NeanderObject constructor. When you add one to the site calling the
811 // constructor you should check that you ensured the VM was not dead first. 760 // constructor you should check that you ensured the VM was not dead first.
812 NeanderObject::NeanderObject(int size) { 761 NeanderObject::NeanderObject(v8::internal::Isolate* isolate, int size) {
813 i::Isolate* isolate = i::Isolate::Current();
814 EnsureInitializedForIsolate(isolate, "v8::Nowhere"); 762 EnsureInitializedForIsolate(isolate, "v8::Nowhere");
815 ENTER_V8(isolate); 763 ENTER_V8(isolate);
816 value_ = isolate->factory()->NewNeanderObject(); 764 value_ = isolate->factory()->NewNeanderObject();
817 i::Handle<i::FixedArray> elements = isolate->factory()->NewFixedArray(size); 765 i::Handle<i::FixedArray> elements = isolate->factory()->NewFixedArray(size);
818 value_->set_elements(*elements); 766 value_->set_elements(*elements);
819 } 767 }
820 768
821 769
822 int NeanderObject::size() { 770 int NeanderObject::size() {
823 return i::FixedArray::cast(value_->elements())->length(); 771 return i::FixedArray::cast(value_->elements())->length();
824 } 772 }
825 773
826 774
827 NeanderArray::NeanderArray() : obj_(2) { 775 NeanderArray::NeanderArray(v8::internal::Isolate* isolate) : obj_(isolate, 2) {
828 obj_.set(0, i::Smi::FromInt(0)); 776 obj_.set(0, i::Smi::FromInt(0));
829 } 777 }
830 778
831 779
832 int NeanderArray::length() { 780 int NeanderArray::length() {
833 return i::Smi::cast(obj_.get(0))->value(); 781 return i::Smi::cast(obj_.get(0))->value();
834 } 782 }
835 783
836 784
837 i::Object* NeanderArray::get(int offset) { 785 i::Object* NeanderArray::get(int offset) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 that->set_tag(i::Smi::FromInt(type)); 822 that->set_tag(i::Smi::FromInt(type));
875 } 823 }
876 824
877 825
878 static void TemplateSet(i::Isolate* isolate, 826 static void TemplateSet(i::Isolate* isolate,
879 v8::Template* templ, 827 v8::Template* templ,
880 int length, 828 int length,
881 v8::Handle<v8::Data>* data) { 829 v8::Handle<v8::Data>* data) {
882 i::Handle<i::Object> list(Utils::OpenHandle(templ)->property_list(), isolate); 830 i::Handle<i::Object> list(Utils::OpenHandle(templ)->property_list(), isolate);
883 if (list->IsUndefined()) { 831 if (list->IsUndefined()) {
884 list = NeanderArray().value(); 832 list = NeanderArray(isolate).value();
885 Utils::OpenHandle(templ)->set_property_list(*list); 833 Utils::OpenHandle(templ)->set_property_list(*list);
886 } 834 }
887 NeanderArray array(list); 835 NeanderArray array(list);
888 array.add(Utils::OpenHandle(*v8::Integer::New(length))); 836 array.add(isolate->factory()->NewNumberFromInt(length));
889 for (int i = 0; i < length; i++) { 837 for (int i = 0; i < length; i++) {
890 i::Handle<i::Object> value = data[i].IsEmpty() ? 838 i::Handle<i::Object> value = data[i].IsEmpty() ?
891 i::Handle<i::Object>(isolate->factory()->undefined_value()) : 839 i::Handle<i::Object>(isolate->factory()->undefined_value()) :
892 Utils::OpenHandle(*data[i]); 840 Utils::OpenHandle(*data[i]);
893 array.add(value); 841 array.add(value);
894 } 842 }
895 } 843 }
896 844
897 845
898 void Template::Set(v8::Handle<String> name, 846 void Template::Set(v8::Handle<String> name,
899 v8::Handle<Data> value, 847 v8::Handle<Data> value,
900 v8::PropertyAttribute attribute) { 848 v8::PropertyAttribute attribute) {
901 i::Isolate* isolate = i::Isolate::Current(); 849 i::Isolate* isolate = i::Isolate::Current();
902 ENTER_V8(isolate); 850 ENTER_V8(isolate);
903 i::HandleScope scope(isolate); 851 i::HandleScope scope(isolate);
904 const int kSize = 3; 852 const int kSize = 3;
853 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
905 v8::Handle<v8::Data> data[kSize] = { 854 v8::Handle<v8::Data> data[kSize] = {
906 name, 855 name,
907 value, 856 value,
908 v8::Integer::New(attribute)}; 857 v8::Integer::New(v8_isolate, attribute)};
909 TemplateSet(isolate, this, kSize, data); 858 TemplateSet(isolate, this, kSize, data);
910 } 859 }
911 860
912 861
913 void Template::SetAccessorProperty( 862 void Template::SetAccessorProperty(
914 v8::Local<v8::String> name, 863 v8::Local<v8::String> name,
915 v8::Local<FunctionTemplate> getter, 864 v8::Local<FunctionTemplate> getter,
916 v8::Local<FunctionTemplate> setter, 865 v8::Local<FunctionTemplate> setter,
917 v8::PropertyAttribute attribute, 866 v8::PropertyAttribute attribute,
918 v8::AccessControl access_control) { 867 v8::AccessControl access_control) {
919 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 868 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
920 ENTER_V8(isolate); 869 ENTER_V8(isolate);
921 ASSERT(!name.IsEmpty()); 870 ASSERT(!name.IsEmpty());
922 ASSERT(!getter.IsEmpty() || !setter.IsEmpty()); 871 ASSERT(!getter.IsEmpty() || !setter.IsEmpty());
923 i::HandleScope scope(isolate); 872 i::HandleScope scope(isolate);
924 const int kSize = 5; 873 const int kSize = 5;
874 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
925 v8::Handle<v8::Data> data[kSize] = { 875 v8::Handle<v8::Data> data[kSize] = {
926 name, 876 name,
927 getter, 877 getter,
928 setter, 878 setter,
929 v8::Integer::New(attribute), 879 v8::Integer::New(v8_isolate, attribute),
930 v8::Integer::New(access_control)}; 880 v8::Integer::New(v8_isolate, access_control)};
931 TemplateSet(isolate, this, kSize, data); 881 TemplateSet(isolate, this, kSize, data);
932 } 882 }
933 883
934 884
935 // --- F u n c t i o n T e m p l a t e --- 885 // --- F u n c t i o n T e m p l a t e ---
936 static void InitializeFunctionTemplate( 886 static void InitializeFunctionTemplate(
937 i::Handle<i::FunctionTemplateInfo> info) { 887 i::Handle<i::FunctionTemplateInfo> info) {
938 info->set_tag(i::Smi::FromInt(Consts::FUNCTION_TEMPLATE)); 888 info->set_tag(i::Smi::FromInt(Consts::FUNCTION_TEMPLATE));
939 info->set_flag(0); 889 info->set_flag(0);
940 } 890 }
941 891
942 892
943 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() { 893 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() {
944 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 894 i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate();
945 ENTER_V8(isolate); 895 ENTER_V8(i_isolate);
946 i::Handle<i::Object> result(Utils::OpenHandle(this)->prototype_template(), 896 i::Handle<i::Object> result(Utils::OpenHandle(this)->prototype_template(),
947 isolate); 897 i_isolate);
948 if (result->IsUndefined()) { 898 if (result->IsUndefined()) {
949 result = Utils::OpenHandle(*ObjectTemplate::New()); 899 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(i_isolate);
900 result = Utils::OpenHandle(*ObjectTemplate::New(isolate));
950 Utils::OpenHandle(this)->set_prototype_template(*result); 901 Utils::OpenHandle(this)->set_prototype_template(*result);
951 } 902 }
952 return ToApiHandle<ObjectTemplate>(result); 903 return ToApiHandle<ObjectTemplate>(result);
953 } 904 }
954 905
955 906
956 void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) { 907 void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) {
957 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 908 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
958 ENTER_V8(isolate); 909 ENTER_V8(isolate);
959 Utils::OpenHandle(this)->set_parent_template(*Utils::OpenHandle(*value)); 910 Utils::OpenHandle(this)->set_parent_template(*Utils::OpenHandle(*value));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 int length) { 952 int length) {
1002 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 953 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
1003 EnsureInitializedForIsolate(i_isolate, "v8::FunctionTemplate::New()"); 954 EnsureInitializedForIsolate(i_isolate, "v8::FunctionTemplate::New()");
1004 LOG_API(i_isolate, "FunctionTemplate::New"); 955 LOG_API(i_isolate, "FunctionTemplate::New");
1005 ENTER_V8(i_isolate); 956 ENTER_V8(i_isolate);
1006 return FunctionTemplateNew( 957 return FunctionTemplateNew(
1007 i_isolate, callback, data, signature, length, false); 958 i_isolate, callback, data, signature, length, false);
1008 } 959 }
1009 960
1010 961
1011 Local<FunctionTemplate> FunctionTemplate::New(
1012 FunctionCallback callback,
1013 v8::Handle<Value> data,
1014 v8::Handle<Signature> signature,
1015 int length) {
1016 return New(Isolate::GetCurrent(), callback, data, signature, length);
1017 }
1018
1019 Local<Signature> Signature::New(Isolate* isolate, 962 Local<Signature> Signature::New(Isolate* isolate,
1020 Handle<FunctionTemplate> receiver, int argc, 963 Handle<FunctionTemplate> receiver, int argc,
1021 Handle<FunctionTemplate> argv[]) { 964 Handle<FunctionTemplate> argv[]) {
1022 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 965 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
1023 EnsureInitializedForIsolate(i_isolate, "v8::Signature::New()"); 966 EnsureInitializedForIsolate(i_isolate, "v8::Signature::New()");
1024 LOG_API(i_isolate, "Signature::New"); 967 LOG_API(i_isolate, "Signature::New");
1025 ENTER_V8(i_isolate); 968 ENTER_V8(i_isolate);
1026 i::Handle<i::Struct> struct_obj = 969 i::Handle<i::Struct> struct_obj =
1027 i_isolate->factory()->NewStruct(i::SIGNATURE_INFO_TYPE); 970 i_isolate->factory()->NewStruct(i::SIGNATURE_INFO_TYPE);
1028 i::Handle<i::SignatureInfo> obj = 971 i::Handle<i::SignatureInfo> obj =
1029 i::Handle<i::SignatureInfo>::cast(struct_obj); 972 i::Handle<i::SignatureInfo>::cast(struct_obj);
1030 if (!receiver.IsEmpty()) obj->set_receiver(*Utils::OpenHandle(*receiver)); 973 if (!receiver.IsEmpty()) obj->set_receiver(*Utils::OpenHandle(*receiver));
1031 if (argc > 0) { 974 if (argc > 0) {
1032 i::Handle<i::FixedArray> args = i_isolate->factory()->NewFixedArray(argc); 975 i::Handle<i::FixedArray> args = i_isolate->factory()->NewFixedArray(argc);
1033 for (int i = 0; i < argc; i++) { 976 for (int i = 0; i < argc; i++) {
1034 if (!argv[i].IsEmpty()) 977 if (!argv[i].IsEmpty())
1035 args->set(i, *Utils::OpenHandle(*argv[i])); 978 args->set(i, *Utils::OpenHandle(*argv[i]));
1036 } 979 }
1037 obj->set_args(*args); 980 obj->set_args(*args);
1038 } 981 }
1039 return Utils::ToLocal(obj); 982 return Utils::ToLocal(obj);
1040 } 983 }
1041 984
1042 985
1043 Local<AccessorSignature> AccessorSignature::New( 986 Local<AccessorSignature> AccessorSignature::New(
1044 Isolate* isolate, 987 Isolate* isolate,
1045 Handle<FunctionTemplate> receiver) { 988 Handle<FunctionTemplate> receiver) {
1046 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver)); 989 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver));
1047 } 990 }
1048 991
1049 992
1050 template<typename Operation> 993 template<typename Operation>
1051 static Local<Operation> NewDescriptor( 994 static Local<Operation> NewDescriptor(
1052 Isolate* isolate, 995 Isolate* isolate,
1053 const i::DeclaredAccessorDescriptorData& data, 996 const i::DeclaredAccessorDescriptorData& data,
1054 Data* previous_descriptor) { 997 Data* previous_descriptor) {
1055 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); 998 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
1056 i::Handle<i::DeclaredAccessorDescriptor> previous = 999 i::Handle<i::DeclaredAccessorDescriptor> previous =
1057 i::Handle<i::DeclaredAccessorDescriptor>(); 1000 i::Handle<i::DeclaredAccessorDescriptor>();
1058 if (previous_descriptor != NULL) { 1001 if (previous_descriptor != NULL) {
1059 previous = Utils::OpenHandle( 1002 previous = Utils::OpenHandle(
1060 static_cast<DeclaredAccessorDescriptor*>(previous_descriptor)); 1003 static_cast<DeclaredAccessorDescriptor*>(previous_descriptor));
1061 } 1004 }
1062 i::Handle<i::DeclaredAccessorDescriptor> descriptor = 1005 i::Handle<i::DeclaredAccessorDescriptor> descriptor =
1063 i::DeclaredAccessorDescriptor::Create(internal_isolate, data, previous); 1006 i::DeclaredAccessorDescriptor::Create(internal_isolate, data, previous);
1064 return Utils::Convert<i::DeclaredAccessorDescriptor, Operation>(descriptor); 1007 return Utils::Convert<i::DeclaredAccessorDescriptor, Operation>(descriptor);
1065 } 1008 }
1066 1009
1067 1010
1068 Local<RawOperationDescriptor> 1011 Local<RawOperationDescriptor>
1069 ObjectOperationDescriptor::NewInternalFieldDereference( 1012 ObjectOperationDescriptor::NewInternalFieldDereference(
1070 Isolate* isolate, 1013 Isolate* isolate,
1071 int internal_field) { 1014 int internal_field) {
1072 i::DeclaredAccessorDescriptorData data; 1015 i::DeclaredAccessorDescriptorData data;
1073 data.type = i::kDescriptorObjectDereference; 1016 data.type = i::kDescriptorObjectDereference;
1074 data.object_dereference_descriptor.internal_field = internal_field; 1017 data.object_dereference_descriptor.internal_field = internal_field;
1075 return NewDescriptor<RawOperationDescriptor>(isolate, data, NULL); 1018 return NewDescriptor<RawOperationDescriptor>(isolate, data, NULL);
1076 } 1019 }
1077 1020
1078 1021
1079 Local<RawOperationDescriptor> RawOperationDescriptor::NewRawShift( 1022 Local<RawOperationDescriptor> RawOperationDescriptor::NewRawShift(
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 i::Handle<i::TypeSwitchInfo> info = Utils::OpenHandle(this); 1137 i::Handle<i::TypeSwitchInfo> info = Utils::OpenHandle(this);
1195 i::FixedArray* types = i::FixedArray::cast(info->types()); 1138 i::FixedArray* types = i::FixedArray::cast(info->types());
1196 for (int i = 0; i < types->length(); i++) { 1139 for (int i = 0; i < types->length(); i++) {
1197 if (i::FunctionTemplateInfo::cast(types->get(i))->IsTemplateFor(*obj)) 1140 if (i::FunctionTemplateInfo::cast(types->get(i))->IsTemplateFor(*obj))
1198 return i + 1; 1141 return i + 1;
1199 } 1142 }
1200 return 0; 1143 return 0;
1201 } 1144 }
1202 1145
1203 1146
1204 #define SET_FIELD_WRAPPED(obj, setter, cdata) do { \ 1147 #define SET_FIELD_WRAPPED(obj, setter, cdata) do { \
1205 i::Handle<i::Object> foreign = FromCData(obj->GetIsolate(), cdata); \ 1148 i::Handle<i::Object> foreign = FromCData(obj->GetIsolate(), cdata); \
1206 (obj)->setter(*foreign); \ 1149 (obj)->setter(*foreign); \
1207 } while (false) 1150 } while (false)
1208 1151
1209 1152
1210 void FunctionTemplate::SetCallHandler(FunctionCallback callback, 1153 void FunctionTemplate::SetCallHandler(FunctionCallback callback,
1211 v8::Handle<Value> data) { 1154 v8::Handle<Value> data) {
1212 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1155 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1213 ENTER_V8(isolate); 1156 ENTER_V8(isolate);
1214 i::HandleScope scope(isolate); 1157 i::HandleScope scope(isolate);
1215 i::Handle<i::Struct> struct_obj = 1158 i::Handle<i::Struct> struct_obj =
1216 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); 1159 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE);
(...skipping 21 matching lines...) Expand all
1238 obj->set_property_attributes(static_cast<PropertyAttributes>(attributes)); 1181 obj->set_property_attributes(static_cast<PropertyAttributes>(attributes));
1239 if (!signature.IsEmpty()) { 1182 if (!signature.IsEmpty()) {
1240 obj->set_expected_receiver_type(*Utils::OpenHandle(*signature)); 1183 obj->set_expected_receiver_type(*Utils::OpenHandle(*signature));
1241 } 1184 }
1242 return obj; 1185 return obj;
1243 } 1186 }
1244 1187
1245 1188
1246 template<typename Getter, typename Setter> 1189 template<typename Getter, typename Setter>
1247 static i::Handle<i::AccessorInfo> MakeAccessorInfo( 1190 static i::Handle<i::AccessorInfo> MakeAccessorInfo(
1248 v8::Handle<String> name, 1191 v8::Handle<String> name,
1249 Getter getter, 1192 Getter getter,
1250 Setter setter, 1193 Setter setter,
1251 v8::Handle<Value> data, 1194 v8::Handle<Value> data,
1252 v8::AccessControl settings, 1195 v8::AccessControl settings,
1253 v8::PropertyAttribute attributes, 1196 v8::PropertyAttribute attributes,
1254 v8::Handle<AccessorSignature> signature) { 1197 v8::Handle<AccessorSignature> signature) {
1255 i::Isolate* isolate = Utils::OpenHandle(*name)->GetIsolate(); 1198 i::Isolate* isolate = Utils::OpenHandle(*name)->GetIsolate();
1256 i::Handle<i::ExecutableAccessorInfo> obj = 1199 i::Handle<i::ExecutableAccessorInfo> obj =
1257 isolate->factory()->NewExecutableAccessorInfo(); 1200 isolate->factory()->NewExecutableAccessorInfo();
1258 SET_FIELD_WRAPPED(obj, set_getter, getter); 1201 SET_FIELD_WRAPPED(obj, set_getter, getter);
1259 SET_FIELD_WRAPPED(obj, set_setter, setter); 1202 SET_FIELD_WRAPPED(obj, set_setter, setter);
1260 if (data.IsEmpty()) { 1203 if (data.IsEmpty()) {
1261 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); 1204 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
1262 } 1205 }
1263 obj->set_data(*Utils::OpenHandle(*data)); 1206 obj->set_data(*Utils::OpenHandle(*data));
1264 return SetAccessorInfoProperties(obj, name, settings, attributes, signature); 1207 return SetAccessorInfoProperties(obj, name, settings, attributes, signature);
1265 } 1208 }
1266 1209
1267 1210
1268 static i::Handle<i::AccessorInfo> MakeAccessorInfo( 1211 static i::Handle<i::AccessorInfo> MakeAccessorInfo(
1269 v8::Handle<String> name, 1212 v8::Handle<String> name,
1270 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor, 1213 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor,
1271 void* setter_ignored, 1214 void* setter_ignored,
1272 void* data_ignored, 1215 void* data_ignored,
1273 v8::AccessControl settings, 1216 v8::AccessControl settings,
1274 v8::PropertyAttribute attributes, 1217 v8::PropertyAttribute attributes,
1275 v8::Handle<AccessorSignature> signature) { 1218 v8::Handle<AccessorSignature> signature) {
1276 i::Isolate* isolate = Utils::OpenHandle(*name)->GetIsolate(); 1219 i::Isolate* isolate = Utils::OpenHandle(*name)->GetIsolate();
1277 if (descriptor.IsEmpty()) return i::Handle<i::DeclaredAccessorInfo>(); 1220 if (descriptor.IsEmpty()) return i::Handle<i::DeclaredAccessorInfo>();
1278 i::Handle<i::DeclaredAccessorInfo> obj = 1221 i::Handle<i::DeclaredAccessorInfo> obj =
1279 isolate->factory()->NewDeclaredAccessorInfo(); 1222 isolate->factory()->NewDeclaredAccessorInfo();
1280 obj->set_descriptor(*Utils::OpenHandle(*descriptor)); 1223 obj->set_descriptor(*Utils::OpenHandle(*descriptor));
1281 return SetAccessorInfoProperties(obj, name, settings, attributes, signature); 1224 return SetAccessorInfoProperties(obj, name, settings, attributes, signature);
1282 } 1225 }
1283 1226
1284 1227
1285 Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() { 1228 Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() {
1286 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1229 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1287 if (EmptyCheck("v8::FunctionTemplate::InstanceTemplate()", this)) 1230 if (!Utils::ApiCheck(this != NULL,
1231 "v8::FunctionTemplate::InstanceTemplate()",
1232 "Reading from empty handle")) {
1288 return Local<ObjectTemplate>(); 1233 return Local<ObjectTemplate>();
1234 }
1289 ENTER_V8(isolate); 1235 ENTER_V8(isolate);
1290 i::Handle<i::FunctionTemplateInfo> handle = Utils::OpenHandle(this); 1236 i::Handle<i::FunctionTemplateInfo> handle = Utils::OpenHandle(this);
1291 if (handle->instance_template()->IsUndefined()) { 1237 if (handle->instance_template()->IsUndefined()) {
1292 Local<ObjectTemplate> templ = 1238 Local<ObjectTemplate> templ =
1293 ObjectTemplate::New(isolate, ToApiHandle<FunctionTemplate>(handle)); 1239 ObjectTemplate::New(isolate, ToApiHandle<FunctionTemplate>(handle));
1294 handle->set_instance_template(*Utils::OpenHandle(*templ)); 1240 handle->set_instance_template(*Utils::OpenHandle(*templ));
1295 } 1241 }
1296 i::Handle<i::ObjectTemplateInfo> result( 1242 i::Handle<i::ObjectTemplateInfo> result(
1297 i::ObjectTemplateInfo::cast(handle->instance_template())); 1243 i::ObjectTemplateInfo::cast(handle->instance_template()));
1298 return Utils::ToLocal(result); 1244 return Utils::ToLocal(result);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 return New(reinterpret_cast<i::Isolate*>(isolate), Local<FunctionTemplate>()); 1287 return New(reinterpret_cast<i::Isolate*>(isolate), Local<FunctionTemplate>());
1342 } 1288 }
1343 1289
1344 1290
1345 Local<ObjectTemplate> ObjectTemplate::New() { 1291 Local<ObjectTemplate> ObjectTemplate::New() {
1346 return New(i::Isolate::Current(), Local<FunctionTemplate>()); 1292 return New(i::Isolate::Current(), Local<FunctionTemplate>());
1347 } 1293 }
1348 1294
1349 1295
1350 Local<ObjectTemplate> ObjectTemplate::New( 1296 Local<ObjectTemplate> ObjectTemplate::New(
1351 i::Isolate* isolate, 1297 i::Isolate* isolate,
1352 v8::Handle<FunctionTemplate> constructor) { 1298 v8::Handle<FunctionTemplate> constructor) {
1353 EnsureInitializedForIsolate(isolate, "v8::ObjectTemplate::New()"); 1299 EnsureInitializedForIsolate(isolate, "v8::ObjectTemplate::New()");
1354 LOG_API(isolate, "ObjectTemplate::New"); 1300 LOG_API(isolate, "ObjectTemplate::New");
1355 ENTER_V8(isolate); 1301 ENTER_V8(isolate);
1356 i::Handle<i::Struct> struct_obj = 1302 i::Handle<i::Struct> struct_obj =
1357 isolate->factory()->NewStruct(i::OBJECT_TEMPLATE_INFO_TYPE); 1303 isolate->factory()->NewStruct(i::OBJECT_TEMPLATE_INFO_TYPE);
1358 i::Handle<i::ObjectTemplateInfo> obj = 1304 i::Handle<i::ObjectTemplateInfo> obj =
1359 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj); 1305 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj);
1360 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE); 1306 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE);
1361 if (!constructor.IsEmpty()) 1307 if (!constructor.IsEmpty())
1362 obj->set_constructor(*Utils::OpenHandle(*constructor)); 1308 obj->set_constructor(*Utils::OpenHandle(*constructor));
(...skipping 17 matching lines...) Expand all
1380 i::Handle<i::FunctionTemplateInfo> constructor = Utils::OpenHandle(*templ); 1326 i::Handle<i::FunctionTemplateInfo> constructor = Utils::OpenHandle(*templ);
1381 constructor->set_instance_template(*Utils::OpenHandle(object_template)); 1327 constructor->set_instance_template(*Utils::OpenHandle(object_template));
1382 Utils::OpenHandle(object_template)->set_constructor(*constructor); 1328 Utils::OpenHandle(object_template)->set_constructor(*constructor);
1383 return constructor; 1329 return constructor;
1384 } 1330 }
1385 1331
1386 1332
1387 static inline void AddPropertyToTemplate( 1333 static inline void AddPropertyToTemplate(
1388 i::Handle<i::TemplateInfo> info, 1334 i::Handle<i::TemplateInfo> info,
1389 i::Handle<i::AccessorInfo> obj) { 1335 i::Handle<i::AccessorInfo> obj) {
1390 i::Handle<i::Object> list(info->property_accessors(), info->GetIsolate()); 1336 i::Isolate* isolate = info->GetIsolate();
1337 i::Handle<i::Object> list(info->property_accessors(), isolate);
1391 if (list->IsUndefined()) { 1338 if (list->IsUndefined()) {
1392 list = NeanderArray().value(); 1339 list = NeanderArray(isolate).value();
1393 info->set_property_accessors(*list); 1340 info->set_property_accessors(*list);
1394 } 1341 }
1395 NeanderArray array(list); 1342 NeanderArray array(list);
1396 array.add(obj); 1343 array.add(obj);
1397 } 1344 }
1398 1345
1399 1346
1400 static inline i::Handle<i::TemplateInfo> GetTemplateInfo( 1347 static inline i::Handle<i::TemplateInfo> GetTemplateInfo(
1401 i::Isolate* isolate, 1348 i::Isolate* isolate,
1402 Template* template_obj) { 1349 Template* template_obj) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 i::HandleScope scope(isolate); 1457 i::HandleScope scope(isolate);
1511 EnsureConstructor(isolate, this); 1458 EnsureConstructor(isolate, this);
1512 i::FunctionTemplateInfo* constructor = 1459 i::FunctionTemplateInfo* constructor =
1513 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); 1460 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());
1514 i::Handle<i::FunctionTemplateInfo> cons(constructor); 1461 i::Handle<i::FunctionTemplateInfo> cons(constructor);
1515 cons->set_undetectable(true); 1462 cons->set_undetectable(true);
1516 } 1463 }
1517 1464
1518 1465
1519 void ObjectTemplate::SetAccessCheckCallbacks( 1466 void ObjectTemplate::SetAccessCheckCallbacks(
1520 NamedSecurityCallback named_callback, 1467 NamedSecurityCallback named_callback,
1521 IndexedSecurityCallback indexed_callback, 1468 IndexedSecurityCallback indexed_callback,
1522 Handle<Value> data, 1469 Handle<Value> data,
1523 bool turned_on_by_default) { 1470 bool turned_on_by_default) {
1524 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1471 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1525 ENTER_V8(isolate); 1472 ENTER_V8(isolate);
1526 i::HandleScope scope(isolate); 1473 i::HandleScope scope(isolate);
1527 EnsureConstructor(isolate, this); 1474 EnsureConstructor(isolate, this);
1528 1475
1529 i::Handle<i::Struct> struct_info = 1476 i::Handle<i::Struct> struct_info =
1530 isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE); 1477 isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE);
1531 i::Handle<i::AccessCheckInfo> info = 1478 i::Handle<i::AccessCheckInfo> info =
1532 i::Handle<i::AccessCheckInfo>::cast(struct_info); 1479 i::Handle<i::AccessCheckInfo>::cast(struct_info);
1533 1480
1534 SET_FIELD_WRAPPED(info, set_named_callback, named_callback); 1481 SET_FIELD_WRAPPED(info, set_named_callback, named_callback);
1535 SET_FIELD_WRAPPED(info, set_indexed_callback, indexed_callback); 1482 SET_FIELD_WRAPPED(info, set_indexed_callback, indexed_callback);
1536 1483
1537 if (data.IsEmpty()) { 1484 if (data.IsEmpty()) {
1538 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); 1485 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
1539 } 1486 }
1540 info->set_data(*Utils::OpenHandle(*data)); 1487 info->set_data(*Utils::OpenHandle(*data));
1541 1488
1542 i::FunctionTemplateInfo* constructor = 1489 i::FunctionTemplateInfo* constructor =
1543 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); 1490 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());
1544 i::Handle<i::FunctionTemplateInfo> cons(constructor); 1491 i::Handle<i::FunctionTemplateInfo> cons(constructor);
1545 cons->set_access_check_info(*info); 1492 cons->set_access_check_info(*info);
1546 cons->set_needs_access_check(turned_on_by_default); 1493 cons->set_needs_access_check(turned_on_by_default);
1547 } 1494 }
1548 1495
1549 1496
1550 void ObjectTemplate::SetIndexedPropertyHandler( 1497 void ObjectTemplate::SetIndexedPropertyHandler(
1551 IndexedPropertyGetterCallback getter, 1498 IndexedPropertyGetterCallback getter,
1552 IndexedPropertySetterCallback setter, 1499 IndexedPropertySetterCallback setter,
1553 IndexedPropertyQueryCallback query, 1500 IndexedPropertyQueryCallback query,
1554 IndexedPropertyDeleterCallback remover, 1501 IndexedPropertyDeleterCallback remover,
1555 IndexedPropertyEnumeratorCallback enumerator, 1502 IndexedPropertyEnumeratorCallback enumerator,
1556 Handle<Value> data) { 1503 Handle<Value> data) {
1557 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1504 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1558 ENTER_V8(isolate); 1505 ENTER_V8(isolate);
1559 i::HandleScope scope(isolate); 1506 i::HandleScope scope(isolate);
1560 EnsureConstructor(isolate, this); 1507 EnsureConstructor(isolate, this);
1561 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( 1508 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast(
1562 Utils::OpenHandle(this)->constructor()); 1509 Utils::OpenHandle(this)->constructor());
1563 i::Handle<i::FunctionTemplateInfo> cons(constructor); 1510 i::Handle<i::FunctionTemplateInfo> cons(constructor);
1564 i::Handle<i::Struct> struct_obj = 1511 i::Handle<i::Struct> struct_obj =
1565 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); 1512 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE);
1566 i::Handle<i::InterceptorInfo> obj = 1513 i::Handle<i::InterceptorInfo> obj =
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 } 1549 }
1603 1550
1604 1551
1605 int ObjectTemplate::InternalFieldCount() { 1552 int ObjectTemplate::InternalFieldCount() {
1606 return i::Smi::cast(Utils::OpenHandle(this)->internal_field_count())->value(); 1553 return i::Smi::cast(Utils::OpenHandle(this)->internal_field_count())->value();
1607 } 1554 }
1608 1555
1609 1556
1610 void ObjectTemplate::SetInternalFieldCount(int value) { 1557 void ObjectTemplate::SetInternalFieldCount(int value) {
1611 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1558 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1612 if (!ApiCheck(i::Smi::IsValid(value), 1559 if (!Utils::ApiCheck(i::Smi::IsValid(value),
1613 "v8::ObjectTemplate::SetInternalFieldCount()", 1560 "v8::ObjectTemplate::SetInternalFieldCount()",
1614 "Invalid internal field count")) { 1561 "Invalid internal field count")) {
1615 return; 1562 return;
1616 } 1563 }
1617 ENTER_V8(isolate); 1564 ENTER_V8(isolate);
1618 if (value > 0) { 1565 if (value > 0) {
1619 // The internal field count is set by the constructor function's 1566 // The internal field count is set by the constructor function's
1620 // construct code, so we ensure that there is a constructor 1567 // construct code, so we ensure that there is a constructor
1621 // function to do the setting. 1568 // function to do the setting.
1622 EnsureConstructor(isolate, this); 1569 EnsureConstructor(isolate, this);
1623 } 1570 }
1624 Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value)); 1571 Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value));
1625 } 1572 }
1626 1573
1627 1574
1628 // --- S c r i p t D a t a --- 1575 // --- S c r i p t D a t a ---
1629 1576
1630 1577
1631 ScriptData* ScriptData::PreCompile(v8::Isolate* isolate,
1632 const char* input,
1633 int length) {
1634 i::Utf8ToUtf16CharacterStream stream(
1635 reinterpret_cast<const unsigned char*>(input), length);
1636 return i::PreParserApi::PreParse(
1637 reinterpret_cast<i::Isolate*>(isolate), &stream);
1638 }
1639
1640
1641 ScriptData* ScriptData::PreCompile(v8::Handle<String> source) { 1578 ScriptData* ScriptData::PreCompile(v8::Handle<String> source) {
1642 i::Handle<i::String> str = Utils::OpenHandle(*source); 1579 i::Handle<i::String> str = Utils::OpenHandle(*source);
1643 i::Isolate* isolate = str->GetIsolate(); 1580 i::Isolate* isolate = str->GetIsolate();
1644 if (str->IsExternalTwoByteString()) { 1581 if (str->IsExternalTwoByteString()) {
1645 i::ExternalTwoByteStringUtf16CharacterStream stream( 1582 i::ExternalTwoByteStringUtf16CharacterStream stream(
1646 i::Handle<i::ExternalTwoByteString>::cast(str), 0, str->length()); 1583 i::Handle<i::ExternalTwoByteString>::cast(str), 0, str->length());
1647 return i::PreParserApi::PreParse(isolate, &stream); 1584 return i::PreParserApi::PreParse(isolate, &stream);
1648 } else { 1585 } else {
1649 i::GenericStringUtf16CharacterStream stream(str, 0, str->length()); 1586 i::GenericStringUtf16CharacterStream stream(str, 0, str->length());
1650 return i::PreParserApi::PreParse(isolate, &stream); 1587 return i::PreParserApi::PreParse(isolate, &stream);
1651 } 1588 }
1652 } 1589 }
1653 1590
1654 1591
1655 ScriptData* ScriptData::New(const char* data, int length) { 1592 ScriptData* ScriptData::New(const char* data, int length) {
1656 // Return an empty ScriptData if the length is obviously invalid. 1593 // Return an empty ScriptData if the length is obviously invalid.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1713 i::ScriptDataImpl* pre_data_impl = 1650 i::ScriptDataImpl* pre_data_impl =
1714 static_cast<i::ScriptDataImpl*>(pre_data); 1651 static_cast<i::ScriptDataImpl*>(pre_data);
1715 // We assert that the pre-data is sane, even though we can actually 1652 // We assert that the pre-data is sane, even though we can actually
1716 // handle it if it turns out not to be in release mode. 1653 // handle it if it turns out not to be in release mode.
1717 ASSERT(pre_data_impl == NULL || pre_data_impl->SanityCheck()); 1654 ASSERT(pre_data_impl == NULL || pre_data_impl->SanityCheck());
1718 // If the pre-data isn't sane we simply ignore it 1655 // If the pre-data isn't sane we simply ignore it
1719 if (pre_data_impl != NULL && !pre_data_impl->SanityCheck()) { 1656 if (pre_data_impl != NULL && !pre_data_impl->SanityCheck()) {
1720 pre_data_impl = NULL; 1657 pre_data_impl = NULL;
1721 } 1658 }
1722 i::Handle<i::SharedFunctionInfo> result = 1659 i::Handle<i::SharedFunctionInfo> result =
1723 i::Compiler::CompileScript(str, 1660 i::Compiler::CompileScript(str,
1724 name_obj, 1661 name_obj,
1725 line_offset, 1662 line_offset,
1726 column_offset, 1663 column_offset,
1727 is_shared_cross_origin, 1664 is_shared_cross_origin,
1728 isolate->global_context(), 1665 isolate->global_context(),
1729 NULL, 1666 NULL,
1730 pre_data_impl, 1667 pre_data_impl,
1731 Utils::OpenHandle(*script_data, true), 1668 Utils::OpenHandle(*script_data, true),
1732 i::NOT_NATIVES_CODE); 1669 i::NOT_NATIVES_CODE);
1733 has_pending_exception = result.is_null(); 1670 has_pending_exception = result.is_null();
1734 EXCEPTION_BAILOUT_CHECK(isolate, Local<Script>()); 1671 EXCEPTION_BAILOUT_CHECK(isolate, Local<Script>());
1735 raw_result = *result; 1672 raw_result = *result;
1736 } 1673 }
1737 i::Handle<i::SharedFunctionInfo> result(raw_result, isolate); 1674 i::Handle<i::SharedFunctionInfo> result(raw_result, isolate);
1738 return ToApiHandle<Script>(result); 1675 return ToApiHandle<Script>(result);
1739 } 1676 }
1740 1677
1741 1678
1742 Local<Script> Script::New(v8::Handle<String> source, 1679 Local<Script> Script::New(v8::Handle<String> source,
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
2427 bool Value::IsArrayBufferView() const { 2364 bool Value::IsArrayBufferView() const {
2428 return Utils::OpenHandle(this)->IsJSArrayBufferView(); 2365 return Utils::OpenHandle(this)->IsJSArrayBufferView();
2429 } 2366 }
2430 2367
2431 2368
2432 bool Value::IsTypedArray() const { 2369 bool Value::IsTypedArray() const {
2433 return Utils::OpenHandle(this)->IsJSTypedArray(); 2370 return Utils::OpenHandle(this)->IsJSTypedArray();
2434 } 2371 }
2435 2372
2436 2373
2437 #define TYPED_ARRAY_LIST(F) \ 2374 #define TYPED_ARRAY_LIST(F) \
2438 F(Uint8Array, kExternalUnsignedByteArray) \ 2375 F(Uint8Array, kExternalUnsignedByteArray) \
2439 F(Int8Array, kExternalByteArray) \ 2376 F(Int8Array, kExternalByteArray) \
2440 F(Uint16Array, kExternalUnsignedShortArray) \ 2377 F(Uint16Array, kExternalUnsignedShortArray) \
2441 F(Int16Array, kExternalShortArray) \ 2378 F(Int16Array, kExternalShortArray) \
2442 F(Uint32Array, kExternalUnsignedIntArray) \ 2379 F(Uint32Array, kExternalUnsignedIntArray) \
2443 F(Int32Array, kExternalIntArray) \ 2380 F(Int32Array, kExternalIntArray) \
2444 F(Float32Array, kExternalFloatArray) \ 2381 F(Float32Array, kExternalFloatArray) \
2445 F(Float64Array, kExternalDoubleArray) \ 2382 F(Float64Array, kExternalDoubleArray) \
2446 F(Uint8ClampedArray, kExternalPixelArray) 2383 F(Uint8ClampedArray, kExternalPixelArray)
2447 2384
2448 2385
2449 #define VALUE_IS_TYPED_ARRAY(TypedArray, type_const) \ 2386 #define VALUE_IS_TYPED_ARRAY(TypedArray, type_const) \
2450 bool Value::Is##TypedArray() const { \ 2387 bool Value::Is##TypedArray() const { \
2451 i::Handle<i::Object> obj = Utils::OpenHandle(this); \ 2388 i::Handle<i::Object> obj = Utils::OpenHandle(this); \
2452 if (!obj->IsJSTypedArray()) return false; \ 2389 if (!obj->IsJSTypedArray()) return false; \
2453 return i::JSTypedArray::cast(*obj)->type() == type_const; \ 2390 return i::JSTypedArray::cast(*obj)->type() == type_const; \
2454 } 2391 }
2455 2392
2456 TYPED_ARRAY_LIST(VALUE_IS_TYPED_ARRAY) 2393 TYPED_ARRAY_LIST(VALUE_IS_TYPED_ARRAY)
2457 2394
2458 #undef VALUE_IS_TYPED_ARRAY 2395 #undef VALUE_IS_TYPED_ARRAY
2459 2396
2460 2397
2461 bool Value::IsDataView() const { 2398 bool Value::IsDataView() const {
2462 return Utils::OpenHandle(this)->IsJSDataView(); 2399 return Utils::OpenHandle(this)->IsJSDataView();
2463 } 2400 }
(...skipping 28 matching lines...) Expand all
2492 return false; 2429 return false;
2493 } 2430 }
2494 2431
2495 2432
2496 bool Value::IsUint32() const { 2433 bool Value::IsUint32() const {
2497 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2434 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2498 if (obj->IsSmi()) return i::Smi::cast(*obj)->value() >= 0; 2435 if (obj->IsSmi()) return i::Smi::cast(*obj)->value() >= 0;
2499 if (obj->IsNumber()) { 2436 if (obj->IsNumber()) {
2500 double value = obj->Number(); 2437 double value = obj->Number();
2501 return !i::IsMinusZero(value) && 2438 return !i::IsMinusZero(value) &&
2502 value >= 0 && 2439 value >= 0 &&
2503 value <= i::kMaxUInt32 && 2440 value <= i::kMaxUInt32 &&
2504 value == i::FastUI2D(i::FastD2UI(value)); 2441 value == i::FastUI2D(i::FastD2UI(value));
2505 } 2442 }
2506 return false; 2443 return false;
2507 } 2444 }
2508 2445
2509 2446
2510 bool Value::IsDate() const { 2447 bool Value::IsDate() const {
2511 i::Isolate* isolate = i::Isolate::Current(); 2448 i::Isolate* isolate = i::Isolate::Current();
2512 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2449 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2513 return obj->HasSpecificClassOf(isolate->heap()->Date_string()); 2450 return obj->HasSpecificClassOf(isolate->heap()->Date_string());
2514 } 2451 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2546 } 2483 }
2547 2484
2548 2485
2549 static bool CheckConstructor(i::Isolate* isolate, 2486 static bool CheckConstructor(i::Isolate* isolate,
2550 i::Handle<i::JSObject> obj, 2487 i::Handle<i::JSObject> obj,
2551 const char* class_name) { 2488 const char* class_name) {
2552 i::Object* constr = obj->map()->constructor(); 2489 i::Object* constr = obj->map()->constructor();
2553 if (!constr->IsJSFunction()) return false; 2490 if (!constr->IsJSFunction()) return false;
2554 i::JSFunction* func = i::JSFunction::cast(constr); 2491 i::JSFunction* func = i::JSFunction::cast(constr);
2555 return func->shared()->native() && 2492 return func->shared()->native() &&
2556 constr == LookupBuiltin(isolate, class_name); 2493 constr == LookupBuiltin(isolate, class_name);
2557 } 2494 }
2558 2495
2559 2496
2560 bool Value::IsNativeError() const { 2497 bool Value::IsNativeError() const {
2561 i::Isolate* isolate = i::Isolate::Current(); 2498 i::Isolate* isolate = i::Isolate::Current();
2562 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2499 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2563 if (obj->IsJSObject()) { 2500 if (obj->IsJSObject()) {
2564 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*obj)); 2501 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*obj));
2565 return CheckConstructor(isolate, js_obj, "$Error") || 2502 return CheckConstructor(isolate, js_obj, "$Error") ||
2566 CheckConstructor(isolate, js_obj, "$EvalError") || 2503 CheckConstructor(isolate, js_obj, "$EvalError") ||
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2683 EXCEPTION_PREAMBLE(isolate); 2620 EXCEPTION_PREAMBLE(isolate);
2684 num = i::Execution::ToInteger(isolate, obj, &has_pending_exception); 2621 num = i::Execution::ToInteger(isolate, obj, &has_pending_exception);
2685 EXCEPTION_BAILOUT_CHECK(isolate, Local<Integer>()); 2622 EXCEPTION_BAILOUT_CHECK(isolate, Local<Integer>());
2686 } 2623 }
2687 return ToApiHandle<Integer>(num); 2624 return ToApiHandle<Integer>(num);
2688 } 2625 }
2689 2626
2690 2627
2691 void i::Internals::CheckInitializedImpl(v8::Isolate* external_isolate) { 2628 void i::Internals::CheckInitializedImpl(v8::Isolate* external_isolate) {
2692 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate); 2629 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate);
2693 ApiCheck(isolate != NULL && isolate->IsInitialized() && !isolate->IsDead(), 2630 Utils::ApiCheck(isolate != NULL &&
2694 "v8::internal::Internals::CheckInitialized()", 2631 isolate->IsInitialized() &&
2695 "Isolate is not initialized or V8 has died"); 2632 !isolate->IsDead(),
2633 "v8::internal::Internals::CheckInitialized()",
2634 "Isolate is not initialized or V8 has died");
2696 } 2635 }
2697 2636
2698 2637
2699 void External::CheckCast(v8::Value* that) { 2638 void External::CheckCast(v8::Value* that) {
2700 ApiCheck(Utils::OpenHandle(that)->IsExternal(), 2639 Utils::ApiCheck(Utils::OpenHandle(that)->IsExternal(),
2701 "v8::External::Cast()", 2640 "v8::External::Cast()",
2702 "Could not convert to external"); 2641 "Could not convert to external");
2703 } 2642 }
2704 2643
2705 2644
2706 void v8::Object::CheckCast(Value* that) { 2645 void v8::Object::CheckCast(Value* that) {
2707 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2646 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2708 ApiCheck(obj->IsJSObject(), 2647 Utils::ApiCheck(obj->IsJSObject(),
2709 "v8::Object::Cast()", 2648 "v8::Object::Cast()",
2710 "Could not convert to object"); 2649 "Could not convert to object");
2711 } 2650 }
2712 2651
2713 2652
2714 void v8::Function::CheckCast(Value* that) { 2653 void v8::Function::CheckCast(Value* that) {
2715 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2654 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2716 ApiCheck(obj->IsJSFunction(), 2655 Utils::ApiCheck(obj->IsJSFunction(),
2717 "v8::Function::Cast()", 2656 "v8::Function::Cast()",
2718 "Could not convert to function"); 2657 "Could not convert to function");
2719 } 2658 }
2720 2659
2721 2660
2722 void v8::String::CheckCast(v8::Value* that) { 2661 void v8::String::CheckCast(v8::Value* that) {
2723 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2662 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2724 ApiCheck(obj->IsString(), 2663 Utils::ApiCheck(obj->IsString(),
2725 "v8::String::Cast()", 2664 "v8::String::Cast()",
2726 "Could not convert to string"); 2665 "Could not convert to string");
2727 } 2666 }
2728 2667
2729 2668
2730 void v8::Symbol::CheckCast(v8::Value* that) { 2669 void v8::Symbol::CheckCast(v8::Value* that) {
2731 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2670 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2732 ApiCheck(obj->IsSymbol(), 2671 Utils::ApiCheck(obj->IsSymbol(),
2733 "v8::Symbol::Cast()", 2672 "v8::Symbol::Cast()",
2734 "Could not convert to symbol"); 2673 "Could not convert to symbol");
2735 } 2674 }
2736 2675
2737 2676
2738 void v8::Number::CheckCast(v8::Value* that) { 2677 void v8::Number::CheckCast(v8::Value* that) {
2739 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2678 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2740 ApiCheck(obj->IsNumber(), 2679 Utils::ApiCheck(obj->IsNumber(),
2741 "v8::Number::Cast()", 2680 "v8::Number::Cast()",
2742 "Could not convert to number"); 2681 "Could not convert to number");
2743 } 2682 }
2744 2683
2745 2684
2746 void v8::Integer::CheckCast(v8::Value* that) { 2685 void v8::Integer::CheckCast(v8::Value* that) {
2747 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2686 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2748 ApiCheck(obj->IsNumber(), 2687 Utils::ApiCheck(obj->IsNumber(),
2749 "v8::Integer::Cast()", 2688 "v8::Integer::Cast()",
2750 "Could not convert to number"); 2689 "Could not convert to number");
2751 } 2690 }
2752 2691
2753 2692
2754 void v8::Array::CheckCast(Value* that) { 2693 void v8::Array::CheckCast(Value* that) {
2755 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2694 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2756 ApiCheck(obj->IsJSArray(), 2695 Utils::ApiCheck(obj->IsJSArray(),
2757 "v8::Array::Cast()", 2696 "v8::Array::Cast()",
2758 "Could not convert to array"); 2697 "Could not convert to array");
2759 } 2698 }
2760 2699
2761 2700
2762 void v8::ArrayBuffer::CheckCast(Value* that) { 2701 void v8::ArrayBuffer::CheckCast(Value* that) {
2763 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2702 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2764 ApiCheck(obj->IsJSArrayBuffer(), 2703 Utils::ApiCheck(obj->IsJSArrayBuffer(),
2765 "v8::ArrayBuffer::Cast()", 2704 "v8::ArrayBuffer::Cast()",
2766 "Could not convert to ArrayBuffer"); 2705 "Could not convert to ArrayBuffer");
2767 } 2706 }
2768 2707
2769 2708
2770 void v8::ArrayBufferView::CheckCast(Value* that) { 2709 void v8::ArrayBufferView::CheckCast(Value* that) {
2771 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2710 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2772 ApiCheck(obj->IsJSArrayBufferView(), 2711 Utils::ApiCheck(obj->IsJSArrayBufferView(),
2773 "v8::ArrayBufferView::Cast()", 2712 "v8::ArrayBufferView::Cast()",
2774 "Could not convert to ArrayBufferView"); 2713 "Could not convert to ArrayBufferView");
2775 } 2714 }
2776 2715
2777 2716
2778 void v8::TypedArray::CheckCast(Value* that) { 2717 void v8::TypedArray::CheckCast(Value* that) {
2779 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2718 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2780 ApiCheck(obj->IsJSTypedArray(), 2719 Utils::ApiCheck(obj->IsJSTypedArray(),
2781 "v8::TypedArray::Cast()", 2720 "v8::TypedArray::Cast()",
2782 "Could not convert to TypedArray"); 2721 "Could not convert to TypedArray");
2783 } 2722 }
2784 2723
2785 2724
2786 #define CHECK_TYPED_ARRAY_CAST(ApiClass, typeConst) \ 2725 #define CHECK_TYPED_ARRAY_CAST(ApiClass, typeConst) \
2787 void v8::ApiClass::CheckCast(Value* that) { \ 2726 void v8::ApiClass::CheckCast(Value* that) { \
2788 i::Handle<i::Object> obj = Utils::OpenHandle(that); \ 2727 i::Handle<i::Object> obj = Utils::OpenHandle(that); \
2789 ApiCheck(obj->IsJSTypedArray() && \ 2728 Utils::ApiCheck(obj->IsJSTypedArray() && \
2790 i::JSTypedArray::cast(*obj)->type() == typeConst, \ 2729 i::JSTypedArray::cast(*obj)->type() == typeConst, \
2791 "v8::" #ApiClass "::Cast()", \ 2730 "v8::" #ApiClass "::Cast()", \
2792 "Could not convert to " #ApiClass); \ 2731 "Could not convert to " #ApiClass); \
2793 } 2732 }
2794 2733
2795 2734
2796 TYPED_ARRAY_LIST(CHECK_TYPED_ARRAY_CAST) 2735 TYPED_ARRAY_LIST(CHECK_TYPED_ARRAY_CAST)
2797 2736
2798 #undef CHECK_TYPED_ARRAY_CAST 2737 #undef CHECK_TYPED_ARRAY_CAST
2799 2738
2800 2739
2801 void v8::DataView::CheckCast(Value* that) { 2740 void v8::DataView::CheckCast(Value* that) {
2802 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2741 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2803 ApiCheck(obj->IsJSDataView(), 2742 Utils::ApiCheck(obj->IsJSDataView(),
2804 "v8::DataView::Cast()", 2743 "v8::DataView::Cast()",
2805 "Could not convert to DataView"); 2744 "Could not convert to DataView");
2806 } 2745 }
2807 2746
2808 2747
2809 void v8::Date::CheckCast(v8::Value* that) { 2748 void v8::Date::CheckCast(v8::Value* that) {
2810 i::Isolate* isolate = i::Isolate::Current(); 2749 i::Isolate* isolate = i::Isolate::Current();
2811 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2750 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2812 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Date_string()), 2751 Utils::ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Date_string()),
2813 "v8::Date::Cast()", 2752 "v8::Date::Cast()",
2814 "Could not convert to date"); 2753 "Could not convert to date");
2815 } 2754 }
2816 2755
2817 2756
2818 void v8::StringObject::CheckCast(v8::Value* that) { 2757 void v8::StringObject::CheckCast(v8::Value* that) {
2819 i::Isolate* isolate = i::Isolate::Current(); 2758 i::Isolate* isolate = i::Isolate::Current();
2820 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2759 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2821 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->String_string()), 2760 Utils::ApiCheck(obj->HasSpecificClassOf(isolate->heap()->String_string()),
2822 "v8::StringObject::Cast()", 2761 "v8::StringObject::Cast()",
2823 "Could not convert to StringObject"); 2762 "Could not convert to StringObject");
2824 } 2763 }
2825 2764
2826 2765
2827 void v8::SymbolObject::CheckCast(v8::Value* that) { 2766 void v8::SymbolObject::CheckCast(v8::Value* that) {
2828 i::Isolate* isolate = i::Isolate::Current(); 2767 i::Isolate* isolate = i::Isolate::Current();
2829 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2768 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2830 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Symbol_string()), 2769 Utils::ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Symbol_string()),
2831 "v8::SymbolObject::Cast()", 2770 "v8::SymbolObject::Cast()",
2832 "Could not convert to SymbolObject"); 2771 "Could not convert to SymbolObject");
2833 } 2772 }
2834 2773
2835 2774
2836 void v8::NumberObject::CheckCast(v8::Value* that) { 2775 void v8::NumberObject::CheckCast(v8::Value* that) {
2837 i::Isolate* isolate = i::Isolate::Current(); 2776 i::Isolate* isolate = i::Isolate::Current();
2838 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2777 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2839 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Number_string()), 2778 Utils::ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Number_string()),
2840 "v8::NumberObject::Cast()", 2779 "v8::NumberObject::Cast()",
2841 "Could not convert to NumberObject"); 2780 "Could not convert to NumberObject");
2842 } 2781 }
2843 2782
2844 2783
2845 void v8::BooleanObject::CheckCast(v8::Value* that) { 2784 void v8::BooleanObject::CheckCast(v8::Value* that) {
2846 i::Isolate* isolate = i::Isolate::Current(); 2785 i::Isolate* isolate = i::Isolate::Current();
2847 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2786 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2848 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Boolean_string()), 2787 Utils::ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Boolean_string()),
2849 "v8::BooleanObject::Cast()", 2788 "v8::BooleanObject::Cast()",
2850 "Could not convert to BooleanObject"); 2789 "Could not convert to BooleanObject");
2851 } 2790 }
2852 2791
2853 2792
2854 void v8::RegExp::CheckCast(v8::Value* that) { 2793 void v8::RegExp::CheckCast(v8::Value* that) {
2855 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2794 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2856 ApiCheck(obj->IsJSRegExp(), 2795 Utils::ApiCheck(obj->IsJSRegExp(),
2857 "v8::RegExp::Cast()", 2796 "v8::RegExp::Cast()",
2858 "Could not convert to regular expression"); 2797 "Could not convert to regular expression");
2859 } 2798 }
2860 2799
2861 2800
2862 bool Value::BooleanValue() const { 2801 bool Value::BooleanValue() const {
2863 return Utils::OpenHandle(this)->BooleanValue(); 2802 return Utils::OpenHandle(this)->BooleanValue();
2864 } 2803 }
2865 2804
2866 2805
2867 double Value::NumberValue() const { 2806 double Value::NumberValue() const {
2868 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2807 i::Handle<i::Object> obj = Utils::OpenHandle(this);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
2980 return i::Smi::cast(*num)->value(); 2919 return i::Smi::cast(*num)->value();
2981 } else { 2920 } else {
2982 return static_cast<int32_t>(num->Number()); 2921 return static_cast<int32_t>(num->Number());
2983 } 2922 }
2984 } 2923 }
2985 } 2924 }
2986 2925
2987 2926
2988 bool Value::Equals(Handle<Value> that) const { 2927 bool Value::Equals(Handle<Value> that) const {
2989 i::Isolate* isolate = i::Isolate::Current(); 2928 i::Isolate* isolate = i::Isolate::Current();
2990 if (EmptyCheck("v8::Value::Equals()", this) || 2929 if (!Utils::ApiCheck(this != NULL && !that.IsEmpty(),
2991 EmptyCheck("v8::Value::Equals()", that)) { 2930 "v8::Value::Equals()",
2931 "Reading from empty handle")) {
2992 return false; 2932 return false;
2993 } 2933 }
2994 LOG_API(isolate, "Equals"); 2934 LOG_API(isolate, "Equals");
2995 ENTER_V8(isolate); 2935 ENTER_V8(isolate);
2996 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2936 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2997 i::Handle<i::Object> other = Utils::OpenHandle(*that); 2937 i::Handle<i::Object> other = Utils::OpenHandle(*that);
2998 // If both obj and other are JSObjects, we'd better compare by identity 2938 // If both obj and other are JSObjects, we'd better compare by identity
2999 // immediately when going into JS builtin. The reason is Invoke 2939 // immediately when going into JS builtin. The reason is Invoke
3000 // would overwrite global object receiver with global proxy. 2940 // would overwrite global object receiver with global proxy.
3001 if (obj->IsJSObject() && other->IsJSObject()) { 2941 if (obj->IsJSObject() && other->IsJSObject()) {
3002 return *obj == *other; 2942 return *obj == *other;
3003 } 2943 }
3004 i::Handle<i::Object> args[] = { other }; 2944 i::Handle<i::Object> args[] = { other };
3005 EXCEPTION_PREAMBLE(isolate); 2945 EXCEPTION_PREAMBLE(isolate);
3006 i::Handle<i::Object> result = 2946 i::Handle<i::Object> result =
3007 CallV8HeapFunction("EQUALS", obj, ARRAY_SIZE(args), args, 2947 CallV8HeapFunction("EQUALS", obj, ARRAY_SIZE(args), args,
3008 &has_pending_exception); 2948 &has_pending_exception);
3009 EXCEPTION_BAILOUT_CHECK(isolate, false); 2949 EXCEPTION_BAILOUT_CHECK(isolate, false);
3010 return *result == i::Smi::FromInt(i::EQUAL); 2950 return *result == i::Smi::FromInt(i::EQUAL);
3011 } 2951 }
3012 2952
3013 2953
3014 bool Value::StrictEquals(Handle<Value> that) const { 2954 bool Value::StrictEquals(Handle<Value> that) const {
3015 i::Isolate* isolate = i::Isolate::Current(); 2955 i::Isolate* isolate = i::Isolate::Current();
3016 if (EmptyCheck("v8::Value::StrictEquals()", this) || 2956 if (!Utils::ApiCheck(this != NULL && !that.IsEmpty(),
3017 EmptyCheck("v8::Value::StrictEquals()", that)) { 2957 "v8::Value::StrictEquals()",
2958 "Reading from empty handle")) {
3018 return false; 2959 return false;
3019 } 2960 }
3020 LOG_API(isolate, "StrictEquals"); 2961 LOG_API(isolate, "StrictEquals");
3021 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2962 i::Handle<i::Object> obj = Utils::OpenHandle(this);
3022 i::Handle<i::Object> other = Utils::OpenHandle(*that); 2963 i::Handle<i::Object> other = Utils::OpenHandle(*that);
3023 // Must check HeapNumber first, since NaN !== NaN. 2964 // Must check HeapNumber first, since NaN !== NaN.
3024 if (obj->IsHeapNumber()) { 2965 if (obj->IsHeapNumber()) {
3025 if (!other->IsNumber()) return false; 2966 if (!other->IsNumber()) return false;
3026 double x = obj->Number(); 2967 double x = obj->Number();
3027 double y = other->Number(); 2968 double y = other->Number();
3028 // Must check explicitly for NaN:s on Windows, but -0 works fine. 2969 // Must check explicitly for NaN:s on Windows, but -0 works fine.
3029 return x == y && !std::isnan(x) && !std::isnan(y); 2970 return x == y && !std::isnan(x) && !std::isnan(y);
3030 } else if (*obj == *other) { // Also covers Booleans. 2971 } else if (*obj == *other) { // Also covers Booleans.
3031 return true; 2972 return true;
3032 } else if (obj->IsSmi()) { 2973 } else if (obj->IsSmi()) {
3033 return other->IsNumber() && obj->Number() == other->Number(); 2974 return other->IsNumber() && obj->Number() == other->Number();
3034 } else if (obj->IsString()) { 2975 } else if (obj->IsString()) {
3035 return other->IsString() && 2976 return other->IsString() &&
3036 i::String::cast(*obj)->Equals(i::String::cast(*other)); 2977 i::String::cast(*obj)->Equals(i::String::cast(*other));
3037 } else if (obj->IsUndefined() || obj->IsUndetectableObject()) { 2978 } else if (obj->IsUndefined() || obj->IsUndetectableObject()) {
3038 return other->IsUndefined() || other->IsUndetectableObject(); 2979 return other->IsUndefined() || other->IsUndetectableObject();
3039 } else { 2980 } else {
3040 return false; 2981 return false;
3041 } 2982 }
3042 } 2983 }
3043 2984
3044 2985
3045 bool Value::SameValue(Handle<Value> that) const { 2986 bool Value::SameValue(Handle<Value> that) const {
3046 i::Isolate* isolate = i::Isolate::Current(); 2987 i::Isolate* isolate = i::Isolate::Current();
3047 if (EmptyCheck("v8::Value::SameValue()", this) || 2988 if (!Utils::ApiCheck(this != NULL && !that.IsEmpty(),
3048 EmptyCheck("v8::Value::SameValue()", that)) { 2989 "v8::Value::SameValue()",
2990 "Reading from empty handle")) {
3049 return false; 2991 return false;
3050 } 2992 }
3051 LOG_API(isolate, "SameValue"); 2993 LOG_API(isolate, "SameValue");
3052 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2994 i::Handle<i::Object> obj = Utils::OpenHandle(this);
3053 i::Handle<i::Object> other = Utils::OpenHandle(*that); 2995 i::Handle<i::Object> other = Utils::OpenHandle(*that);
3054 return obj->SameValue(*other); 2996 return obj->SameValue(*other);
3055 } 2997 }
3056 2998
3057 2999
3058 uint32_t Value::Uint32Value() const { 3000 uint32_t Value::Uint32Value() const {
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
3561 i::Object::GetProperty(receiver, receiver, lookup, name, 3503 i::Object::GetProperty(receiver, receiver, lookup, name,
3562 &ignored); 3504 &ignored);
3563 has_pending_exception = result.is_null(); 3505 has_pending_exception = result.is_null();
3564 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); 3506 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
3565 3507
3566 return Utils::ToLocal(result); 3508 return Utils::ToLocal(result);
3567 } 3509 }
3568 3510
3569 3511
3570 Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( 3512 Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain(
3571 Handle<String> key) { 3513 Handle<String> key) {
3572 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3514 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3573 ON_BAILOUT(isolate, 3515 ON_BAILOUT(isolate,
3574 "v8::Object::GetRealNamedPropertyInPrototypeChain()", 3516 "v8::Object::GetRealNamedPropertyInPrototypeChain()",
3575 return Local<Value>()); 3517 return Local<Value>());
3576 ENTER_V8(isolate); 3518 ENTER_V8(isolate);
3577 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); 3519 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this);
3578 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 3520 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
3579 i::LookupResult lookup(isolate); 3521 i::LookupResult lookup(isolate);
3580 self_obj->LookupRealNamedPropertyInPrototypes(*key_obj, &lookup); 3522 self_obj->LookupRealNamedPropertyInPrototypes(*key_obj, &lookup);
3581 return GetPropertyByLookup(isolate, self_obj, key_obj, &lookup); 3523 return GetPropertyByLookup(isolate, self_obj, key_obj, &lookup);
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
3774 } 3716 }
3775 3717
3776 } // namespace 3718 } // namespace
3777 3719
3778 3720
3779 void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) { 3721 void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) {
3780 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3722 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3781 ON_BAILOUT(isolate, "v8::SetElementsToPixelData()", return); 3723 ON_BAILOUT(isolate, "v8::SetElementsToPixelData()", return);
3782 ENTER_V8(isolate); 3724 ENTER_V8(isolate);
3783 i::HandleScope scope(isolate); 3725 i::HandleScope scope(isolate);
3784 if (!ApiCheck(length >= 0 && length <= i::ExternalPixelArray::kMaxLength, 3726 if (!Utils::ApiCheck(length >= 0 &&
3785 "v8::Object::SetIndexedPropertiesToPixelData()", 3727 length <= i::ExternalPixelArray::kMaxLength,
3786 "length exceeds max acceptable value")) { 3728 "v8::Object::SetIndexedPropertiesToPixelData()",
3729 "length exceeds max acceptable value")) {
3787 return; 3730 return;
3788 } 3731 }
3789 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3732 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3790 if (!ApiCheck(!self->IsJSArray(), 3733 if (!Utils::ApiCheck(!self->IsJSArray(),
3791 "v8::Object::SetIndexedPropertiesToPixelData()", 3734 "v8::Object::SetIndexedPropertiesToPixelData()",
3792 "JSArray is not supported")) { 3735 "JSArray is not supported")) {
3793 return; 3736 return;
3794 } 3737 }
3795 PrepareExternalArrayElements(self, data, kExternalPixelArray, length); 3738 PrepareExternalArrayElements(self, data, kExternalPixelArray, length);
3796 } 3739 }
3797 3740
3798 3741
3799 bool v8::Object::HasIndexedPropertiesInPixelData() { 3742 bool v8::Object::HasIndexedPropertiesInPixelData() {
3800 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3743 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3801 ON_BAILOUT(self->GetIsolate(), "v8::HasIndexedPropertiesInPixelData()", 3744 ON_BAILOUT(self->GetIsolate(), "v8::HasIndexedPropertiesInPixelData()",
3802 return false); 3745 return false);
(...skipping 27 matching lines...) Expand all
3830 3773
3831 3774
3832 void v8::Object::SetIndexedPropertiesToExternalArrayData( 3775 void v8::Object::SetIndexedPropertiesToExternalArrayData(
3833 void* data, 3776 void* data,
3834 ExternalArrayType array_type, 3777 ExternalArrayType array_type,
3835 int length) { 3778 int length) {
3836 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3779 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3837 ON_BAILOUT(isolate, "v8::SetIndexedPropertiesToExternalArrayData()", return); 3780 ON_BAILOUT(isolate, "v8::SetIndexedPropertiesToExternalArrayData()", return);
3838 ENTER_V8(isolate); 3781 ENTER_V8(isolate);
3839 i::HandleScope scope(isolate); 3782 i::HandleScope scope(isolate);
3840 if (!ApiCheck(length >= 0 && length <= i::ExternalArray::kMaxLength, 3783 if (!Utils::ApiCheck(length >= 0 && length <= i::ExternalArray::kMaxLength,
3841 "v8::Object::SetIndexedPropertiesToExternalArrayData()", 3784 "v8::Object::SetIndexedPropertiesToExternalArrayData()",
3842 "length exceeds max acceptable value")) { 3785 "length exceeds max acceptable value")) {
3843 return; 3786 return;
3844 } 3787 }
3845 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3788 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3846 if (!ApiCheck(!self->IsJSArray(), 3789 if (!Utils::ApiCheck(!self->IsJSArray(),
3847 "v8::Object::SetIndexedPropertiesToExternalArrayData()", 3790 "v8::Object::SetIndexedPropertiesToExternalArrayData()",
3848 "JSArray is not supported")) { 3791 "JSArray is not supported")) {
3849 return; 3792 return;
3850 } 3793 }
3851 PrepareExternalArrayElements(self, data, array_type, length); 3794 PrepareExternalArrayElements(self, data, array_type, length);
3852 } 3795 }
3853 3796
3854 3797
3855 bool v8::Object::HasIndexedPropertiesInExternalArrayData() { 3798 bool v8::Object::HasIndexedPropertiesInExternalArrayData() {
3856 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3799 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3857 ON_BAILOUT(self->GetIsolate(), 3800 ON_BAILOUT(self->GetIsolate(),
3858 "v8::HasIndexedPropertiesInExternalArrayData()", 3801 "v8::HasIndexedPropertiesInExternalArrayData()",
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
4002 3945
4003 Local<Function> Function::New(Isolate* v8_isolate, 3946 Local<Function> Function::New(Isolate* v8_isolate,
4004 FunctionCallback callback, 3947 FunctionCallback callback,
4005 Local<Value> data, 3948 Local<Value> data,
4006 int length) { 3949 int length) {
4007 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); 3950 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
4008 LOG_API(isolate, "Function::New"); 3951 LOG_API(isolate, "Function::New");
4009 ENTER_V8(isolate); 3952 ENTER_V8(isolate);
4010 return FunctionTemplateNew( 3953 return FunctionTemplateNew(
4011 isolate, callback, data, Local<Signature>(), length, true)-> 3954 isolate, callback, data, Local<Signature>(), length, true)->
4012 GetFunction(); 3955 GetFunction();
4013 } 3956 }
4014 3957
4015 3958
4016 Local<v8::Object> Function::NewInstance() const { 3959 Local<v8::Object> Function::NewInstance() const {
4017 return NewInstance(0, NULL); 3960 return NewInstance(0, NULL);
4018 } 3961 }
4019 3962
4020 3963
4021 Local<v8::Object> Function::NewInstance(int argc, 3964 Local<v8::Object> Function::NewInstance(int argc,
4022 v8::Handle<v8::Value> argv[]) const { 3965 v8::Handle<v8::Value> argv[]) const {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
4085 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); 4028 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
4086 return Utils::ToLocal(i::Handle<i::Object>(func->shared()->inferred_name(), 4029 return Utils::ToLocal(i::Handle<i::Object>(func->shared()->inferred_name(),
4087 func->GetIsolate())); 4030 func->GetIsolate()));
4088 } 4031 }
4089 4032
4090 4033
4091 Handle<Value> Function::GetDisplayName() const { 4034 Handle<Value> Function::GetDisplayName() const {
4092 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 4035 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4093 ON_BAILOUT(isolate, "v8::Function::GetDisplayName()", 4036 ON_BAILOUT(isolate, "v8::Function::GetDisplayName()",
4094 return ToApiHandle<Primitive>( 4037 return ToApiHandle<Primitive>(
4095 isolate->factory()->undefined_value())); 4038 isolate->factory()->undefined_value()));
4096 ENTER_V8(isolate); 4039 ENTER_V8(isolate);
4097 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); 4040 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
4098 i::Handle<i::String> property_name = 4041 i::Handle<i::String> property_name =
4099 isolate->factory()->InternalizeOneByteString( 4042 isolate->factory()->InternalizeOneByteString(
4100 STATIC_ASCII_VECTOR("displayName")); 4043 STATIC_ASCII_VECTOR("displayName"));
4101 i::LookupResult lookup(isolate); 4044 i::LookupResult lookup(isolate);
4102 func->LookupRealNamedProperty(*property_name, &lookup); 4045 func->LookupRealNamedProperty(*property_name, &lookup);
4103 if (lookup.IsFound()) { 4046 if (lookup.IsFound()) {
4104 i::Object* value = lookup.GetLazyValue(); 4047 i::Object* value = lookup.GetLazyValue();
4105 if (value && value->IsString()) { 4048 if (value && value->IsString()) {
4106 i::String* name = i::String::cast(value); 4049 i::String* name = i::String::cast(value);
4107 if (name->length() > 0) return Utils::ToLocal(i::Handle<i::String>(name)); 4050 if (name->length() > 0) return Utils::ToLocal(i::Handle<i::String>(name));
4108 } 4051 }
4109 } 4052 }
4110 return ToApiHandle<Primitive>(isolate->factory()->undefined_value()); 4053 return ToApiHandle<Primitive>(isolate->factory()->undefined_value());
4111 } 4054 }
4112 4055
4113 4056
4114 ScriptOrigin Function::GetScriptOrigin() const { 4057 ScriptOrigin Function::GetScriptOrigin() const {
4115 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); 4058 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
4116 if (func->shared()->script()->IsScript()) { 4059 if (func->shared()->script()->IsScript()) {
4117 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); 4060 i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
4118 i::Handle<i::Object> scriptName = GetScriptNameOrSourceURL(script); 4061 i::Handle<i::Object> scriptName = GetScriptNameOrSourceURL(script);
4062 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(func->GetIsolate());
4119 v8::ScriptOrigin origin( 4063 v8::ScriptOrigin origin(
4120 Utils::ToLocal(scriptName), 4064 Utils::ToLocal(scriptName),
4121 v8::Integer::New(script->line_offset()->value()), 4065 v8::Integer::New(isolate, script->line_offset()->value()),
4122 v8::Integer::New(script->column_offset()->value())); 4066 v8::Integer::New(isolate, script->column_offset()->value()));
4123 return origin; 4067 return origin;
4124 } 4068 }
4125 return v8::ScriptOrigin(Handle<Value>()); 4069 return v8::ScriptOrigin(Handle<Value>());
4126 } 4070 }
4127 4071
4128 4072
4129 const int Function::kLineOffsetNotFound = -1; 4073 const int Function::kLineOffsetNotFound = -1;
4130 4074
4131 4075
4132 int Function::GetScriptLineNumber() const { 4076 int Function::GetScriptLineNumber() const {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
4199 }; 4143 };
4200 static const uintptr_t kOneByteMask = OneByteMask<sizeof(uintptr_t)>::value; 4144 static const uintptr_t kOneByteMask = OneByteMask<sizeof(uintptr_t)>::value;
4201 static const uintptr_t kAlignmentMask = sizeof(uintptr_t) - 1; 4145 static const uintptr_t kAlignmentMask = sizeof(uintptr_t) - 1;
4202 static inline bool Unaligned(const uint16_t* chars) { 4146 static inline bool Unaligned(const uint16_t* chars) {
4203 return reinterpret_cast<const uintptr_t>(chars) & kAlignmentMask; 4147 return reinterpret_cast<const uintptr_t>(chars) & kAlignmentMask;
4204 } 4148 }
4205 4149
4206 4150
4207 static inline const uint16_t* Align(const uint16_t* chars) { 4151 static inline const uint16_t* Align(const uint16_t* chars) {
4208 return reinterpret_cast<uint16_t*>( 4152 return reinterpret_cast<uint16_t*>(
4209 reinterpret_cast<uintptr_t>(chars) & ~kAlignmentMask); 4153 reinterpret_cast<uintptr_t>(chars) & ~kAlignmentMask);
4210 } 4154 }
4211 4155
4212 class ContainsOnlyOneByteHelper { 4156 class ContainsOnlyOneByteHelper {
4213 public: 4157 public:
4214 ContainsOnlyOneByteHelper() : is_one_byte_(true) {} 4158 ContainsOnlyOneByteHelper() : is_one_byte_(true) {}
4215 bool Check(i::String* string) { 4159 bool Check(i::String* string) {
4216 i::ConsString* cons_string = i::String::VisitFlat(this, string, 0); 4160 i::ConsString* cons_string = i::String::VisitFlat(this, string, 0);
4217 if (cons_string == NULL) return is_one_byte_; 4161 if (cons_string == NULL) return is_one_byte_;
4218 return CheckCons(cons_string); 4162 return CheckCons(cons_string);
4219 } 4163 }
4220 void VisitOneByteString(const uint8_t* chars, int length) { 4164 void VisitOneByteString(const uint8_t* chars, int length) {
4221 // Nothing to do. 4165 // Nothing to do.
4222 } 4166 }
4223 void VisitTwoByteString(const uint16_t* chars, int length) { 4167 void VisitTwoByteString(const uint16_t* chars, int length) {
4224 // Accumulated bits. 4168 // Accumulated bits.
4225 uintptr_t acc = 0; 4169 uintptr_t acc = 0;
4226 // Align to uintptr_t. 4170 // Align to uintptr_t.
4227 const uint16_t* end = chars + length; 4171 const uint16_t* end = chars + length;
4228 while (Unaligned(chars) && chars != end) { 4172 while (Unaligned(chars) && chars != end) {
4229 acc |= *chars++; 4173 acc |= *chars++;
4230 } 4174 }
4231 // Read word aligned in blocks, 4175 // Read word aligned in blocks,
4232 // checking the return value at the end of each block. 4176 // checking the return value at the end of each block.
4233 const uint16_t* aligned_end = Align(end); 4177 const uint16_t* aligned_end = Align(end);
4234 const int increment = sizeof(uintptr_t)/sizeof(uint16_t); 4178 const int increment = sizeof(uintptr_t)/sizeof(uint16_t);
4235 const int inner_loops = 16; 4179 const int inner_loops = 16;
4236 while (chars + inner_loops*increment < aligned_end) { 4180 while (chars + inner_loops*increment < aligned_end) {
4237 for (int i = 0; i < inner_loops; i++) { 4181 for (int i = 0; i < inner_loops; i++) {
4238 acc |= *reinterpret_cast<const uintptr_t*>(chars); 4182 acc |= *reinterpret_cast<const uintptr_t*>(chars);
4239 chars += increment; 4183 chars += increment;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
4323 return state & kEndsWithLeadingSurrogate; 4267 return state & kEndsWithLeadingSurrogate;
4324 } 4268 }
4325 4269
4326 static inline bool StartsWithSurrogate(uint8_t state) { 4270 static inline bool StartsWithSurrogate(uint8_t state) {
4327 return state & kStartsWithTrailingSurrogate; 4271 return state & kStartsWithTrailingSurrogate;
4328 } 4272 }
4329 4273
4330 class Visitor { 4274 class Visitor {
4331 public: 4275 public:
4332 inline explicit Visitor() 4276 inline explicit Visitor()
4333 : utf8_length_(0), 4277 : utf8_length_(0),
4334 state_(kInitialState) {} 4278 state_(kInitialState) {}
4335 4279
4336 void VisitOneByteString(const uint8_t* chars, int length) { 4280 void VisitOneByteString(const uint8_t* chars, int length) {
4337 int utf8_length = 0; 4281 int utf8_length = 0;
4338 // Add in length 1 for each non-ASCII character. 4282 // Add in length 1 for each non-ASCII character.
4339 for (int i = 0; i < length; i++) { 4283 for (int i = 0; i < length; i++) {
4340 utf8_length += *chars++ >> 7; 4284 utf8_length += *chars++ >> 7;
4341 } 4285 }
4342 // Add in length 1 for each character. 4286 // Add in length 1 for each character.
4343 utf8_length_ = utf8_length + length; 4287 utf8_length_ = utf8_length + length;
4344 state_ = kInitialState; 4288 state_ = kInitialState;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
4397 } 4341 }
4398 } 4342 }
4399 4343
4400 static inline void MergeLeafRight(int* length, 4344 static inline void MergeLeafRight(int* length,
4401 uint8_t* state, 4345 uint8_t* state,
4402 uint8_t leaf_state) { 4346 uint8_t leaf_state) {
4403 bool edge_surrogate = EndsWithSurrogate(leaf_state); 4347 bool edge_surrogate = EndsWithSurrogate(leaf_state);
4404 if (!(*state & kRightmostEdgeIsCalculated)) { 4348 if (!(*state & kRightmostEdgeIsCalculated)) {
4405 ASSERT(!(*state & kRightmostEdgeIsSurrogate)); 4349 ASSERT(!(*state & kRightmostEdgeIsSurrogate));
4406 *state |= (kRightmostEdgeIsCalculated 4350 *state |= (kRightmostEdgeIsCalculated
4407 | (edge_surrogate ? kRightmostEdgeIsSurrogate : 0)); 4351 | (edge_surrogate ? kRightmostEdgeIsSurrogate : 0));
4408 } else if (edge_surrogate && StartsWithSurrogate(*state)) { 4352 } else if (edge_surrogate && StartsWithSurrogate(*state)) {
4409 *length -= unibrow::Utf8::kBytesSavedByCombiningSurrogates; 4353 *length -= unibrow::Utf8::kBytesSavedByCombiningSurrogates;
4410 } 4354 }
4411 if (StartsWithSurrogate(leaf_state)) { 4355 if (StartsWithSurrogate(leaf_state)) {
4412 *state |= kStartsWithTrailingSurrogate; 4356 *state |= kStartsWithTrailingSurrogate;
4413 } else { 4357 } else {
4414 *state &= ~kStartsWithTrailingSurrogate; 4358 *state &= ~kStartsWithTrailingSurrogate;
4415 } 4359 }
4416 } 4360 }
4417 4361
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
4504 i::Handle<i::String> str = Utils::OpenHandle(this); 4448 i::Handle<i::String> str = Utils::OpenHandle(this);
4505 i::Isolate* isolate = str->GetIsolate(); 4449 i::Isolate* isolate = str->GetIsolate();
4506 return v8::Utf8Length(*str, isolate); 4450 return v8::Utf8Length(*str, isolate);
4507 } 4451 }
4508 4452
4509 4453
4510 class Utf8WriterVisitor { 4454 class Utf8WriterVisitor {
4511 public: 4455 public:
4512 Utf8WriterVisitor( 4456 Utf8WriterVisitor(
4513 char* buffer, int capacity, bool skip_capacity_check) 4457 char* buffer, int capacity, bool skip_capacity_check)
4514 : early_termination_(false), 4458 : early_termination_(false),
4515 last_character_(unibrow::Utf16::kNoPreviousCharacter), 4459 last_character_(unibrow::Utf16::kNoPreviousCharacter),
4516 buffer_(buffer), 4460 buffer_(buffer),
4517 start_(buffer), 4461 start_(buffer),
4518 capacity_(capacity), 4462 capacity_(capacity),
4519 skip_capacity_check_(capacity == -1 || skip_capacity_check), 4463 skip_capacity_check_(capacity == -1 || skip_capacity_check),
4520 utf16_chars_read_(0) { 4464 utf16_chars_read_(0) {
4521 } 4465 }
4522 4466
4523 static int WriteEndCharacter(uint16_t character, 4467 static int WriteEndCharacter(uint16_t character,
4524 int last_character, 4468 int last_character,
4525 int remaining, 4469 int remaining,
4526 char* const buffer) { 4470 char* const buffer) {
4527 using namespace unibrow; 4471 using namespace unibrow;
4528 ASSERT(remaining > 0); 4472 ASSERT(remaining > 0);
4529 // We can't use a local buffer here because Encode needs to modify 4473 // We can't use a local buffer here because Encode needs to modify
4530 // previous characters in the stream. We know, however, that 4474 // previous characters in the stream. We know, however, that
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
4657 char* buffer_; 4601 char* buffer_;
4658 char* const start_; 4602 char* const start_;
4659 int capacity_; 4603 int capacity_;
4660 bool const skip_capacity_check_; 4604 bool const skip_capacity_check_;
4661 int utf16_chars_read_; 4605 int utf16_chars_read_;
4662 DISALLOW_IMPLICIT_CONSTRUCTORS(Utf8WriterVisitor); 4606 DISALLOW_IMPLICIT_CONSTRUCTORS(Utf8WriterVisitor);
4663 }; 4607 };
4664 4608
4665 4609
4666 static bool RecursivelySerializeToUtf8(i::String* current, 4610 static bool RecursivelySerializeToUtf8(i::String* current,
4667 Utf8WriterVisitor* writer, 4611 Utf8WriterVisitor* writer,
4668 int recursion_budget) { 4612 int recursion_budget) {
4669 while (!writer->IsDone()) { 4613 while (!writer->IsDone()) {
4670 i::ConsString* cons_string = i::String::VisitFlat(writer, current); 4614 i::ConsString* cons_string = i::String::VisitFlat(writer, current);
4671 if (cons_string == NULL) return true; // Leaf node. 4615 if (cons_string == NULL) return true; // Leaf node.
4672 if (recursion_budget <= 0) return false; 4616 if (recursion_budget <= 0) return false;
4673 // Must write the left branch first. 4617 // Must write the left branch first.
4674 i::String* first = cons_string->first(); 4618 i::String* first = cons_string->first();
4675 bool success = RecursivelySerializeToUtf8(first, 4619 bool success = RecursivelySerializeToUtf8(first,
4676 writer, 4620 writer,
4677 recursion_budget - 1); 4621 recursion_budget - 1);
4678 if (!success) return false; 4622 if (!success) return false;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
4816 expected = reinterpret_cast<const ExternalStringResourceBase*>(resource); 4760 expected = reinterpret_cast<const ExternalStringResourceBase*>(resource);
4817 expectedEncoding = ASCII_ENCODING; 4761 expectedEncoding = ASCII_ENCODING;
4818 } else if (i::StringShape(*str).IsExternalTwoByte()) { 4762 } else if (i::StringShape(*str).IsExternalTwoByte()) {
4819 const void* resource = 4763 const void* resource =
4820 i::Handle<i::ExternalTwoByteString>::cast(str)->resource(); 4764 i::Handle<i::ExternalTwoByteString>::cast(str)->resource();
4821 expected = reinterpret_cast<const ExternalStringResourceBase*>(resource); 4765 expected = reinterpret_cast<const ExternalStringResourceBase*>(resource);
4822 expectedEncoding = TWO_BYTE_ENCODING; 4766 expectedEncoding = TWO_BYTE_ENCODING;
4823 } else { 4767 } else {
4824 expected = NULL; 4768 expected = NULL;
4825 expectedEncoding = str->IsOneByteRepresentation() ? ASCII_ENCODING 4769 expectedEncoding = str->IsOneByteRepresentation() ? ASCII_ENCODING
4826 : TWO_BYTE_ENCODING; 4770 : TWO_BYTE_ENCODING;
4827 } 4771 }
4828 CHECK_EQ(expected, value); 4772 CHECK_EQ(expected, value);
4829 CHECK_EQ(expectedEncoding, encoding); 4773 CHECK_EQ(expectedEncoding, encoding);
4830 } 4774 }
4831 4775
4832 const v8::String::ExternalAsciiStringResource* 4776 const v8::String::ExternalAsciiStringResource*
4833 v8::String::GetExternalAsciiStringResource() const { 4777 v8::String::GetExternalAsciiStringResource() const {
4834 i::Handle<i::String> str = Utils::OpenHandle(this); 4778 i::Handle<i::String> str = Utils::OpenHandle(this);
4835 if (i::StringShape(*str).IsExternalAscii()) { 4779 if (i::StringShape(*str).IsExternalAscii()) {
4836 const void* resource = 4780 const void* resource =
4837 i::Handle<i::ExternalAsciiString>::cast(str)->resource(); 4781 i::Handle<i::ExternalAsciiString>::cast(str)->resource();
4838 return reinterpret_cast<const ExternalAsciiStringResource*>(resource); 4782 return reinterpret_cast<const ExternalAsciiStringResource*>(resource);
4839 } else { 4783 } else {
4840 return NULL; 4784 return NULL;
4841 } 4785 }
4842 } 4786 }
4843 4787
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
4898 4842
4899 int v8::Object::InternalFieldCount() { 4843 int v8::Object::InternalFieldCount() {
4900 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 4844 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
4901 return obj->GetInternalFieldCount(); 4845 return obj->GetInternalFieldCount();
4902 } 4846 }
4903 4847
4904 4848
4905 static bool InternalFieldOK(i::Handle<i::JSObject> obj, 4849 static bool InternalFieldOK(i::Handle<i::JSObject> obj,
4906 int index, 4850 int index,
4907 const char* location) { 4851 const char* location) {
4908 return ApiCheck(index < obj->GetInternalFieldCount(), 4852 return Utils::ApiCheck(index < obj->GetInternalFieldCount(),
4909 location, 4853 location,
4910 "Internal field out of bounds"); 4854 "Internal field out of bounds");
4911 } 4855 }
4912 4856
4913 4857
4914 Local<Value> v8::Object::SlowGetInternalField(int index) { 4858 Local<Value> v8::Object::SlowGetInternalField(int index) {
4915 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 4859 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
4916 const char* location = "v8::Object::GetInternalField()"; 4860 const char* location = "v8::Object::GetInternalField()";
4917 if (!InternalFieldOK(obj, index, location)) return Local<Value>(); 4861 if (!InternalFieldOK(obj, index, location)) return Local<Value>();
4918 i::Handle<i::Object> value(obj->GetInternalField(index), obj->GetIsolate()); 4862 i::Handle<i::Object> value(obj->GetInternalField(index), obj->GetIsolate());
4919 return Utils::ToLocal(value); 4863 return Utils::ToLocal(value);
4920 } 4864 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
4984 return InitializeHelper(isolate); 4928 return InitializeHelper(isolate);
4985 } 4929 }
4986 4930
4987 4931
4988 void v8::V8::SetEntropySource(EntropySource entropy_source) { 4932 void v8::V8::SetEntropySource(EntropySource entropy_source) {
4989 i::RandomNumberGenerator::SetEntropySource(entropy_source); 4933 i::RandomNumberGenerator::SetEntropySource(entropy_source);
4990 } 4934 }
4991 4935
4992 4936
4993 void v8::V8::SetReturnAddressLocationResolver( 4937 void v8::V8::SetReturnAddressLocationResolver(
4994 ReturnAddressLocationResolver return_address_resolver) { 4938 ReturnAddressLocationResolver return_address_resolver) {
4995 i::V8::SetReturnAddressLocationResolver(return_address_resolver); 4939 i::V8::SetReturnAddressLocationResolver(return_address_resolver);
4996 } 4940 }
4997 4941
4998 4942
4999 bool v8::V8::SetFunctionEntryHook(Isolate* ext_isolate, 4943 bool v8::V8::SetFunctionEntryHook(Isolate* ext_isolate,
5000 FunctionEntryHook entry_hook) { 4944 FunctionEntryHook entry_hook) {
5001 ASSERT(ext_isolate != NULL); 4945 ASSERT(ext_isolate != NULL);
5002 ASSERT(entry_hook != NULL); 4946 ASSERT(entry_hook != NULL);
5003 4947
5004 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(ext_isolate); 4948 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(ext_isolate);
(...skipping 17 matching lines...) Expand all
5022 void v8::V8::SetJitCodeEventHandler( 4966 void v8::V8::SetJitCodeEventHandler(
5023 JitCodeEventOptions options, JitCodeEventHandler event_handler) { 4967 JitCodeEventOptions options, JitCodeEventHandler event_handler) {
5024 i::Isolate* isolate = i::Isolate::Current(); 4968 i::Isolate* isolate = i::Isolate::Current();
5025 // Ensure that logging is initialized for our isolate. 4969 // Ensure that logging is initialized for our isolate.
5026 isolate->InitializeLoggingAndCounters(); 4970 isolate->InitializeLoggingAndCounters();
5027 isolate->logger()->SetCodeEventHandler(options, event_handler); 4971 isolate->logger()->SetCodeEventHandler(options, event_handler);
5028 } 4972 }
5029 4973
5030 void v8::V8::SetArrayBufferAllocator( 4974 void v8::V8::SetArrayBufferAllocator(
5031 ArrayBuffer::Allocator* allocator) { 4975 ArrayBuffer::Allocator* allocator) {
5032 if (!ApiCheck(i::V8::ArrayBufferAllocator() == NULL, 4976 if (!Utils::ApiCheck(i::V8::ArrayBufferAllocator() == NULL,
5033 "v8::V8::SetArrayBufferAllocator", 4977 "v8::V8::SetArrayBufferAllocator",
5034 "ArrayBufferAllocator might only be set once")) 4978 "ArrayBufferAllocator might only be set once"))
5035 return; 4979 return;
5036 i::V8::SetArrayBufferAllocator(allocator); 4980 i::V8::SetArrayBufferAllocator(allocator);
5037 } 4981 }
5038 4982
5039 4983
5040 bool v8::V8::Dispose() { 4984 bool v8::V8::Dispose() {
5041 i::Isolate* isolate = i::Isolate::Current(); 4985 i::Isolate* isolate = i::Isolate::Current();
5042 if (!ApiCheck(isolate != NULL && isolate->IsDefaultIsolate(), 4986 if (!Utils::ApiCheck(isolate != NULL && isolate->IsDefaultIsolate(),
5043 "v8::V8::Dispose()", 4987 "v8::V8::Dispose()",
5044 "Use v8::Isolate::Dispose() for a non-default isolate.")) { 4988 "Use v8::Isolate::Dispose() for non-default isolate.")) {
5045 return false; 4989 return false;
5046 } 4990 }
5047 i::V8::TearDown(); 4991 i::V8::TearDown();
5048 return true; 4992 return true;
5049 } 4993 }
5050 4994
5051 4995
5052 HeapStatistics::HeapStatistics(): total_heap_size_(0), 4996 HeapStatistics::HeapStatistics(): total_heap_size_(0),
5053 total_heap_size_executable_(0), 4997 total_heap_size_executable_(0),
5054 total_physical_size_(0), 4998 total_physical_size_(0),
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
5146 ENTER_V8(isolate); 5090 ENTER_V8(isolate);
5147 v8::Handle<ObjectTemplate> proxy_template = global_template; 5091 v8::Handle<ObjectTemplate> proxy_template = global_template;
5148 i::Handle<i::FunctionTemplateInfo> proxy_constructor; 5092 i::Handle<i::FunctionTemplateInfo> proxy_constructor;
5149 i::Handle<i::FunctionTemplateInfo> global_constructor; 5093 i::Handle<i::FunctionTemplateInfo> global_constructor;
5150 5094
5151 if (!global_template.IsEmpty()) { 5095 if (!global_template.IsEmpty()) {
5152 // Make sure that the global_template has a constructor. 5096 // Make sure that the global_template has a constructor.
5153 global_constructor = EnsureConstructor(isolate, *global_template); 5097 global_constructor = EnsureConstructor(isolate, *global_template);
5154 5098
5155 // Create a fresh template for the global proxy object. 5099 // Create a fresh template for the global proxy object.
5156 proxy_template = ObjectTemplate::New(); 5100 proxy_template = ObjectTemplate::New(
5101 reinterpret_cast<v8::Isolate*>(isolate));
5157 proxy_constructor = EnsureConstructor(isolate, *proxy_template); 5102 proxy_constructor = EnsureConstructor(isolate, *proxy_template);
5158 5103
5159 // Set the global template to be the prototype template of 5104 // Set the global template to be the prototype template of
5160 // global proxy template. 5105 // global proxy template.
5161 proxy_constructor->set_prototype_template( 5106 proxy_constructor->set_prototype_template(
5162 *Utils::OpenHandle(*global_template)); 5107 *Utils::OpenHandle(*global_template));
5163 5108
5164 // Migrate security handlers from global_template to 5109 // Migrate security handlers from global_template to
5165 // proxy_template. Temporarily removing access check 5110 // proxy_template. Temporarily removing access check
5166 // information from the global template. 5111 // information from the global template.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
5252 5197
5253 5198
5254 v8::Local<v8::Object> Context::Global() { 5199 v8::Local<v8::Object> Context::Global() {
5255 i::Handle<i::Context> context = Utils::OpenHandle(this); 5200 i::Handle<i::Context> context = Utils::OpenHandle(this);
5256 i::Isolate* isolate = context->GetIsolate(); 5201 i::Isolate* isolate = context->GetIsolate();
5257 i::Handle<i::Object> global(context->global_proxy(), isolate); 5202 i::Handle<i::Object> global(context->global_proxy(), isolate);
5258 // TODO(dcarney): This should always return the global proxy 5203 // TODO(dcarney): This should always return the global proxy
5259 // but can't presently as calls to GetProtoype will return the wrong result. 5204 // but can't presently as calls to GetProtoype will return the wrong result.
5260 if (i::Handle<i::JSGlobalProxy>::cast( 5205 if (i::Handle<i::JSGlobalProxy>::cast(
5261 global)->IsDetachedFrom(context->global_object())) { 5206 global)->IsDetachedFrom(context->global_object())) {
5262 global = i::Handle<i::Object>(context->global_object(), isolate); 5207 global = i::Handle<i::Object>(context->global_object(), isolate);
5263 } 5208 }
5264 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global)); 5209 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global));
5265 } 5210 }
5266 5211
5267 5212
5268 void Context::DetachGlobal() { 5213 void Context::DetachGlobal() {
5269 i::Handle<i::Context> context = Utils::OpenHandle(this); 5214 i::Handle<i::Context> context = Utils::OpenHandle(this);
5270 i::Isolate* isolate = context->GetIsolate(); 5215 i::Isolate* isolate = context->GetIsolate();
5271 ENTER_V8(isolate); 5216 ENTER_V8(isolate);
5272 isolate->bootstrapper()->DetachGlobal(context); 5217 isolate->bootstrapper()->DetachGlobal(context);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
5343 i::Handle<i::JSObject> external = i_isolate->factory()->NewExternal(value); 5288 i::Handle<i::JSObject> external = i_isolate->factory()->NewExternal(value);
5344 return Utils::ExternalToLocal(external); 5289 return Utils::ExternalToLocal(external);
5345 } 5290 }
5346 5291
5347 5292
5348 void* External::Value() const { 5293 void* External::Value() const {
5349 return ExternalValue(*Utils::OpenHandle(this)); 5294 return ExternalValue(*Utils::OpenHandle(this));
5350 } 5295 }
5351 5296
5352 5297
5353 Local<String> v8::String::Empty() {
5354 i::Isolate* isolate = i::Isolate::Current();
5355 if (!EnsureInitializedForIsolate(isolate, "v8::String::Empty()")) {
5356 return v8::Local<String>();
5357 }
5358 LOG_API(isolate, "String::Empty()");
5359 return Utils::ToLocal(isolate->factory()->empty_string());
5360 }
5361
5362
5363 // anonymous namespace for string creation helper functions 5298 // anonymous namespace for string creation helper functions
5364 namespace { 5299 namespace {
5365 5300
5366 inline int StringLength(const char* string) { 5301 inline int StringLength(const char* string) {
5367 return i::StrLength(string); 5302 return i::StrLength(string);
5368 } 5303 }
5369 5304
5370 5305
5371 inline int StringLength(const uint8_t* string) { 5306 inline int StringLength(const uint8_t* string) {
5372 return i::StrLength(reinterpret_cast<const char*>(string)); 5307 return i::StrLength(reinterpret_cast<const char*>(string));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
5415 inline Local<String> NewString(Isolate* v8_isolate, 5350 inline Local<String> NewString(Isolate* v8_isolate,
5416 const char* location, 5351 const char* location,
5417 const char* env, 5352 const char* env,
5418 const Char* data, 5353 const Char* data,
5419 String::NewStringType type, 5354 String::NewStringType type,
5420 int length) { 5355 int length) {
5421 i::Isolate* isolate = reinterpret_cast<internal::Isolate*>(v8_isolate); 5356 i::Isolate* isolate = reinterpret_cast<internal::Isolate*>(v8_isolate);
5422 EnsureInitializedForIsolate(isolate, location); 5357 EnsureInitializedForIsolate(isolate, location);
5423 LOG_API(isolate, env); 5358 LOG_API(isolate, env);
5424 if (length == 0 && type != String::kUndetectableString) { 5359 if (length == 0 && type != String::kUndetectableString) {
5425 return String::Empty(); 5360 return String::Empty(v8_isolate);
5426 } 5361 }
5427 ENTER_V8(isolate); 5362 ENTER_V8(isolate);
5428 if (length == -1) length = StringLength(data); 5363 if (length == -1) length = StringLength(data);
5429 i::Handle<i::String> result = NewString( 5364 i::Handle<i::String> result = NewString(
5430 isolate->factory(), type, i::Vector<const Char>(data, length)); 5365 isolate->factory(), type, i::Vector<const Char>(data, length));
5431 if (type == String::kUndetectableString) { 5366 if (type == String::kUndetectableString) {
5432 result->MarkAsUndetectable(); 5367 result->MarkAsUndetectable();
5433 } 5368 }
5434 return Utils::ToLocal(result); 5369 return Utils::ToLocal(result);
5435 } 5370 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
5482 EnsureInitializedForIsolate(isolate, "v8::String::New()"); 5417 EnsureInitializedForIsolate(isolate, "v8::String::New()");
5483 LOG_API(isolate, "String::New(char)"); 5418 LOG_API(isolate, "String::New(char)");
5484 ENTER_V8(isolate); 5419 ENTER_V8(isolate);
5485 i::Handle<i::String> right_string = Utils::OpenHandle(*right); 5420 i::Handle<i::String> right_string = Utils::OpenHandle(*right);
5486 i::Handle<i::String> result = isolate->factory()->NewConsString(left_string, 5421 i::Handle<i::String> result = isolate->factory()->NewConsString(left_string,
5487 right_string); 5422 right_string);
5488 return Utils::ToLocal(result); 5423 return Utils::ToLocal(result);
5489 } 5424 }
5490 5425
5491 5426
5492 i::Handle<i::String> NewExternalStringHandle(i::Isolate* isolate, 5427 static i::Handle<i::String> NewExternalStringHandle(
5493 v8::String::ExternalStringResource* resource) { 5428 i::Isolate* isolate,
5494 i::Handle<i::String> result = 5429 v8::String::ExternalStringResource* resource) {
5495 isolate->factory()->NewExternalStringFromTwoByte(resource); 5430 return isolate->factory()->NewExternalStringFromTwoByte(resource);
5496 return result;
5497 } 5431 }
5498 5432
5499 5433
5500 i::Handle<i::String> NewExternalAsciiStringHandle(i::Isolate* isolate, 5434 static i::Handle<i::String> NewExternalAsciiStringHandle(
5501 v8::String::ExternalAsciiStringResource* resource) { 5435 i::Isolate* isolate,
5502 i::Handle<i::String> result = 5436 v8::String::ExternalAsciiStringResource* resource) {
5503 isolate->factory()->NewExternalStringFromAscii(resource); 5437 return isolate->factory()->NewExternalStringFromAscii(resource);
5504 return result;
5505 } 5438 }
5506 5439
5507 5440
5508 bool RedirectToExternalString(i::Isolate* isolate, 5441 static bool RedirectToExternalString(i::Isolate* isolate,
5509 i::Handle<i::String> parent, 5442 i::Handle<i::String> parent,
5510 i::Handle<i::String> external) { 5443 i::Handle<i::String> external) {
5511 if (parent->IsConsString()) { 5444 if (parent->IsConsString()) {
5512 i::Handle<i::ConsString> cons = i::Handle<i::ConsString>::cast(parent); 5445 i::Handle<i::ConsString> cons = i::Handle<i::ConsString>::cast(parent);
5513 cons->set_first(*external); 5446 cons->set_first(*external);
5514 cons->set_second(isolate->heap()->empty_string()); 5447 cons->set_second(isolate->heap()->empty_string());
5515 } else { 5448 } else {
5516 ASSERT(parent->IsSlicedString()); 5449 ASSERT(parent->IsSlicedString());
5517 i::Handle<i::SlicedString> slice = i::Handle<i::SlicedString>::cast(parent); 5450 i::Handle<i::SlicedString> slice = i::Handle<i::SlicedString>::cast(parent);
5518 slice->set_parent(*external); 5451 slice->set_parent(*external);
5519 slice->set_offset(0); 5452 slice->set_offset(0);
5520 } 5453 }
5521 return true; 5454 return true;
5522 } 5455 }
5523 5456
5524 5457
5525 Local<String> v8::String::NewExternal( 5458 Local<String> v8::String::NewExternal(
5526 Isolate* isolate, 5459 Isolate* isolate,
5527 v8::String::ExternalStringResource* resource) { 5460 v8::String::ExternalStringResource* resource) {
5528 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 5461 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5529 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()"); 5462 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()");
5530 LOG_API(i_isolate, "String::NewExternal"); 5463 LOG_API(i_isolate, "String::NewExternal");
5531 ENTER_V8(i_isolate); 5464 ENTER_V8(i_isolate);
5532 CHECK(resource && resource->data()); 5465 CHECK(resource && resource->data());
5533 i::Handle<i::String> result = NewExternalStringHandle(i_isolate, resource); 5466 i::Handle<i::String> result = NewExternalStringHandle(i_isolate, resource);
5534 i_isolate->heap()->external_string_table()->AddString(*result); 5467 i_isolate->heap()->external_string_table()->AddString(*result);
5535 return Utils::ToLocal(result); 5468 return Utils::ToLocal(result);
5536 } 5469 }
5537 5470
(...skipping 28 matching lines...) Expand all
5566 5499
5567 if (result) { 5500 if (result) {
5568 ASSERT(external->IsExternalString()); 5501 ASSERT(external->IsExternalString());
5569 isolate->heap()->external_string_table()->AddString(*external); 5502 isolate->heap()->external_string_table()->AddString(*external);
5570 } 5503 }
5571 return result; 5504 return result;
5572 } 5505 }
5573 5506
5574 5507
5575 Local<String> v8::String::NewExternal( 5508 Local<String> v8::String::NewExternal(
5576 Isolate* isolate, 5509 Isolate* isolate,
5577 v8::String::ExternalAsciiStringResource* resource) { 5510 v8::String::ExternalAsciiStringResource* resource) {
5578 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 5511 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5579 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()"); 5512 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()");
5580 LOG_API(i_isolate, "String::NewExternal"); 5513 LOG_API(i_isolate, "String::NewExternal");
5581 ENTER_V8(i_isolate); 5514 ENTER_V8(i_isolate);
5582 CHECK(resource && resource->data()); 5515 CHECK(resource && resource->data());
5583 i::Handle<i::String> result = 5516 i::Handle<i::String> result =
5584 NewExternalAsciiStringHandle(i_isolate, resource); 5517 NewExternalAsciiStringHandle(i_isolate, resource);
5585 i_isolate->heap()->external_string_table()->AddString(*result); 5518 i_isolate->heap()->external_string_table()->AddString(*result);
5586 return Utils::ToLocal(result); 5519 return Utils::ToLocal(result);
5587 } 5520 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
5646 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 5579 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5647 EnsureInitializedForIsolate(i_isolate, "v8::Object::New()"); 5580 EnsureInitializedForIsolate(i_isolate, "v8::Object::New()");
5648 LOG_API(i_isolate, "Object::New"); 5581 LOG_API(i_isolate, "Object::New");
5649 ENTER_V8(i_isolate); 5582 ENTER_V8(i_isolate);
5650 i::Handle<i::JSObject> obj = 5583 i::Handle<i::JSObject> obj =
5651 i_isolate->factory()->NewJSObject(i_isolate->object_function()); 5584 i_isolate->factory()->NewJSObject(i_isolate->object_function());
5652 return Utils::ToLocal(obj); 5585 return Utils::ToLocal(obj);
5653 } 5586 }
5654 5587
5655 5588
5656 Local<v8::Object> v8::Object::New() {
5657 return New(Isolate::GetCurrent());
5658 }
5659
5660
5661 Local<v8::Value> v8::NumberObject::New(Isolate* isolate, double value) { 5589 Local<v8::Value> v8::NumberObject::New(Isolate* isolate, double value) {
5662 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 5590 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5663 EnsureInitializedForIsolate(i_isolate, "v8::NumberObject::New()"); 5591 EnsureInitializedForIsolate(i_isolate, "v8::NumberObject::New()");
5664 LOG_API(i_isolate, "NumberObject::New"); 5592 LOG_API(i_isolate, "NumberObject::New");
5665 ENTER_V8(i_isolate); 5593 ENTER_V8(i_isolate);
5666 i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value); 5594 i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value);
5667 i::Handle<i::Object> obj = i_isolate->factory()->ToObject(number); 5595 i::Handle<i::Object> obj = i_isolate->factory()->ToObject(number);
5668 return Utils::ToLocal(obj); 5596 return Utils::ToLocal(obj);
5669 } 5597 }
5670 5598
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
5834 } 5762 }
5835 5763
5836 5764
5837 Local<v8::String> v8::RegExp::GetSource() const { 5765 Local<v8::String> v8::RegExp::GetSource() const {
5838 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); 5766 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this);
5839 return Utils::ToLocal(i::Handle<i::String>(obj->Pattern())); 5767 return Utils::ToLocal(i::Handle<i::String>(obj->Pattern()));
5840 } 5768 }
5841 5769
5842 5770
5843 // Assert that the static flags cast in GetFlags is valid. 5771 // Assert that the static flags cast in GetFlags is valid.
5844 #define REGEXP_FLAG_ASSERT_EQ(api_flag, internal_flag) \ 5772 #define REGEXP_FLAG_ASSERT_EQ(api_flag, internal_flag) \
5845 STATIC_ASSERT(static_cast<int>(v8::RegExp::api_flag) == \ 5773 STATIC_ASSERT(static_cast<int>(v8::RegExp::api_flag) == \
5846 static_cast<int>(i::JSRegExp::internal_flag)) 5774 static_cast<int>(i::JSRegExp::internal_flag))
5847 REGEXP_FLAG_ASSERT_EQ(kNone, NONE); 5775 REGEXP_FLAG_ASSERT_EQ(kNone, NONE);
5848 REGEXP_FLAG_ASSERT_EQ(kGlobal, GLOBAL); 5776 REGEXP_FLAG_ASSERT_EQ(kGlobal, GLOBAL);
5849 REGEXP_FLAG_ASSERT_EQ(kIgnoreCase, IGNORE_CASE); 5777 REGEXP_FLAG_ASSERT_EQ(kIgnoreCase, IGNORE_CASE);
5850 REGEXP_FLAG_ASSERT_EQ(kMultiline, MULTILINE); 5778 REGEXP_FLAG_ASSERT_EQ(kMultiline, MULTILINE);
5851 #undef REGEXP_FLAG_ASSERT_EQ 5779 #undef REGEXP_FLAG_ASSERT_EQ
5852 5780
5853 v8::RegExp::Flags v8::RegExp::GetFlags() const { 5781 v8::RegExp::Flags v8::RegExp::GetFlags() const {
5854 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); 5782 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this);
5855 return static_cast<RegExp::Flags>(obj->GetFlags().value()); 5783 return static_cast<RegExp::Flags>(obj->GetFlags().value());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
5903 } 5831 }
5904 5832
5905 5833
5906 bool v8::ArrayBuffer::IsExternal() const { 5834 bool v8::ArrayBuffer::IsExternal() const {
5907 return Utils::OpenHandle(this)->is_external(); 5835 return Utils::OpenHandle(this)->is_external();
5908 } 5836 }
5909 5837
5910 5838
5911 v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() { 5839 v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() {
5912 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); 5840 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this);
5913 ApiCheck(!obj->is_external(), 5841 Utils::ApiCheck(!obj->is_external(),
5914 "v8::ArrayBuffer::Externalize", 5842 "v8::ArrayBuffer::Externalize",
5915 "ArrayBuffer already externalized"); 5843 "ArrayBuffer already externalized");
5916 obj->set_is_external(true); 5844 obj->set_is_external(true);
5917 size_t byte_length = static_cast<size_t>(obj->byte_length()->Number()); 5845 size_t byte_length = static_cast<size_t>(obj->byte_length()->Number());
5918 Contents contents; 5846 Contents contents;
5919 contents.data_ = obj->backing_store(); 5847 contents.data_ = obj->backing_store();
5920 contents.byte_length_ = byte_length; 5848 contents.byte_length_ = byte_length;
5921 return contents; 5849 return contents;
5922 } 5850 }
5923 5851
5924 5852
5925 void v8::ArrayBuffer::Neuter() { 5853 void v8::ArrayBuffer::Neuter() {
5926 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); 5854 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this);
5927 i::Isolate* isolate = obj->GetIsolate(); 5855 i::Isolate* isolate = obj->GetIsolate();
5928 ApiCheck(obj->is_external(), 5856 Utils::ApiCheck(obj->is_external(),
5929 "v8::ArrayBuffer::Neuter", 5857 "v8::ArrayBuffer::Neuter",
5930 "Only externalized ArrayBuffers can be neutered"); 5858 "Only externalized ArrayBuffers can be neutered");
5931 LOG_API(obj->GetIsolate(), "v8::ArrayBuffer::Neuter()"); 5859 LOG_API(obj->GetIsolate(), "v8::ArrayBuffer::Neuter()");
5932 ENTER_V8(isolate); 5860 ENTER_V8(isolate);
5933 5861
5934 for (i::Handle<i::Object> view_obj(obj->weak_first_view(), isolate); 5862 for (i::Handle<i::Object> view_obj(obj->weak_first_view(), isolate);
5935 !view_obj->IsUndefined();) { 5863 !view_obj->IsUndefined();) {
5936 i::Handle<i::JSArrayBufferView> view(i::JSArrayBufferView::cast(*view_obj)); 5864 i::Handle<i::JSArrayBufferView> view(i::JSArrayBufferView::cast(*view_obj));
5937 if (view->IsJSTypedArray()) { 5865 if (view->IsJSTypedArray()) {
5938 i::JSTypedArray::cast(*view)->Neuter(); 5866 i::JSTypedArray::cast(*view)->Neuter();
5939 } else if (view->IsJSDataView()) { 5867 } else if (view->IsJSDataView()) {
5940 i::JSDataView::cast(*view)->Neuter(); 5868 i::JSDataView::cast(*view)->Neuter();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
6004 } 5932 }
6005 5933
6006 5934
6007 static inline void SetupArrayBufferView( 5935 static inline void SetupArrayBufferView(
6008 i::Isolate* isolate, 5936 i::Isolate* isolate,
6009 i::Handle<i::JSArrayBufferView> obj, 5937 i::Handle<i::JSArrayBufferView> obj,
6010 i::Handle<i::JSArrayBuffer> buffer, 5938 i::Handle<i::JSArrayBuffer> buffer,
6011 size_t byte_offset, 5939 size_t byte_offset,
6012 size_t byte_length) { 5940 size_t byte_length) {
6013 ASSERT(byte_offset + byte_length <= 5941 ASSERT(byte_offset + byte_length <=
6014 static_cast<size_t>(buffer->byte_length()->Number())); 5942 static_cast<size_t>(buffer->byte_length()->Number()));
6015 5943
6016 obj->set_buffer(*buffer); 5944 obj->set_buffer(*buffer);
6017 5945
6018 obj->set_weak_next(buffer->weak_first_view()); 5946 obj->set_weak_next(buffer->weak_first_view());
6019 buffer->set_weak_first_view(*obj); 5947 buffer->set_weak_first_view(*obj);
6020 5948
6021 i::Handle<i::Object> byte_offset_object = 5949 i::Handle<i::Object> byte_offset_object =
6022 isolate->factory()->NewNumberFromSize(byte_offset); 5950 isolate->factory()->NewNumberFromSize(byte_offset);
6023 obj->set_byte_offset(*byte_offset_object); 5951 obj->set_byte_offset(*byte_offset_object);
6024 5952
6025 i::Handle<i::Object> byte_length_object = 5953 i::Handle<i::Object> byte_length_object =
6026 isolate->factory()->NewNumberFromSize(byte_length); 5954 isolate->factory()->NewNumberFromSize(byte_length);
6027 obj->set_byte_length(*byte_length_object); 5955 obj->set_byte_length(*byte_length_object);
6028 } 5956 }
6029 5957
6030 template<typename ElementType, 5958 template<typename ElementType,
6031 ExternalArrayType array_type, 5959 ExternalArrayType array_type,
6032 i::ElementsKind elements_kind> 5960 i::ElementsKind elements_kind>
6033 i::Handle<i::JSTypedArray> NewTypedArray( 5961 i::Handle<i::JSTypedArray> NewTypedArray(
6034 i::Isolate* isolate, 5962 i::Isolate* isolate,
6035 Handle<ArrayBuffer> array_buffer, size_t byte_offset, size_t length) { 5963 Handle<ArrayBuffer> array_buffer, size_t byte_offset, size_t length) {
6036 i::Handle<i::JSTypedArray> obj = 5964 i::Handle<i::JSTypedArray> obj =
6037 isolate->factory()->NewJSTypedArray(array_type); 5965 isolate->factory()->NewJSTypedArray(array_type);
6038 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer); 5966 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer);
6039 5967
6040 ASSERT(byte_offset % sizeof(ElementType) == 0); 5968 ASSERT(byte_offset % sizeof(ElementType) == 0);
6041 5969
6042 CHECK(length <= (std::numeric_limits<size_t>::max() / sizeof(ElementType))); 5970 CHECK(length <= (std::numeric_limits<size_t>::max() / sizeof(ElementType)));
6043 size_t byte_length = length * sizeof(ElementType); 5971 size_t byte_length = length * sizeof(ElementType);
6044 SetupArrayBufferView( 5972 SetupArrayBufferView(
6045 isolate, obj, buffer, byte_offset, byte_length); 5973 isolate, obj, buffer, byte_offset, byte_length);
6046 5974
6047 i::Handle<i::Object> length_object = 5975 i::Handle<i::Object> length_object =
6048 isolate->factory()->NewNumberFromSize(length); 5976 isolate->factory()->NewNumberFromSize(length);
6049 obj->set_length(*length_object); 5977 obj->set_length(*length_object);
6050 5978
6051 i::Handle<i::ExternalArray> elements = 5979 i::Handle<i::ExternalArray> elements =
6052 isolate->factory()->NewExternalArray( 5980 isolate->factory()->NewExternalArray(
6053 static_cast<int>(length), array_type, 5981 static_cast<int>(length), array_type,
6054 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); 5982 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset);
6055 obj->set_elements(*elements); 5983 obj->set_elements(*elements);
6056 return obj; 5984 return obj;
6057 } 5985 }
6058 5986
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
6136 if (length == -1) length = i::StrLength(data); 6064 if (length == -1) length = i::StrLength(data);
6137 i::Handle<i::String> name = i_isolate->factory()->NewStringFromUtf8( 6065 i::Handle<i::String> name = i_isolate->factory()->NewStringFromUtf8(
6138 i::Vector<const char>(data, length)); 6066 i::Vector<const char>(data, length));
6139 symbol->set_name(*name); 6067 symbol->set_name(*name);
6140 } 6068 }
6141 Local<Symbol> result = Utils::ToLocal(symbol); 6069 Local<Symbol> result = Utils::ToLocal(symbol);
6142 return v8::Handle<Private>(reinterpret_cast<Private*>(*result)); 6070 return v8::Handle<Private>(reinterpret_cast<Private*>(*result));
6143 } 6071 }
6144 6072
6145 6073
6146 Local<Number> v8::Number::New(double value) {
6147 i::Isolate* isolate = i::Isolate::Current();
6148 EnsureInitializedForIsolate(isolate, "v8::Number::New()");
6149 return Number::New(reinterpret_cast<Isolate*>(isolate), value);
6150 }
6151
6152
6153 Local<Number> v8::Number::New(Isolate* isolate, double value) { 6074 Local<Number> v8::Number::New(Isolate* isolate, double value) {
6154 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); 6075 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
6155 ASSERT(internal_isolate->IsInitialized()); 6076 ASSERT(internal_isolate->IsInitialized());
6156 if (std::isnan(value)) { 6077 if (std::isnan(value)) {
6157 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. 6078 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs.
6158 value = i::OS::nan_value(); 6079 value = i::OS::nan_value();
6159 } 6080 }
6160 ENTER_V8(internal_isolate); 6081 ENTER_V8(internal_isolate);
6161 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); 6082 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value);
6162 return Utils::NumberToLocal(result); 6083 return Utils::NumberToLocal(result);
6163 } 6084 }
6164 6085
6165 6086
6166 Local<Integer> v8::Integer::New(int32_t value) {
6167 i::Isolate* isolate = i::Isolate::UncheckedCurrent();
6168 EnsureInitializedForIsolate(isolate, "v8::Integer::New()");
6169 return v8::Integer::New(reinterpret_cast<Isolate*>(isolate), value);
6170 }
6171
6172
6173 Local<Integer> Integer::NewFromUnsigned(uint32_t value) {
6174 i::Isolate* isolate = i::Isolate::Current();
6175 EnsureInitializedForIsolate(isolate, "v8::Integer::NewFromUnsigned()");
6176 return Integer::NewFromUnsigned(reinterpret_cast<Isolate*>(isolate), value);
6177 }
6178
6179
6180 Local<Integer> v8::Integer::New(int32_t value, Isolate* isolate) {
6181 return Integer::New(isolate, value);
6182 }
6183
6184
6185 Local<Integer> v8::Integer::NewFromUnsigned(uint32_t value, Isolate* isolate) {
6186 return Integer::NewFromUnsigned(isolate, value);
6187 }
6188
6189
6190 Local<Integer> v8::Integer::New(Isolate* isolate, int32_t value) { 6087 Local<Integer> v8::Integer::New(Isolate* isolate, int32_t value) {
6191 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); 6088 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
6192 ASSERT(internal_isolate->IsInitialized()); 6089 ASSERT(internal_isolate->IsInitialized());
6193 if (i::Smi::IsValid(value)) { 6090 if (i::Smi::IsValid(value)) {
6194 return Utils::IntegerToLocal(i::Handle<i::Object>(i::Smi::FromInt(value), 6091 return Utils::IntegerToLocal(i::Handle<i::Object>(i::Smi::FromInt(value),
6195 internal_isolate)); 6092 internal_isolate));
6196 } 6093 }
6197 ENTER_V8(internal_isolate); 6094 ENTER_V8(internal_isolate);
6198 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); 6095 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value);
6199 return Utils::IntegerToLocal(result); 6096 return Utils::IntegerToLocal(result);
6200 } 6097 }
6201 6098
6202 6099
6203 Local<Integer> v8::Integer::NewFromUnsigned(Isolate* isolate, uint32_t value) { 6100 Local<Integer> v8::Integer::NewFromUnsigned(Isolate* isolate, uint32_t value) {
6204 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); 6101 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
6205 ASSERT(internal_isolate->IsInitialized()); 6102 ASSERT(internal_isolate->IsInitialized());
6206 bool fits_into_int32_t = (value & (1 << 31)) == 0; 6103 bool fits_into_int32_t = (value & (1 << 31)) == 0;
6207 if (fits_into_int32_t) { 6104 if (fits_into_int32_t) {
6208 return Integer::New(static_cast<int32_t>(value), isolate); 6105 return Integer::New(isolate, static_cast<int32_t>(value));
6209 } 6106 }
6210 ENTER_V8(internal_isolate); 6107 ENTER_V8(internal_isolate);
6211 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); 6108 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value);
6212 return Utils::IntegerToLocal(result); 6109 return Utils::IntegerToLocal(result);
6213 } 6110 }
6214 6111
6215 6112
6216 #ifdef DEBUG
6217 v8::AssertNoGCScope::AssertNoGCScope(v8::Isolate* isolate) {
6218 disallow_heap_allocation_ = new i::DisallowHeapAllocation();
6219 }
6220
6221
6222 v8::AssertNoGCScope::~AssertNoGCScope() {
6223 delete static_cast<i::DisallowHeapAllocation*>(disallow_heap_allocation_);
6224 }
6225 #endif
6226
6227
6228 void V8::IgnoreOutOfMemoryException() { 6113 void V8::IgnoreOutOfMemoryException() {
6229 EnterIsolateIfNeeded()->set_ignore_out_of_memory(true); 6114 EnterIsolateIfNeeded()->set_ignore_out_of_memory(true);
6230 } 6115 }
6231 6116
6232 6117
6233 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) { 6118 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) {
6234 i::Isolate* isolate = i::Isolate::Current(); 6119 i::Isolate* isolate = i::Isolate::Current();
6235 EnsureInitializedForIsolate(isolate, "v8::V8::AddMessageListener()"); 6120 EnsureInitializedForIsolate(isolate, "v8::V8::AddMessageListener()");
6236 ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false); 6121 ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false);
6237 ENTER_V8(isolate); 6122 ENTER_V8(isolate);
6238 i::HandleScope scope(isolate); 6123 i::HandleScope scope(isolate);
6239 NeanderArray listeners(isolate->factory()->message_listeners()); 6124 NeanderArray listeners(isolate->factory()->message_listeners());
6240 NeanderObject obj(2); 6125 NeanderObject obj(isolate, 2);
6241 obj.set(0, *isolate->factory()->NewForeign(FUNCTION_ADDR(that))); 6126 obj.set(0, *isolate->factory()->NewForeign(FUNCTION_ADDR(that)));
6242 obj.set(1, data.IsEmpty() ? isolate->heap()->undefined_value() 6127 obj.set(1, data.IsEmpty() ? isolate->heap()->undefined_value()
6243 : *Utils::OpenHandle(*data)); 6128 : *Utils::OpenHandle(*data));
6244 listeners.add(obj.value()); 6129 listeners.add(obj.value());
6245 return true; 6130 return true;
6246 } 6131 }
6247 6132
6248 6133
6249 void V8::RemoveMessageListeners(MessageCallback that) { 6134 void V8::RemoveMessageListeners(MessageCallback that) {
6250 i::Isolate* isolate = i::Isolate::Current(); 6135 i::Isolate* isolate = i::Isolate::Current();
6251 EnsureInitializedForIsolate(isolate, "v8::V8::RemoveMessageListener()"); 6136 EnsureInitializedForIsolate(isolate, "v8::V8::RemoveMessageListener()");
6252 ON_BAILOUT(isolate, "v8::V8::RemoveMessageListeners()", return); 6137 ON_BAILOUT(isolate, "v8::V8::RemoveMessageListeners()", return);
6253 ENTER_V8(isolate); 6138 ENTER_V8(isolate);
6254 i::HandleScope scope(isolate); 6139 i::HandleScope scope(isolate);
6255 NeanderArray listeners(isolate->factory()->message_listeners()); 6140 NeanderArray listeners(isolate->factory()->message_listeners());
6256 for (int i = 0; i < listeners.length(); i++) { 6141 for (int i = 0; i < listeners.length(); i++) {
6257 if (listeners.get(i)->IsUndefined()) continue; // skip deleted ones 6142 if (listeners.get(i)->IsUndefined()) continue; // skip deleted ones
6258 6143
6259 NeanderObject listener(i::JSObject::cast(listeners.get(i))); 6144 NeanderObject listener(i::JSObject::cast(listeners.get(i)));
6260 i::Handle<i::Foreign> callback_obj(i::Foreign::cast(listener.get(0))); 6145 i::Handle<i::Foreign> callback_obj(i::Foreign::cast(listener.get(0)));
6261 if (callback_obj->foreign_address() == FUNCTION_ADDR(that)) { 6146 if (callback_obj->foreign_address() == FUNCTION_ADDR(that)) {
6262 listeners.set(i, isolate->heap()->undefined_value()); 6147 listeners.set(i, isolate->heap()->undefined_value());
6263 } 6148 }
6264 } 6149 }
6265 } 6150 }
6266 6151
6267 6152
6268 void V8::SetCaptureStackTraceForUncaughtExceptions( 6153 void V8::SetCaptureStackTraceForUncaughtExceptions(
6269 bool capture, 6154 bool capture,
6270 int frame_limit, 6155 int frame_limit,
6271 StackTrace::StackTraceOptions options) { 6156 StackTrace::StackTraceOptions options) {
6272 i::Isolate::Current()->SetCaptureStackTraceForUncaughtExceptions( 6157 i::Isolate::Current()->SetCaptureStackTraceForUncaughtExceptions(
6273 capture, 6158 capture,
6274 frame_limit, 6159 frame_limit,
6275 options); 6160 options);
6276 } 6161 }
6277 6162
6278 6163
6279 void V8::SetCounterFunction(CounterLookupCallback callback) { 6164 void V8::SetCounterFunction(CounterLookupCallback callback) {
6280 i::Isolate* isolate = EnterIsolateIfNeeded(); 6165 i::Isolate* isolate = EnterIsolateIfNeeded();
6281 isolate->stats_table()->SetCounterFunction(callback); 6166 isolate->stats_table()->SetCounterFunction(callback);
6282 } 6167 }
6283 6168
6284 6169
6285 void V8::SetCreateHistogramFunction(CreateHistogramCallback callback) { 6170 void V8::SetCreateHistogramFunction(CreateHistogramCallback callback) {
6286 i::Isolate* isolate = EnterIsolateIfNeeded(); 6171 i::Isolate* isolate = EnterIsolateIfNeeded();
6287 isolate->stats_table()->SetCreateHistogramFunction(callback); 6172 isolate->stats_table()->SetCreateHistogramFunction(callback);
6288 isolate->InitializeLoggingAndCounters(); 6173 isolate->InitializeLoggingAndCounters();
6289 isolate->counters()->ResetHistograms(); 6174 isolate->counters()->ResetHistograms();
6290 } 6175 }
6291 6176
6292 6177
6293 void V8::SetAddHistogramSampleFunction(AddHistogramSampleCallback callback) { 6178 void V8::SetAddHistogramSampleFunction(AddHistogramSampleCallback callback) {
6294 i::Isolate* isolate = EnterIsolateIfNeeded(); 6179 i::Isolate* isolate = EnterIsolateIfNeeded();
6295 isolate->stats_table()-> 6180 isolate->stats_table()->
6296 SetAddHistogramSampleFunction(callback); 6181 SetAddHistogramSampleFunction(callback);
6297 } 6182 }
6298 6183
6299 void V8::SetFailedAccessCheckCallbackFunction( 6184 void V8::SetFailedAccessCheckCallbackFunction(
6300 FailedAccessCheckCallback callback) { 6185 FailedAccessCheckCallback callback) {
6301 i::Isolate* isolate = i::Isolate::Current(); 6186 i::Isolate* isolate = i::Isolate::Current();
6302 isolate->SetFailedAccessCheckCallback(callback); 6187 isolate->SetFailedAccessCheckCallback(callback);
6303 } 6188 }
6304 6189
6305 6190
6306 int64_t Isolate::AdjustAmountOfExternalAllocatedMemory( 6191 int64_t Isolate::AdjustAmountOfExternalAllocatedMemory(
6307 int64_t change_in_bytes) { 6192 int64_t change_in_bytes) {
6308 i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap(); 6193 i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap();
6309 return heap->AdjustAmountOfExternalAllocatedMemory(change_in_bytes); 6194 return heap->AdjustAmountOfExternalAllocatedMemory(change_in_bytes);
6310 } 6195 }
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
6510 reinterpret_cast<i::Isolate*>(this)->stack_guard()->RequestInterrupt( 6395 reinterpret_cast<i::Isolate*>(this)->stack_guard()->RequestInterrupt(
6511 callback, data); 6396 callback, data);
6512 } 6397 }
6513 6398
6514 6399
6515 void Isolate::ClearInterrupt() { 6400 void Isolate::ClearInterrupt() {
6516 reinterpret_cast<i::Isolate*>(this)->stack_guard()->ClearInterrupt(); 6401 reinterpret_cast<i::Isolate*>(this)->stack_guard()->ClearInterrupt();
6517 } 6402 }
6518 6403
6519 6404
6405 void Isolate::RequestGarbageCollectionForTesting(GarbageCollectionType type) {
6406 CHECK(i::FLAG_expose_gc);
6407 if (type == kMinorGarbageCollection) {
6408 reinterpret_cast<i::Isolate*>(this)->heap()->CollectGarbage(
6409 i::NEW_SPACE, "Isolate::RequestGarbageCollection",
6410 kGCCallbackFlagForced);
6411 } else {
6412 ASSERT_EQ(kFullGarbageCollection, type);
6413 reinterpret_cast<i::Isolate*>(this)->heap()->CollectAllGarbage(
6414 i::Heap::kNoGCFlags, "Isolate::RequestGarbageCollection",
6415 kGCCallbackFlagForced);
6416 }
6417 }
6418
6419
6520 Isolate* Isolate::GetCurrent() { 6420 Isolate* Isolate::GetCurrent() {
6521 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); 6421 i::Isolate* isolate = i::Isolate::UncheckedCurrent();
6522 return reinterpret_cast<Isolate*>(isolate); 6422 return reinterpret_cast<Isolate*>(isolate);
6523 } 6423 }
6524 6424
6525 6425
6526 Isolate* Isolate::New() { 6426 Isolate* Isolate::New() {
6527 i::Isolate* isolate = new i::Isolate(); 6427 i::Isolate* isolate = new i::Isolate();
6528 return reinterpret_cast<Isolate*>(isolate); 6428 return reinterpret_cast<Isolate*>(isolate);
6529 } 6429 }
6530 6430
6531 6431
6532 void Isolate::Dispose() { 6432 void Isolate::Dispose() {
6533 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); 6433 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6534 if (!ApiCheck(!isolate->IsInUse(), 6434 if (!Utils::ApiCheck(!isolate->IsInUse(),
6535 "v8::Isolate::Dispose()", 6435 "v8::Isolate::Dispose()",
6536 "Disposing the isolate that is entered by a thread.")) { 6436 "Disposing the isolate that is entered by a thread.")) {
6537 return; 6437 return;
6538 } 6438 }
6539 isolate->TearDown(); 6439 isolate->TearDown();
6540 } 6440 }
6541 6441
6542 6442
6543 void Isolate::Enter() { 6443 void Isolate::Enter() {
6544 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); 6444 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6545 isolate->Enter(); 6445 isolate->Enter();
6546 } 6446 }
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
7188 } 7088 }
7189 7089
7190 7090
7191 SnapshotObjectId HeapSnapshot::GetMaxSnapshotJSObjectId() const { 7091 SnapshotObjectId HeapSnapshot::GetMaxSnapshotJSObjectId() const {
7192 return ToInternal(this)->max_snapshot_js_object_id(); 7092 return ToInternal(this)->max_snapshot_js_object_id();
7193 } 7093 }
7194 7094
7195 7095
7196 void HeapSnapshot::Serialize(OutputStream* stream, 7096 void HeapSnapshot::Serialize(OutputStream* stream,
7197 HeapSnapshot::SerializationFormat format) const { 7097 HeapSnapshot::SerializationFormat format) const {
7198 ApiCheck(format == kJSON, 7098 Utils::ApiCheck(format == kJSON,
7199 "v8::HeapSnapshot::Serialize", 7099 "v8::HeapSnapshot::Serialize",
7200 "Unknown serialization format"); 7100 "Unknown serialization format");
7201 ApiCheck(stream->GetOutputEncoding() == OutputStream::kAscii, 7101 Utils::ApiCheck(stream->GetOutputEncoding() == OutputStream::kAscii,
7202 "v8::HeapSnapshot::Serialize", 7102 "v8::HeapSnapshot::Serialize",
7203 "Unsupported output encoding"); 7103 "Unsupported output encoding");
7204 ApiCheck(stream->GetChunkSize() > 0, 7104 Utils::ApiCheck(stream->GetChunkSize() > 0,
7205 "v8::HeapSnapshot::Serialize", 7105 "v8::HeapSnapshot::Serialize",
7206 "Invalid stream chunk size"); 7106 "Invalid stream chunk size");
7207 i::HeapSnapshotJSONSerializer serializer(ToInternal(this)); 7107 i::HeapSnapshotJSONSerializer serializer(ToInternal(this));
7208 serializer.Serialize(stream); 7108 serializer.Serialize(stream);
7209 } 7109 }
7210 7110
7211 7111
7212 int HeapProfiler::GetSnapshotCount() { 7112 int HeapProfiler::GetSnapshotCount() {
7213 return reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshotsCount(); 7113 return reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshotsCount();
7214 } 7114 }
7215 7115
7216 7116
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
7523 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7423 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7524 Address callback_address = 7424 Address callback_address =
7525 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7425 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7526 VMState<EXTERNAL> state(isolate); 7426 VMState<EXTERNAL> state(isolate);
7527 ExternalCallbackScope call_scope(isolate, callback_address); 7427 ExternalCallbackScope call_scope(isolate, callback_address);
7528 callback(info); 7428 callback(info);
7529 } 7429 }
7530 7430
7531 7431
7532 } } // namespace v8::internal 7432 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.h ('k') | src/arm/builtins-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698