OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) \ | 121 #define API_ENTRY_CHECK(isolate, msg) \ |
122 do { \ | 122 do { \ |
123 if (v8::Locker::IsActive()) { \ | 123 if (v8::Locker::IsActive()) { \ |
124 ApiCheck(isolate->thread_manager()->IsLockedByCurrentThread(), \ | 124 Utils::ApiCheck(isolate->thread_manager()->IsLockedByCurrentThread(), \ |
125 msg, \ | 125 msg, \ |
126 "Entering the V8 API without proper locking in place"); \ | 126 "Entering the V8 API without proper locking in place"); \ |
127 } \ | 127 } \ |
128 } while (false) | 128 } while (false) |
129 | 129 |
130 | 130 |
131 // --- E x c e p t i o n B e h a v i o r --- | 131 // --- E x c e p t i o n B e h a v i o r --- |
132 | 132 |
133 | 133 |
134 static void DefaultFatalErrorHandler(const char* location, | 134 static void DefaultFatalErrorHandler(const char* location, |
135 const char* message) { | 135 const char* message) { |
136 i::Isolate* isolate = i::Isolate::Current(); | 136 i::Isolate* isolate = i::Isolate::Current(); |
137 if (isolate->IsInitialized()) { | 137 if (isolate->IsInitialized()) { |
138 i::VMState<i::OTHER> state(isolate); | 138 i::VMState<i::OTHER> state(isolate); |
139 API_Fatal(location, message); | 139 API_Fatal(location, message); |
140 } else { | 140 } else { |
141 API_Fatal(location, message); | 141 API_Fatal(location, message); |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 | 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) { | 146 void i::FatalProcessOutOfMemory(const char* location) { |
156 i::V8::FatalProcessOutOfMemory(location, false); | 147 i::V8::FatalProcessOutOfMemory(location, false); |
157 } | 148 } |
158 | 149 |
159 | 150 |
160 // When V8 cannot allocated memory FatalProcessOutOfMemory is called. | 151 // When V8 cannot allocated memory FatalProcessOutOfMemory is called. |
161 // The default fatal error handler is called and execution is stopped. | 152 // The default fatal error handler is called and execution is stopped. |
162 void i::V8::FatalProcessOutOfMemory(const char* location, bool take_snapshot) { | 153 void i::V8::FatalProcessOutOfMemory(const char* location, bool take_snapshot) { |
163 i::HeapStats heap_stats; | 154 i::HeapStats heap_stats; |
164 int start_marker; | 155 int start_marker; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 int os_error; | 205 int os_error; |
215 heap_stats.os_error = &os_error; | 206 heap_stats.os_error = &os_error; |
216 int end_marker; | 207 int end_marker; |
217 heap_stats.end_marker = &end_marker; | 208 heap_stats.end_marker = &end_marker; |
218 i::Isolate* isolate = i::Isolate::Current(); | 209 i::Isolate* isolate = i::Isolate::Current(); |
219 if (isolate->heap()->HasBeenSetUp()) { | 210 if (isolate->heap()->HasBeenSetUp()) { |
220 // BUG(1718): Don't use the take_snapshot since we don't support | 211 // BUG(1718): Don't use the take_snapshot since we don't support |
221 // HeapIterator here without doing a special GC. | 212 // HeapIterator here without doing a special GC. |
222 isolate->heap()->RecordStats(&heap_stats, false); | 213 isolate->heap()->RecordStats(&heap_stats, false); |
223 } | 214 } |
224 isolate->SignalFatalError(); | 215 Utils::ApiCheck(false, location, "Allocation failed - process out of memory"); |
225 FatalErrorCallback callback = GetFatalErrorHandler(); | 216 // 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"); | 217 FATAL("API fatal error handler returned after process out of memory"); |
230 } | 218 } |
231 | 219 |
232 | 220 |
233 bool Utils::ReportApiFailure(const char* location, const char* message) { | 221 void Utils::ReportApiFailure(const char* location, const char* message) { |
234 FatalErrorCallback callback = GetFatalErrorHandler(); | 222 i::Isolate* isolate = i::Isolate::Current(); |
| 223 FatalErrorCallback callback = isolate->exception_behavior() == NULL |
| 224 ? DefaultFatalErrorHandler |
| 225 : isolate->exception_behavior(); |
235 callback(location, message); | 226 callback(location, message); |
236 i::Isolate* isolate = i::Isolate::Current(); | |
237 isolate->SignalFatalError(); | 227 isolate->SignalFatalError(); |
238 return false; | |
239 } | 228 } |
240 | 229 |
241 | 230 |
242 bool V8::IsDead() { | 231 bool V8::IsDead() { |
243 i::Isolate* isolate = i::Isolate::Current(); | 232 i::Isolate* isolate = i::Isolate::Current(); |
244 return isolate->IsDead(); | 233 return isolate->IsDead(); |
245 } | 234 } |
246 | 235 |
247 | 236 |
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) { | 237 static inline bool IsExecutionTerminatingCheck(i::Isolate* isolate) { |
263 if (!isolate->IsInitialized()) return false; | 238 if (!isolate->IsInitialized()) return false; |
264 if (isolate->has_scheduled_exception()) { | 239 if (isolate->has_scheduled_exception()) { |
265 return isolate->scheduled_exception() == | 240 return isolate->scheduled_exception() == |
266 isolate->heap()->termination_exception(); | 241 isolate->heap()->termination_exception(); |
267 } | 242 } |
268 return false; | 243 return false; |
269 } | 244 } |
270 | 245 |
271 | 246 |
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 --- | 247 // --- S t a t i c s --- |
283 | 248 |
284 | 249 |
285 static bool InitializeHelper(i::Isolate* isolate) { | 250 static bool InitializeHelper(i::Isolate* isolate) { |
286 // If the isolate has a function entry hook, it needs to re-build all its | 251 // 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. | 252 // code stubs with entry hooks embedded, so let's deserialize a snapshot. |
288 if (isolate == NULL || isolate->function_entry_hook() == NULL) { | 253 if (isolate == NULL || isolate->function_entry_hook() == NULL) { |
289 if (i::Snapshot::Initialize()) | 254 if (i::Snapshot::Initialize()) |
290 return true; | 255 return true; |
291 } | 256 } |
292 return i::V8::Initialize(NULL); | 257 return i::V8::Initialize(NULL); |
293 } | 258 } |
294 | 259 |
295 | 260 |
296 static inline bool EnsureInitializedForIsolate(i::Isolate* isolate, | 261 static inline bool EnsureInitializedForIsolate(i::Isolate* isolate, |
297 const char* location) { | 262 const char* location) { |
298 if (isolate != NULL) { | 263 return (isolate != NULL && isolate->IsInitialized()) || |
299 if (isolate->IsInitialized()) return true; | 264 Utils::ApiCheck(InitializeHelper(isolate), |
300 } | 265 location, |
301 ASSERT(isolate == i::Isolate::Current()); | 266 "Error initializing V8"); |
302 return ApiCheck(InitializeHelper(isolate), location, "Error initializing V8"); | |
303 } | 267 } |
304 | 268 |
305 | 269 |
306 // Some initializing API functions are called early and may be | 270 // Some initializing API functions are called early and may be |
307 // called on a thread different from static initializer thread. | 271 // called on a thread different from static initializer thread. |
308 // If Isolate API is used, Isolate::Enter() will initialize TLS so | 272 // If Isolate API is used, Isolate::Enter() will initialize TLS so |
309 // Isolate::Current() works. If it's a legacy case, then the thread | 273 // Isolate::Current() works. If it's a legacy case, then the thread |
310 // may not have TLS initialized yet. However, in initializing APIs it | 274 // may not have TLS initialized yet. However, in initializing APIs it |
311 // may be too early to call EnsureInitialized() - some pre-init | 275 // may be too early to call EnsureInitialized() - some pre-init |
312 // parameters still have to be configured. | 276 // parameters still have to be configured. |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 (source ? static_cast<int>(strlen(source)) : 0)), | 476 (source ? static_cast<int>(strlen(source)) : 0)), |
513 source_(source, source_length_), | 477 source_(source, source_length_), |
514 dep_count_(dep_count), | 478 dep_count_(dep_count), |
515 deps_(deps), | 479 deps_(deps), |
516 auto_enable_(false) { | 480 auto_enable_(false) { |
517 CHECK(source != NULL || source_length_ == 0); | 481 CHECK(source != NULL || source_length_ == 0); |
518 } | 482 } |
519 | 483 |
520 | 484 |
521 ResourceConstraints::ResourceConstraints() | 485 ResourceConstraints::ResourceConstraints() |
522 : max_young_space_size_(0), | 486 : max_young_space_size_(0), |
523 max_old_space_size_(0), | 487 max_old_space_size_(0), |
524 max_executable_size_(0), | 488 max_executable_size_(0), |
525 stack_limit_(NULL), | 489 stack_limit_(NULL), |
526 max_available_threads_(0) { } | 490 max_available_threads_(0) { } |
527 | 491 |
528 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, | 492 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, |
529 uint32_t number_of_processors) { | 493 uint32_t number_of_processors) { |
530 const int lump_of_memory = (i::kPointerSize / 4) * i::MB; | 494 const int lump_of_memory = (i::kPointerSize / 4) * i::MB; |
531 #if V8_OS_ANDROID | 495 #if V8_OS_ANDROID |
532 // Android has higher physical memory requirements before raising the maximum | 496 // Android has higher physical memory requirements before raising the maximum |
533 // heap size limits since it has no swap space. | 497 // heap size limits since it has no swap space. |
534 const uint64_t low_limit = 512ul * i::MB; | 498 const uint64_t low_limit = 512ul * i::MB; |
535 const uint64_t medium_limit = 1ul * i::GB; | 499 const uint64_t medium_limit = 1ul * i::GB; |
536 const uint64_t high_limit = 2ul * i::GB; | 500 const uint64_t high_limit = 2ul * i::GB; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 | 645 |
682 | 646 |
683 EscapableHandleScope::EscapableHandleScope(Isolate* v8_isolate) { | 647 EscapableHandleScope::EscapableHandleScope(Isolate* v8_isolate) { |
684 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 648 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
685 escape_slot_ = CreateHandle(isolate, isolate->heap()->the_hole_value()); | 649 escape_slot_ = CreateHandle(isolate, isolate->heap()->the_hole_value()); |
686 Initialize(v8_isolate); | 650 Initialize(v8_isolate); |
687 } | 651 } |
688 | 652 |
689 | 653 |
690 i::Object** EscapableHandleScope::Escape(i::Object** escape_value) { | 654 i::Object** EscapableHandleScope::Escape(i::Object** escape_value) { |
691 ApiCheck(*escape_slot_ == isolate_->heap()->the_hole_value(), | 655 Utils::ApiCheck(*escape_slot_ == isolate_->heap()->the_hole_value(), |
692 "EscapeableHandleScope::Escape", | 656 "EscapeableHandleScope::Escape", |
693 "Escape value set twice"); | 657 "Escape value set twice"); |
694 if (escape_value == NULL) { | 658 if (escape_value == NULL) { |
695 *escape_slot_ = isolate_->heap()->undefined_value(); | 659 *escape_slot_ = isolate_->heap()->undefined_value(); |
696 return NULL; | 660 return NULL; |
697 } | 661 } |
698 *escape_slot_ = *escape_value; | 662 *escape_slot_ = *escape_value; |
699 return escape_slot_; | 663 return escape_slot_; |
700 } | 664 } |
701 | 665 |
702 | 666 |
703 void Context::Enter() { | 667 void Context::Enter() { |
704 i::Handle<i::Context> env = Utils::OpenHandle(this); | 668 i::Handle<i::Context> env = Utils::OpenHandle(this); |
705 i::Isolate* isolate = env->GetIsolate(); | 669 i::Isolate* isolate = env->GetIsolate(); |
706 ENTER_V8(isolate); | 670 ENTER_V8(isolate); |
707 isolate->handle_scope_implementer()->EnterContext(env); | 671 isolate->handle_scope_implementer()->EnterContext(env); |
708 isolate->handle_scope_implementer()->SaveContext(isolate->context()); | 672 isolate->handle_scope_implementer()->SaveContext(isolate->context()); |
709 isolate->set_context(*env); | 673 isolate->set_context(*env); |
710 } | 674 } |
711 | 675 |
712 | 676 |
713 void Context::Exit() { | 677 void Context::Exit() { |
714 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 678 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
715 i::Handle<i::Context> context = i::Handle<i::Context>::null(); | 679 i::Handle<i::Context> context = i::Handle<i::Context>::null(); |
716 ENTER_V8(isolate); | 680 ENTER_V8(isolate); |
717 if (!ApiCheck(isolate->handle_scope_implementer()->LeaveContext(context), | 681 i::HandleScopeImplementer* impl = isolate->handle_scope_implementer(); |
718 "v8::Context::Exit()", | 682 if (!Utils::ApiCheck(impl->LeaveContext(context), |
719 "Cannot exit non-entered context")) { | 683 "v8::Context::Exit()", |
| 684 "Cannot exit non-entered context")) { |
720 return; | 685 return; |
721 } | 686 } |
722 // Content of 'last_context' could be NULL. | 687 isolate->set_context(impl->RestoreContext()); |
723 i::Context* last_context = | |
724 isolate->handle_scope_implementer()->RestoreContext(); | |
725 isolate->set_context(last_context); | |
726 } | 688 } |
727 | 689 |
728 | 690 |
729 static void* DecodeSmiToAligned(i::Object* value, const char* location) { | 691 static void* DecodeSmiToAligned(i::Object* value, const char* location) { |
730 ApiCheck(value->IsSmi(), location, "Not a Smi"); | 692 Utils::ApiCheck(value->IsSmi(), location, "Not a Smi"); |
731 return reinterpret_cast<void*>(value); | 693 return reinterpret_cast<void*>(value); |
732 } | 694 } |
733 | 695 |
734 | 696 |
735 static i::Smi* EncodeAlignedAsSmi(void* value, const char* location) { | 697 static i::Smi* EncodeAlignedAsSmi(void* value, const char* location) { |
736 i::Smi* smi = reinterpret_cast<i::Smi*>(value); | 698 i::Smi* smi = reinterpret_cast<i::Smi*>(value); |
737 ApiCheck(smi->IsSmi(), location, "Pointer is not aligned"); | 699 Utils::ApiCheck(smi->IsSmi(), location, "Pointer is not aligned"); |
738 return smi; | 700 return smi; |
739 } | 701 } |
740 | 702 |
741 | 703 |
742 static i::Handle<i::FixedArray> EmbedderDataFor(Context* context, | 704 static i::Handle<i::FixedArray> EmbedderDataFor(Context* context, |
743 int index, | 705 int index, |
744 bool can_grow, | 706 bool can_grow, |
745 const char* location) { | 707 const char* location) { |
746 i::Handle<i::Context> env = Utils::OpenHandle(context); | 708 i::Handle<i::Context> env = Utils::OpenHandle(context); |
747 bool ok = | 709 bool ok = |
748 ApiCheck(env->IsNativeContext(), location, "Not a native context") && | 710 Utils::ApiCheck(env->IsNativeContext(), |
749 ApiCheck(index >= 0, location, "Negative index"); | 711 location, |
| 712 "Not a native context") && |
| 713 Utils::ApiCheck(index >= 0, location, "Negative index"); |
750 if (!ok) return i::Handle<i::FixedArray>(); | 714 if (!ok) return i::Handle<i::FixedArray>(); |
751 i::Handle<i::FixedArray> data(env->embedder_data()); | 715 i::Handle<i::FixedArray> data(env->embedder_data()); |
752 if (index < data->length()) return data; | 716 if (index < data->length()) return data; |
753 if (!can_grow) { | 717 if (!Utils::ApiCheck(can_grow, location, "Index too large")) { |
754 Utils::ReportApiFailure(location, "Index too large"); | |
755 return i::Handle<i::FixedArray>(); | 718 return i::Handle<i::FixedArray>(); |
756 } | 719 } |
757 int new_size = i::Max(index, data->length() << 1) + 1; | 720 int new_size = i::Max(index, data->length() << 1) + 1; |
758 data = env->GetIsolate()->factory()->CopySizeFixedArray(data, new_size); | 721 data = env->GetIsolate()->factory()->CopySizeFixedArray(data, new_size); |
759 env->set_embedder_data(*data); | 722 env->set_embedder_data(*data); |
760 return data; | 723 return data; |
761 } | 724 } |
762 | 725 |
763 | 726 |
764 v8::Local<v8::Value> Context::SlowGetEmbedderData(int index) { | 727 v8::Local<v8::Value> Context::SlowGetEmbedderData(int index) { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 | 855 |
893 void Template::Set(v8::Handle<String> name, | 856 void Template::Set(v8::Handle<String> name, |
894 v8::Handle<Data> value, | 857 v8::Handle<Data> value, |
895 v8::PropertyAttribute attribute) { | 858 v8::PropertyAttribute attribute) { |
896 i::Isolate* isolate = i::Isolate::Current(); | 859 i::Isolate* isolate = i::Isolate::Current(); |
897 ENTER_V8(isolate); | 860 ENTER_V8(isolate); |
898 i::HandleScope scope(isolate); | 861 i::HandleScope scope(isolate); |
899 const int kSize = 3; | 862 const int kSize = 3; |
900 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); | 863 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); |
901 v8::Handle<v8::Data> data[kSize] = { | 864 v8::Handle<v8::Data> data[kSize] = { |
902 name, | 865 name, |
903 value, | 866 value, |
904 v8::Integer::New(v8_isolate, attribute)}; | 867 v8::Integer::New(v8_isolate, attribute)}; |
905 TemplateSet(isolate, this, kSize, data); | 868 TemplateSet(isolate, this, kSize, data); |
906 } | 869 } |
907 | 870 |
908 | 871 |
909 void Template::SetAccessorProperty( | 872 void Template::SetAccessorProperty( |
910 v8::Local<v8::String> name, | 873 v8::Local<v8::String> name, |
911 v8::Local<FunctionTemplate> getter, | 874 v8::Local<FunctionTemplate> getter, |
912 v8::Local<FunctionTemplate> setter, | 875 v8::Local<FunctionTemplate> setter, |
913 v8::PropertyAttribute attribute, | 876 v8::PropertyAttribute attribute, |
914 v8::AccessControl access_control) { | 877 v8::AccessControl access_control) { |
915 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 878 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
916 ENTER_V8(isolate); | 879 ENTER_V8(isolate); |
917 ASSERT(!name.IsEmpty()); | 880 ASSERT(!name.IsEmpty()); |
918 ASSERT(!getter.IsEmpty() || !setter.IsEmpty()); | 881 ASSERT(!getter.IsEmpty() || !setter.IsEmpty()); |
919 i::HandleScope scope(isolate); | 882 i::HandleScope scope(isolate); |
920 const int kSize = 5; | 883 const int kSize = 5; |
921 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); | 884 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); |
922 v8::Handle<v8::Data> data[kSize] = { | 885 v8::Handle<v8::Data> data[kSize] = { |
923 name, | 886 name, |
924 getter, | 887 getter, |
925 setter, | 888 setter, |
926 v8::Integer::New(v8_isolate, attribute), | 889 v8::Integer::New(v8_isolate, attribute), |
927 v8::Integer::New(v8_isolate, access_control)}; | 890 v8::Integer::New(v8_isolate, access_control)}; |
928 TemplateSet(isolate, this, kSize, data); | 891 TemplateSet(isolate, this, kSize, data); |
929 } | 892 } |
930 | 893 |
931 | 894 |
932 // --- F u n c t i o n T e m p l a t e --- | 895 // --- F u n c t i o n T e m p l a t e --- |
933 static void InitializeFunctionTemplate( | 896 static void InitializeFunctionTemplate( |
934 i::Handle<i::FunctionTemplateInfo> info) { | 897 i::Handle<i::FunctionTemplateInfo> info) { |
935 info->set_tag(i::Smi::FromInt(Consts::FUNCTION_TEMPLATE)); | 898 info->set_tag(i::Smi::FromInt(Consts::FUNCTION_TEMPLATE)); |
936 info->set_flag(0); | 899 info->set_flag(0); |
937 } | 900 } |
938 | 901 |
939 | 902 |
940 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() { | 903 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() { |
941 i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); | 904 i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); |
942 ENTER_V8(i_isolate); | 905 ENTER_V8(i_isolate); |
943 i::Handle<i::Object> result(Utils::OpenHandle(this)->prototype_template(), | 906 i::Handle<i::Object> result(Utils::OpenHandle(this)->prototype_template(), |
944 i_isolate); | 907 i_isolate); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1024 if (!argv[i].IsEmpty()) | 987 if (!argv[i].IsEmpty()) |
1025 args->set(i, *Utils::OpenHandle(*argv[i])); | 988 args->set(i, *Utils::OpenHandle(*argv[i])); |
1026 } | 989 } |
1027 obj->set_args(*args); | 990 obj->set_args(*args); |
1028 } | 991 } |
1029 return Utils::ToLocal(obj); | 992 return Utils::ToLocal(obj); |
1030 } | 993 } |
1031 | 994 |
1032 | 995 |
1033 Local<AccessorSignature> AccessorSignature::New( | 996 Local<AccessorSignature> AccessorSignature::New( |
1034 Isolate* isolate, | 997 Isolate* isolate, |
1035 Handle<FunctionTemplate> receiver) { | 998 Handle<FunctionTemplate> receiver) { |
1036 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver)); | 999 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver)); |
1037 } | 1000 } |
1038 | 1001 |
1039 | 1002 |
1040 template<typename Operation> | 1003 template<typename Operation> |
1041 static Local<Operation> NewDescriptor( | 1004 static Local<Operation> NewDescriptor( |
1042 Isolate* isolate, | 1005 Isolate* isolate, |
1043 const i::DeclaredAccessorDescriptorData& data, | 1006 const i::DeclaredAccessorDescriptorData& data, |
1044 Data* previous_descriptor) { | 1007 Data* previous_descriptor) { |
1045 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); | 1008 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
1046 i::Handle<i::DeclaredAccessorDescriptor> previous = | 1009 i::Handle<i::DeclaredAccessorDescriptor> previous = |
1047 i::Handle<i::DeclaredAccessorDescriptor>(); | 1010 i::Handle<i::DeclaredAccessorDescriptor>(); |
1048 if (previous_descriptor != NULL) { | 1011 if (previous_descriptor != NULL) { |
1049 previous = Utils::OpenHandle( | 1012 previous = Utils::OpenHandle( |
1050 static_cast<DeclaredAccessorDescriptor*>(previous_descriptor)); | 1013 static_cast<DeclaredAccessorDescriptor*>(previous_descriptor)); |
1051 } | 1014 } |
1052 i::Handle<i::DeclaredAccessorDescriptor> descriptor = | 1015 i::Handle<i::DeclaredAccessorDescriptor> descriptor = |
1053 i::DeclaredAccessorDescriptor::Create(internal_isolate, data, previous); | 1016 i::DeclaredAccessorDescriptor::Create(internal_isolate, data, previous); |
1054 return Utils::Convert<i::DeclaredAccessorDescriptor, Operation>(descriptor); | 1017 return Utils::Convert<i::DeclaredAccessorDescriptor, Operation>(descriptor); |
1055 } | 1018 } |
1056 | 1019 |
1057 | 1020 |
1058 Local<RawOperationDescriptor> | 1021 Local<RawOperationDescriptor> |
1059 ObjectOperationDescriptor::NewInternalFieldDereference( | 1022 ObjectOperationDescriptor::NewInternalFieldDereference( |
1060 Isolate* isolate, | 1023 Isolate* isolate, |
1061 int internal_field) { | 1024 int internal_field) { |
1062 i::DeclaredAccessorDescriptorData data; | 1025 i::DeclaredAccessorDescriptorData data; |
1063 data.type = i::kDescriptorObjectDereference; | 1026 data.type = i::kDescriptorObjectDereference; |
1064 data.object_dereference_descriptor.internal_field = internal_field; | 1027 data.object_dereference_descriptor.internal_field = internal_field; |
1065 return NewDescriptor<RawOperationDescriptor>(isolate, data, NULL); | 1028 return NewDescriptor<RawOperationDescriptor>(isolate, data, NULL); |
1066 } | 1029 } |
1067 | 1030 |
1068 | 1031 |
1069 Local<RawOperationDescriptor> RawOperationDescriptor::NewRawShift( | 1032 Local<RawOperationDescriptor> RawOperationDescriptor::NewRawShift( |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 i::Handle<i::TypeSwitchInfo> info = Utils::OpenHandle(this); | 1147 i::Handle<i::TypeSwitchInfo> info = Utils::OpenHandle(this); |
1185 i::FixedArray* types = i::FixedArray::cast(info->types()); | 1148 i::FixedArray* types = i::FixedArray::cast(info->types()); |
1186 for (int i = 0; i < types->length(); i++) { | 1149 for (int i = 0; i < types->length(); i++) { |
1187 if (i::FunctionTemplateInfo::cast(types->get(i))->IsTemplateFor(*obj)) | 1150 if (i::FunctionTemplateInfo::cast(types->get(i))->IsTemplateFor(*obj)) |
1188 return i + 1; | 1151 return i + 1; |
1189 } | 1152 } |
1190 return 0; | 1153 return 0; |
1191 } | 1154 } |
1192 | 1155 |
1193 | 1156 |
1194 #define SET_FIELD_WRAPPED(obj, setter, cdata) do { \ | 1157 #define SET_FIELD_WRAPPED(obj, setter, cdata) do { \ |
1195 i::Handle<i::Object> foreign = FromCData(obj->GetIsolate(), cdata); \ | 1158 i::Handle<i::Object> foreign = FromCData(obj->GetIsolate(), cdata); \ |
1196 (obj)->setter(*foreign); \ | 1159 (obj)->setter(*foreign); \ |
1197 } while (false) | 1160 } while (false) |
1198 | 1161 |
1199 | 1162 |
1200 void FunctionTemplate::SetCallHandler(FunctionCallback callback, | 1163 void FunctionTemplate::SetCallHandler(FunctionCallback callback, |
1201 v8::Handle<Value> data) { | 1164 v8::Handle<Value> data) { |
1202 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1165 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1203 ENTER_V8(isolate); | 1166 ENTER_V8(isolate); |
1204 i::HandleScope scope(isolate); | 1167 i::HandleScope scope(isolate); |
1205 i::Handle<i::Struct> struct_obj = | 1168 i::Handle<i::Struct> struct_obj = |
1206 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); | 1169 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); |
(...skipping 21 matching lines...) Expand all Loading... |
1228 obj->set_property_attributes(static_cast<PropertyAttributes>(attributes)); | 1191 obj->set_property_attributes(static_cast<PropertyAttributes>(attributes)); |
1229 if (!signature.IsEmpty()) { | 1192 if (!signature.IsEmpty()) { |
1230 obj->set_expected_receiver_type(*Utils::OpenHandle(*signature)); | 1193 obj->set_expected_receiver_type(*Utils::OpenHandle(*signature)); |
1231 } | 1194 } |
1232 return obj; | 1195 return obj; |
1233 } | 1196 } |
1234 | 1197 |
1235 | 1198 |
1236 template<typename Getter, typename Setter> | 1199 template<typename Getter, typename Setter> |
1237 static i::Handle<i::AccessorInfo> MakeAccessorInfo( | 1200 static i::Handle<i::AccessorInfo> MakeAccessorInfo( |
1238 v8::Handle<String> name, | 1201 v8::Handle<String> name, |
1239 Getter getter, | 1202 Getter getter, |
1240 Setter setter, | 1203 Setter setter, |
1241 v8::Handle<Value> data, | 1204 v8::Handle<Value> data, |
1242 v8::AccessControl settings, | 1205 v8::AccessControl settings, |
1243 v8::PropertyAttribute attributes, | 1206 v8::PropertyAttribute attributes, |
1244 v8::Handle<AccessorSignature> signature) { | 1207 v8::Handle<AccessorSignature> signature) { |
1245 i::Isolate* isolate = Utils::OpenHandle(*name)->GetIsolate(); | 1208 i::Isolate* isolate = Utils::OpenHandle(*name)->GetIsolate(); |
1246 i::Handle<i::ExecutableAccessorInfo> obj = | 1209 i::Handle<i::ExecutableAccessorInfo> obj = |
1247 isolate->factory()->NewExecutableAccessorInfo(); | 1210 isolate->factory()->NewExecutableAccessorInfo(); |
1248 SET_FIELD_WRAPPED(obj, set_getter, getter); | 1211 SET_FIELD_WRAPPED(obj, set_getter, getter); |
1249 SET_FIELD_WRAPPED(obj, set_setter, setter); | 1212 SET_FIELD_WRAPPED(obj, set_setter, setter); |
1250 if (data.IsEmpty()) { | 1213 if (data.IsEmpty()) { |
1251 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); | 1214 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); |
1252 } | 1215 } |
1253 obj->set_data(*Utils::OpenHandle(*data)); | 1216 obj->set_data(*Utils::OpenHandle(*data)); |
1254 return SetAccessorInfoProperties(obj, name, settings, attributes, signature); | 1217 return SetAccessorInfoProperties(obj, name, settings, attributes, signature); |
1255 } | 1218 } |
1256 | 1219 |
1257 | 1220 |
1258 static i::Handle<i::AccessorInfo> MakeAccessorInfo( | 1221 static i::Handle<i::AccessorInfo> MakeAccessorInfo( |
1259 v8::Handle<String> name, | 1222 v8::Handle<String> name, |
1260 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor, | 1223 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor, |
1261 void* setter_ignored, | 1224 void* setter_ignored, |
1262 void* data_ignored, | 1225 void* data_ignored, |
1263 v8::AccessControl settings, | 1226 v8::AccessControl settings, |
1264 v8::PropertyAttribute attributes, | 1227 v8::PropertyAttribute attributes, |
1265 v8::Handle<AccessorSignature> signature) { | 1228 v8::Handle<AccessorSignature> signature) { |
1266 i::Isolate* isolate = Utils::OpenHandle(*name)->GetIsolate(); | 1229 i::Isolate* isolate = Utils::OpenHandle(*name)->GetIsolate(); |
1267 if (descriptor.IsEmpty()) return i::Handle<i::DeclaredAccessorInfo>(); | 1230 if (descriptor.IsEmpty()) return i::Handle<i::DeclaredAccessorInfo>(); |
1268 i::Handle<i::DeclaredAccessorInfo> obj = | 1231 i::Handle<i::DeclaredAccessorInfo> obj = |
1269 isolate->factory()->NewDeclaredAccessorInfo(); | 1232 isolate->factory()->NewDeclaredAccessorInfo(); |
1270 obj->set_descriptor(*Utils::OpenHandle(*descriptor)); | 1233 obj->set_descriptor(*Utils::OpenHandle(*descriptor)); |
1271 return SetAccessorInfoProperties(obj, name, settings, attributes, signature); | 1234 return SetAccessorInfoProperties(obj, name, settings, attributes, signature); |
1272 } | 1235 } |
1273 | 1236 |
1274 | 1237 |
1275 Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() { | 1238 Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() { |
1276 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1239 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1277 if (EmptyCheck("v8::FunctionTemplate::InstanceTemplate()", this)) | 1240 if (!Utils::ApiCheck(this != NULL, |
| 1241 "v8::FunctionTemplate::InstanceTemplate()", |
| 1242 "Reading from empty handle")) { |
1278 return Local<ObjectTemplate>(); | 1243 return Local<ObjectTemplate>(); |
| 1244 } |
1279 ENTER_V8(isolate); | 1245 ENTER_V8(isolate); |
1280 i::Handle<i::FunctionTemplateInfo> handle = Utils::OpenHandle(this); | 1246 i::Handle<i::FunctionTemplateInfo> handle = Utils::OpenHandle(this); |
1281 if (handle->instance_template()->IsUndefined()) { | 1247 if (handle->instance_template()->IsUndefined()) { |
1282 Local<ObjectTemplate> templ = | 1248 Local<ObjectTemplate> templ = |
1283 ObjectTemplate::New(isolate, ToApiHandle<FunctionTemplate>(handle)); | 1249 ObjectTemplate::New(isolate, ToApiHandle<FunctionTemplate>(handle)); |
1284 handle->set_instance_template(*Utils::OpenHandle(*templ)); | 1250 handle->set_instance_template(*Utils::OpenHandle(*templ)); |
1285 } | 1251 } |
1286 i::Handle<i::ObjectTemplateInfo> result( | 1252 i::Handle<i::ObjectTemplateInfo> result( |
1287 i::ObjectTemplateInfo::cast(handle->instance_template())); | 1253 i::ObjectTemplateInfo::cast(handle->instance_template())); |
1288 return Utils::ToLocal(result); | 1254 return Utils::ToLocal(result); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 return New(reinterpret_cast<i::Isolate*>(isolate), Local<FunctionTemplate>()); | 1297 return New(reinterpret_cast<i::Isolate*>(isolate), Local<FunctionTemplate>()); |
1332 } | 1298 } |
1333 | 1299 |
1334 | 1300 |
1335 Local<ObjectTemplate> ObjectTemplate::New() { | 1301 Local<ObjectTemplate> ObjectTemplate::New() { |
1336 return New(i::Isolate::Current(), Local<FunctionTemplate>()); | 1302 return New(i::Isolate::Current(), Local<FunctionTemplate>()); |
1337 } | 1303 } |
1338 | 1304 |
1339 | 1305 |
1340 Local<ObjectTemplate> ObjectTemplate::New( | 1306 Local<ObjectTemplate> ObjectTemplate::New( |
1341 i::Isolate* isolate, | 1307 i::Isolate* isolate, |
1342 v8::Handle<FunctionTemplate> constructor) { | 1308 v8::Handle<FunctionTemplate> constructor) { |
1343 EnsureInitializedForIsolate(isolate, "v8::ObjectTemplate::New()"); | 1309 EnsureInitializedForIsolate(isolate, "v8::ObjectTemplate::New()"); |
1344 LOG_API(isolate, "ObjectTemplate::New"); | 1310 LOG_API(isolate, "ObjectTemplate::New"); |
1345 ENTER_V8(isolate); | 1311 ENTER_V8(isolate); |
1346 i::Handle<i::Struct> struct_obj = | 1312 i::Handle<i::Struct> struct_obj = |
1347 isolate->factory()->NewStruct(i::OBJECT_TEMPLATE_INFO_TYPE); | 1313 isolate->factory()->NewStruct(i::OBJECT_TEMPLATE_INFO_TYPE); |
1348 i::Handle<i::ObjectTemplateInfo> obj = | 1314 i::Handle<i::ObjectTemplateInfo> obj = |
1349 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj); | 1315 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj); |
1350 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE); | 1316 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE); |
1351 if (!constructor.IsEmpty()) | 1317 if (!constructor.IsEmpty()) |
1352 obj->set_constructor(*Utils::OpenHandle(*constructor)); | 1318 obj->set_constructor(*Utils::OpenHandle(*constructor)); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1501 i::HandleScope scope(isolate); | 1467 i::HandleScope scope(isolate); |
1502 EnsureConstructor(isolate, this); | 1468 EnsureConstructor(isolate, this); |
1503 i::FunctionTemplateInfo* constructor = | 1469 i::FunctionTemplateInfo* constructor = |
1504 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); | 1470 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); |
1505 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 1471 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
1506 cons->set_undetectable(true); | 1472 cons->set_undetectable(true); |
1507 } | 1473 } |
1508 | 1474 |
1509 | 1475 |
1510 void ObjectTemplate::SetAccessCheckCallbacks( | 1476 void ObjectTemplate::SetAccessCheckCallbacks( |
1511 NamedSecurityCallback named_callback, | 1477 NamedSecurityCallback named_callback, |
1512 IndexedSecurityCallback indexed_callback, | 1478 IndexedSecurityCallback indexed_callback, |
1513 Handle<Value> data, | 1479 Handle<Value> data, |
1514 bool turned_on_by_default) { | 1480 bool turned_on_by_default) { |
1515 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1481 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1516 ENTER_V8(isolate); | 1482 ENTER_V8(isolate); |
1517 i::HandleScope scope(isolate); | 1483 i::HandleScope scope(isolate); |
1518 EnsureConstructor(isolate, this); | 1484 EnsureConstructor(isolate, this); |
1519 | 1485 |
1520 i::Handle<i::Struct> struct_info = | 1486 i::Handle<i::Struct> struct_info = |
1521 isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE); | 1487 isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE); |
1522 i::Handle<i::AccessCheckInfo> info = | 1488 i::Handle<i::AccessCheckInfo> info = |
1523 i::Handle<i::AccessCheckInfo>::cast(struct_info); | 1489 i::Handle<i::AccessCheckInfo>::cast(struct_info); |
1524 | 1490 |
1525 SET_FIELD_WRAPPED(info, set_named_callback, named_callback); | 1491 SET_FIELD_WRAPPED(info, set_named_callback, named_callback); |
1526 SET_FIELD_WRAPPED(info, set_indexed_callback, indexed_callback); | 1492 SET_FIELD_WRAPPED(info, set_indexed_callback, indexed_callback); |
1527 | 1493 |
1528 if (data.IsEmpty()) { | 1494 if (data.IsEmpty()) { |
1529 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); | 1495 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); |
1530 } | 1496 } |
1531 info->set_data(*Utils::OpenHandle(*data)); | 1497 info->set_data(*Utils::OpenHandle(*data)); |
1532 | 1498 |
1533 i::FunctionTemplateInfo* constructor = | 1499 i::FunctionTemplateInfo* constructor = |
1534 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); | 1500 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); |
1535 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 1501 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
1536 cons->set_access_check_info(*info); | 1502 cons->set_access_check_info(*info); |
1537 cons->set_needs_access_check(turned_on_by_default); | 1503 cons->set_needs_access_check(turned_on_by_default); |
1538 } | 1504 } |
1539 | 1505 |
1540 | 1506 |
1541 void ObjectTemplate::SetIndexedPropertyHandler( | 1507 void ObjectTemplate::SetIndexedPropertyHandler( |
1542 IndexedPropertyGetterCallback getter, | 1508 IndexedPropertyGetterCallback getter, |
1543 IndexedPropertySetterCallback setter, | 1509 IndexedPropertySetterCallback setter, |
1544 IndexedPropertyQueryCallback query, | 1510 IndexedPropertyQueryCallback query, |
1545 IndexedPropertyDeleterCallback remover, | 1511 IndexedPropertyDeleterCallback remover, |
1546 IndexedPropertyEnumeratorCallback enumerator, | 1512 IndexedPropertyEnumeratorCallback enumerator, |
1547 Handle<Value> data) { | 1513 Handle<Value> data) { |
1548 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1514 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1549 ENTER_V8(isolate); | 1515 ENTER_V8(isolate); |
1550 i::HandleScope scope(isolate); | 1516 i::HandleScope scope(isolate); |
1551 EnsureConstructor(isolate, this); | 1517 EnsureConstructor(isolate, this); |
1552 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( | 1518 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( |
1553 Utils::OpenHandle(this)->constructor()); | 1519 Utils::OpenHandle(this)->constructor()); |
1554 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 1520 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
1555 i::Handle<i::Struct> struct_obj = | 1521 i::Handle<i::Struct> struct_obj = |
1556 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); | 1522 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); |
1557 i::Handle<i::InterceptorInfo> obj = | 1523 i::Handle<i::InterceptorInfo> obj = |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1593 } | 1559 } |
1594 | 1560 |
1595 | 1561 |
1596 int ObjectTemplate::InternalFieldCount() { | 1562 int ObjectTemplate::InternalFieldCount() { |
1597 return i::Smi::cast(Utils::OpenHandle(this)->internal_field_count())->value(); | 1563 return i::Smi::cast(Utils::OpenHandle(this)->internal_field_count())->value(); |
1598 } | 1564 } |
1599 | 1565 |
1600 | 1566 |
1601 void ObjectTemplate::SetInternalFieldCount(int value) { | 1567 void ObjectTemplate::SetInternalFieldCount(int value) { |
1602 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1568 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1603 if (!ApiCheck(i::Smi::IsValid(value), | 1569 if (!Utils::ApiCheck(i::Smi::IsValid(value), |
1604 "v8::ObjectTemplate::SetInternalFieldCount()", | 1570 "v8::ObjectTemplate::SetInternalFieldCount()", |
1605 "Invalid internal field count")) { | 1571 "Invalid internal field count")) { |
1606 return; | 1572 return; |
1607 } | 1573 } |
1608 ENTER_V8(isolate); | 1574 ENTER_V8(isolate); |
1609 if (value > 0) { | 1575 if (value > 0) { |
1610 // The internal field count is set by the constructor function's | 1576 // The internal field count is set by the constructor function's |
1611 // construct code, so we ensure that there is a constructor | 1577 // construct code, so we ensure that there is a constructor |
1612 // function to do the setting. | 1578 // function to do the setting. |
1613 EnsureConstructor(isolate, this); | 1579 EnsureConstructor(isolate, this); |
1614 } | 1580 } |
1615 Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value)); | 1581 Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value)); |
(...skipping 11 matching lines...) Expand all Loading... |
1627 return i::PreParserApi::PreParse( | 1593 return i::PreParserApi::PreParse( |
1628 reinterpret_cast<i::Isolate*>(isolate), &stream); | 1594 reinterpret_cast<i::Isolate*>(isolate), &stream); |
1629 } | 1595 } |
1630 | 1596 |
1631 | 1597 |
1632 ScriptData* ScriptData::PreCompile(v8::Handle<String> source) { | 1598 ScriptData* ScriptData::PreCompile(v8::Handle<String> source) { |
1633 i::Handle<i::String> str = Utils::OpenHandle(*source); | 1599 i::Handle<i::String> str = Utils::OpenHandle(*source); |
1634 i::Isolate* isolate = str->GetIsolate(); | 1600 i::Isolate* isolate = str->GetIsolate(); |
1635 if (str->IsExternalTwoByteString()) { | 1601 if (str->IsExternalTwoByteString()) { |
1636 i::ExternalTwoByteStringUtf16CharacterStream stream( | 1602 i::ExternalTwoByteStringUtf16CharacterStream stream( |
1637 i::Handle<i::ExternalTwoByteString>::cast(str), 0, str->length()); | 1603 i::Handle<i::ExternalTwoByteString>::cast(str), 0, str->length()); |
1638 return i::PreParserApi::PreParse(isolate, &stream); | 1604 return i::PreParserApi::PreParse(isolate, &stream); |
1639 } else { | 1605 } else { |
1640 i::GenericStringUtf16CharacterStream stream(str, 0, str->length()); | 1606 i::GenericStringUtf16CharacterStream stream(str, 0, str->length()); |
1641 return i::PreParserApi::PreParse(isolate, &stream); | 1607 return i::PreParserApi::PreParse(isolate, &stream); |
1642 } | 1608 } |
1643 } | 1609 } |
1644 | 1610 |
1645 | 1611 |
1646 ScriptData* ScriptData::New(const char* data, int length) { | 1612 ScriptData* ScriptData::New(const char* data, int length) { |
1647 // Return an empty ScriptData if the length is obviously invalid. | 1613 // Return an empty ScriptData if the length is obviously invalid. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1704 i::ScriptDataImpl* pre_data_impl = | 1670 i::ScriptDataImpl* pre_data_impl = |
1705 static_cast<i::ScriptDataImpl*>(pre_data); | 1671 static_cast<i::ScriptDataImpl*>(pre_data); |
1706 // We assert that the pre-data is sane, even though we can actually | 1672 // We assert that the pre-data is sane, even though we can actually |
1707 // handle it if it turns out not to be in release mode. | 1673 // handle it if it turns out not to be in release mode. |
1708 ASSERT(pre_data_impl == NULL || pre_data_impl->SanityCheck()); | 1674 ASSERT(pre_data_impl == NULL || pre_data_impl->SanityCheck()); |
1709 // If the pre-data isn't sane we simply ignore it | 1675 // If the pre-data isn't sane we simply ignore it |
1710 if (pre_data_impl != NULL && !pre_data_impl->SanityCheck()) { | 1676 if (pre_data_impl != NULL && !pre_data_impl->SanityCheck()) { |
1711 pre_data_impl = NULL; | 1677 pre_data_impl = NULL; |
1712 } | 1678 } |
1713 i::Handle<i::SharedFunctionInfo> result = | 1679 i::Handle<i::SharedFunctionInfo> result = |
1714 i::Compiler::CompileScript(str, | 1680 i::Compiler::CompileScript(str, |
1715 name_obj, | 1681 name_obj, |
1716 line_offset, | 1682 line_offset, |
1717 column_offset, | 1683 column_offset, |
1718 is_shared_cross_origin, | 1684 is_shared_cross_origin, |
1719 isolate->global_context(), | 1685 isolate->global_context(), |
1720 NULL, | 1686 NULL, |
1721 pre_data_impl, | 1687 pre_data_impl, |
1722 Utils::OpenHandle(*script_data, true), | 1688 Utils::OpenHandle(*script_data, true), |
1723 i::NOT_NATIVES_CODE); | 1689 i::NOT_NATIVES_CODE); |
1724 has_pending_exception = result.is_null(); | 1690 has_pending_exception = result.is_null(); |
1725 EXCEPTION_BAILOUT_CHECK(isolate, Local<Script>()); | 1691 EXCEPTION_BAILOUT_CHECK(isolate, Local<Script>()); |
1726 raw_result = *result; | 1692 raw_result = *result; |
1727 } | 1693 } |
1728 i::Handle<i::SharedFunctionInfo> result(raw_result, isolate); | 1694 i::Handle<i::SharedFunctionInfo> result(raw_result, isolate); |
1729 return ToApiHandle<Script>(result); | 1695 return ToApiHandle<Script>(result); |
1730 } | 1696 } |
1731 | 1697 |
1732 | 1698 |
1733 Local<Script> Script::New(v8::Handle<String> source, | 1699 Local<Script> Script::New(v8::Handle<String> source, |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2418 bool Value::IsArrayBufferView() const { | 2384 bool Value::IsArrayBufferView() const { |
2419 return Utils::OpenHandle(this)->IsJSArrayBufferView(); | 2385 return Utils::OpenHandle(this)->IsJSArrayBufferView(); |
2420 } | 2386 } |
2421 | 2387 |
2422 | 2388 |
2423 bool Value::IsTypedArray() const { | 2389 bool Value::IsTypedArray() const { |
2424 return Utils::OpenHandle(this)->IsJSTypedArray(); | 2390 return Utils::OpenHandle(this)->IsJSTypedArray(); |
2425 } | 2391 } |
2426 | 2392 |
2427 | 2393 |
2428 #define TYPED_ARRAY_LIST(F) \ | 2394 #define TYPED_ARRAY_LIST(F) \ |
2429 F(Uint8Array, kExternalUnsignedByteArray) \ | 2395 F(Uint8Array, kExternalUnsignedByteArray) \ |
2430 F(Int8Array, kExternalByteArray) \ | 2396 F(Int8Array, kExternalByteArray) \ |
2431 F(Uint16Array, kExternalUnsignedShortArray) \ | 2397 F(Uint16Array, kExternalUnsignedShortArray) \ |
2432 F(Int16Array, kExternalShortArray) \ | 2398 F(Int16Array, kExternalShortArray) \ |
2433 F(Uint32Array, kExternalUnsignedIntArray) \ | 2399 F(Uint32Array, kExternalUnsignedIntArray) \ |
2434 F(Int32Array, kExternalIntArray) \ | 2400 F(Int32Array, kExternalIntArray) \ |
2435 F(Float32Array, kExternalFloatArray) \ | 2401 F(Float32Array, kExternalFloatArray) \ |
2436 F(Float64Array, kExternalDoubleArray) \ | 2402 F(Float64Array, kExternalDoubleArray) \ |
2437 F(Uint8ClampedArray, kExternalPixelArray) | 2403 F(Uint8ClampedArray, kExternalPixelArray) |
2438 | 2404 |
2439 | 2405 |
2440 #define VALUE_IS_TYPED_ARRAY(TypedArray, type_const) \ | 2406 #define VALUE_IS_TYPED_ARRAY(TypedArray, type_const) \ |
2441 bool Value::Is##TypedArray() const { \ | 2407 bool Value::Is##TypedArray() const { \ |
2442 i::Handle<i::Object> obj = Utils::OpenHandle(this); \ | 2408 i::Handle<i::Object> obj = Utils::OpenHandle(this); \ |
2443 if (!obj->IsJSTypedArray()) return false; \ | 2409 if (!obj->IsJSTypedArray()) return false; \ |
2444 return i::JSTypedArray::cast(*obj)->type() == type_const; \ | 2410 return i::JSTypedArray::cast(*obj)->type() == type_const; \ |
2445 } | 2411 } |
2446 | 2412 |
2447 TYPED_ARRAY_LIST(VALUE_IS_TYPED_ARRAY) | 2413 TYPED_ARRAY_LIST(VALUE_IS_TYPED_ARRAY) |
2448 | 2414 |
2449 #undef VALUE_IS_TYPED_ARRAY | 2415 #undef VALUE_IS_TYPED_ARRAY |
2450 | 2416 |
2451 | 2417 |
2452 bool Value::IsDataView() const { | 2418 bool Value::IsDataView() const { |
2453 return Utils::OpenHandle(this)->IsJSDataView(); | 2419 return Utils::OpenHandle(this)->IsJSDataView(); |
2454 } | 2420 } |
(...skipping 28 matching lines...) Expand all Loading... |
2483 return false; | 2449 return false; |
2484 } | 2450 } |
2485 | 2451 |
2486 | 2452 |
2487 bool Value::IsUint32() const { | 2453 bool Value::IsUint32() const { |
2488 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2454 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2489 if (obj->IsSmi()) return i::Smi::cast(*obj)->value() >= 0; | 2455 if (obj->IsSmi()) return i::Smi::cast(*obj)->value() >= 0; |
2490 if (obj->IsNumber()) { | 2456 if (obj->IsNumber()) { |
2491 double value = obj->Number(); | 2457 double value = obj->Number(); |
2492 return !i::IsMinusZero(value) && | 2458 return !i::IsMinusZero(value) && |
2493 value >= 0 && | 2459 value >= 0 && |
2494 value <= i::kMaxUInt32 && | 2460 value <= i::kMaxUInt32 && |
2495 value == i::FastUI2D(i::FastD2UI(value)); | 2461 value == i::FastUI2D(i::FastD2UI(value)); |
2496 } | 2462 } |
2497 return false; | 2463 return false; |
2498 } | 2464 } |
2499 | 2465 |
2500 | 2466 |
2501 bool Value::IsDate() const { | 2467 bool Value::IsDate() const { |
2502 i::Isolate* isolate = i::Isolate::Current(); | 2468 i::Isolate* isolate = i::Isolate::Current(); |
2503 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2469 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2504 return obj->HasSpecificClassOf(isolate->heap()->Date_string()); | 2470 return obj->HasSpecificClassOf(isolate->heap()->Date_string()); |
2505 } | 2471 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2537 } | 2503 } |
2538 | 2504 |
2539 | 2505 |
2540 static bool CheckConstructor(i::Isolate* isolate, | 2506 static bool CheckConstructor(i::Isolate* isolate, |
2541 i::Handle<i::JSObject> obj, | 2507 i::Handle<i::JSObject> obj, |
2542 const char* class_name) { | 2508 const char* class_name) { |
2543 i::Object* constr = obj->map()->constructor(); | 2509 i::Object* constr = obj->map()->constructor(); |
2544 if (!constr->IsJSFunction()) return false; | 2510 if (!constr->IsJSFunction()) return false; |
2545 i::JSFunction* func = i::JSFunction::cast(constr); | 2511 i::JSFunction* func = i::JSFunction::cast(constr); |
2546 return func->shared()->native() && | 2512 return func->shared()->native() && |
2547 constr == LookupBuiltin(isolate, class_name); | 2513 constr == LookupBuiltin(isolate, class_name); |
2548 } | 2514 } |
2549 | 2515 |
2550 | 2516 |
2551 bool Value::IsNativeError() const { | 2517 bool Value::IsNativeError() const { |
2552 i::Isolate* isolate = i::Isolate::Current(); | 2518 i::Isolate* isolate = i::Isolate::Current(); |
2553 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2519 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2554 if (obj->IsJSObject()) { | 2520 if (obj->IsJSObject()) { |
2555 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*obj)); | 2521 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*obj)); |
2556 return CheckConstructor(isolate, js_obj, "$Error") || | 2522 return CheckConstructor(isolate, js_obj, "$Error") || |
2557 CheckConstructor(isolate, js_obj, "$EvalError") || | 2523 CheckConstructor(isolate, js_obj, "$EvalError") || |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2674 EXCEPTION_PREAMBLE(isolate); | 2640 EXCEPTION_PREAMBLE(isolate); |
2675 num = i::Execution::ToInteger(isolate, obj, &has_pending_exception); | 2641 num = i::Execution::ToInteger(isolate, obj, &has_pending_exception); |
2676 EXCEPTION_BAILOUT_CHECK(isolate, Local<Integer>()); | 2642 EXCEPTION_BAILOUT_CHECK(isolate, Local<Integer>()); |
2677 } | 2643 } |
2678 return ToApiHandle<Integer>(num); | 2644 return ToApiHandle<Integer>(num); |
2679 } | 2645 } |
2680 | 2646 |
2681 | 2647 |
2682 void i::Internals::CheckInitializedImpl(v8::Isolate* external_isolate) { | 2648 void i::Internals::CheckInitializedImpl(v8::Isolate* external_isolate) { |
2683 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate); | 2649 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate); |
2684 ApiCheck(isolate != NULL && isolate->IsInitialized() && !isolate->IsDead(), | 2650 Utils::ApiCheck(isolate != NULL && |
2685 "v8::internal::Internals::CheckInitialized()", | 2651 isolate->IsInitialized() && |
2686 "Isolate is not initialized or V8 has died"); | 2652 !isolate->IsDead(), |
| 2653 "v8::internal::Internals::CheckInitialized()", |
| 2654 "Isolate is not initialized or V8 has died"); |
2687 } | 2655 } |
2688 | 2656 |
2689 | 2657 |
2690 void External::CheckCast(v8::Value* that) { | 2658 void External::CheckCast(v8::Value* that) { |
2691 ApiCheck(Utils::OpenHandle(that)->IsExternal(), | 2659 Utils::ApiCheck(Utils::OpenHandle(that)->IsExternal(), |
2692 "v8::External::Cast()", | 2660 "v8::External::Cast()", |
2693 "Could not convert to external"); | 2661 "Could not convert to external"); |
2694 } | 2662 } |
2695 | 2663 |
2696 | 2664 |
2697 void v8::Object::CheckCast(Value* that) { | 2665 void v8::Object::CheckCast(Value* that) { |
2698 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2666 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2699 ApiCheck(obj->IsJSObject(), | 2667 Utils::ApiCheck(obj->IsJSObject(), |
2700 "v8::Object::Cast()", | 2668 "v8::Object::Cast()", |
2701 "Could not convert to object"); | 2669 "Could not convert to object"); |
2702 } | 2670 } |
2703 | 2671 |
2704 | 2672 |
2705 void v8::Function::CheckCast(Value* that) { | 2673 void v8::Function::CheckCast(Value* that) { |
2706 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2674 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2707 ApiCheck(obj->IsJSFunction(), | 2675 Utils::ApiCheck(obj->IsJSFunction(), |
2708 "v8::Function::Cast()", | 2676 "v8::Function::Cast()", |
2709 "Could not convert to function"); | 2677 "Could not convert to function"); |
2710 } | 2678 } |
2711 | 2679 |
2712 | 2680 |
2713 void v8::String::CheckCast(v8::Value* that) { | 2681 void v8::String::CheckCast(v8::Value* that) { |
2714 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2682 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2715 ApiCheck(obj->IsString(), | 2683 Utils::ApiCheck(obj->IsString(), |
2716 "v8::String::Cast()", | 2684 "v8::String::Cast()", |
2717 "Could not convert to string"); | 2685 "Could not convert to string"); |
2718 } | 2686 } |
2719 | 2687 |
2720 | 2688 |
2721 void v8::Symbol::CheckCast(v8::Value* that) { | 2689 void v8::Symbol::CheckCast(v8::Value* that) { |
2722 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2690 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2723 ApiCheck(obj->IsSymbol(), | 2691 Utils::ApiCheck(obj->IsSymbol(), |
2724 "v8::Symbol::Cast()", | 2692 "v8::Symbol::Cast()", |
2725 "Could not convert to symbol"); | 2693 "Could not convert to symbol"); |
2726 } | 2694 } |
2727 | 2695 |
2728 | 2696 |
2729 void v8::Number::CheckCast(v8::Value* that) { | 2697 void v8::Number::CheckCast(v8::Value* that) { |
2730 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2698 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2731 ApiCheck(obj->IsNumber(), | 2699 Utils::ApiCheck(obj->IsNumber(), |
2732 "v8::Number::Cast()", | 2700 "v8::Number::Cast()", |
2733 "Could not convert to number"); | 2701 "Could not convert to number"); |
2734 } | 2702 } |
2735 | 2703 |
2736 | 2704 |
2737 void v8::Integer::CheckCast(v8::Value* that) { | 2705 void v8::Integer::CheckCast(v8::Value* that) { |
2738 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2706 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2739 ApiCheck(obj->IsNumber(), | 2707 Utils::ApiCheck(obj->IsNumber(), |
2740 "v8::Integer::Cast()", | 2708 "v8::Integer::Cast()", |
2741 "Could not convert to number"); | 2709 "Could not convert to number"); |
2742 } | 2710 } |
2743 | 2711 |
2744 | 2712 |
2745 void v8::Array::CheckCast(Value* that) { | 2713 void v8::Array::CheckCast(Value* that) { |
2746 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2714 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2747 ApiCheck(obj->IsJSArray(), | 2715 Utils::ApiCheck(obj->IsJSArray(), |
2748 "v8::Array::Cast()", | 2716 "v8::Array::Cast()", |
2749 "Could not convert to array"); | 2717 "Could not convert to array"); |
2750 } | 2718 } |
2751 | 2719 |
2752 | 2720 |
2753 void v8::ArrayBuffer::CheckCast(Value* that) { | 2721 void v8::ArrayBuffer::CheckCast(Value* that) { |
2754 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2722 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2755 ApiCheck(obj->IsJSArrayBuffer(), | 2723 Utils::ApiCheck(obj->IsJSArrayBuffer(), |
2756 "v8::ArrayBuffer::Cast()", | 2724 "v8::ArrayBuffer::Cast()", |
2757 "Could not convert to ArrayBuffer"); | 2725 "Could not convert to ArrayBuffer"); |
2758 } | 2726 } |
2759 | 2727 |
2760 | 2728 |
2761 void v8::ArrayBufferView::CheckCast(Value* that) { | 2729 void v8::ArrayBufferView::CheckCast(Value* that) { |
2762 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2730 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2763 ApiCheck(obj->IsJSArrayBufferView(), | 2731 Utils::ApiCheck(obj->IsJSArrayBufferView(), |
2764 "v8::ArrayBufferView::Cast()", | 2732 "v8::ArrayBufferView::Cast()", |
2765 "Could not convert to ArrayBufferView"); | 2733 "Could not convert to ArrayBufferView"); |
2766 } | 2734 } |
2767 | 2735 |
2768 | 2736 |
2769 void v8::TypedArray::CheckCast(Value* that) { | 2737 void v8::TypedArray::CheckCast(Value* that) { |
2770 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2738 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2771 ApiCheck(obj->IsJSTypedArray(), | 2739 Utils::ApiCheck(obj->IsJSTypedArray(), |
2772 "v8::TypedArray::Cast()", | 2740 "v8::TypedArray::Cast()", |
2773 "Could not convert to TypedArray"); | 2741 "Could not convert to TypedArray"); |
2774 } | 2742 } |
2775 | 2743 |
2776 | 2744 |
2777 #define CHECK_TYPED_ARRAY_CAST(ApiClass, typeConst) \ | 2745 #define CHECK_TYPED_ARRAY_CAST(ApiClass, typeConst) \ |
2778 void v8::ApiClass::CheckCast(Value* that) { \ | 2746 void v8::ApiClass::CheckCast(Value* that) { \ |
2779 i::Handle<i::Object> obj = Utils::OpenHandle(that); \ | 2747 i::Handle<i::Object> obj = Utils::OpenHandle(that); \ |
2780 ApiCheck(obj->IsJSTypedArray() && \ | 2748 Utils::ApiCheck(obj->IsJSTypedArray() && \ |
2781 i::JSTypedArray::cast(*obj)->type() == typeConst, \ | 2749 i::JSTypedArray::cast(*obj)->type() == typeConst, \ |
2782 "v8::" #ApiClass "::Cast()", \ | 2750 "v8::" #ApiClass "::Cast()", \ |
2783 "Could not convert to " #ApiClass); \ | 2751 "Could not convert to " #ApiClass); \ |
2784 } | 2752 } |
2785 | 2753 |
2786 | 2754 |
2787 TYPED_ARRAY_LIST(CHECK_TYPED_ARRAY_CAST) | 2755 TYPED_ARRAY_LIST(CHECK_TYPED_ARRAY_CAST) |
2788 | 2756 |
2789 #undef CHECK_TYPED_ARRAY_CAST | 2757 #undef CHECK_TYPED_ARRAY_CAST |
2790 | 2758 |
2791 | 2759 |
2792 void v8::DataView::CheckCast(Value* that) { | 2760 void v8::DataView::CheckCast(Value* that) { |
2793 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2761 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2794 ApiCheck(obj->IsJSDataView(), | 2762 Utils::ApiCheck(obj->IsJSDataView(), |
2795 "v8::DataView::Cast()", | 2763 "v8::DataView::Cast()", |
2796 "Could not convert to DataView"); | 2764 "Could not convert to DataView"); |
2797 } | 2765 } |
2798 | 2766 |
2799 | 2767 |
2800 void v8::Date::CheckCast(v8::Value* that) { | 2768 void v8::Date::CheckCast(v8::Value* that) { |
2801 i::Isolate* isolate = i::Isolate::Current(); | 2769 i::Isolate* isolate = i::Isolate::Current(); |
2802 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2770 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2803 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Date_string()), | 2771 Utils::ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Date_string()), |
2804 "v8::Date::Cast()", | 2772 "v8::Date::Cast()", |
2805 "Could not convert to date"); | 2773 "Could not convert to date"); |
2806 } | 2774 } |
2807 | 2775 |
2808 | 2776 |
2809 void v8::StringObject::CheckCast(v8::Value* that) { | 2777 void v8::StringObject::CheckCast(v8::Value* that) { |
2810 i::Isolate* isolate = i::Isolate::Current(); | 2778 i::Isolate* isolate = i::Isolate::Current(); |
2811 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2779 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2812 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->String_string()), | 2780 Utils::ApiCheck(obj->HasSpecificClassOf(isolate->heap()->String_string()), |
2813 "v8::StringObject::Cast()", | 2781 "v8::StringObject::Cast()", |
2814 "Could not convert to StringObject"); | 2782 "Could not convert to StringObject"); |
2815 } | 2783 } |
2816 | 2784 |
2817 | 2785 |
2818 void v8::SymbolObject::CheckCast(v8::Value* that) { | 2786 void v8::SymbolObject::CheckCast(v8::Value* that) { |
2819 i::Isolate* isolate = i::Isolate::Current(); | 2787 i::Isolate* isolate = i::Isolate::Current(); |
2820 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2788 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2821 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Symbol_string()), | 2789 Utils::ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Symbol_string()), |
2822 "v8::SymbolObject::Cast()", | 2790 "v8::SymbolObject::Cast()", |
2823 "Could not convert to SymbolObject"); | 2791 "Could not convert to SymbolObject"); |
2824 } | 2792 } |
2825 | 2793 |
2826 | 2794 |
2827 void v8::NumberObject::CheckCast(v8::Value* that) { | 2795 void v8::NumberObject::CheckCast(v8::Value* that) { |
2828 i::Isolate* isolate = i::Isolate::Current(); | 2796 i::Isolate* isolate = i::Isolate::Current(); |
2829 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2797 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2830 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Number_string()), | 2798 Utils::ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Number_string()), |
2831 "v8::NumberObject::Cast()", | 2799 "v8::NumberObject::Cast()", |
2832 "Could not convert to NumberObject"); | 2800 "Could not convert to NumberObject"); |
2833 } | 2801 } |
2834 | 2802 |
2835 | 2803 |
2836 void v8::BooleanObject::CheckCast(v8::Value* that) { | 2804 void v8::BooleanObject::CheckCast(v8::Value* that) { |
2837 i::Isolate* isolate = i::Isolate::Current(); | 2805 i::Isolate* isolate = i::Isolate::Current(); |
2838 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2806 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2839 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Boolean_string()), | 2807 Utils::ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Boolean_string()), |
2840 "v8::BooleanObject::Cast()", | 2808 "v8::BooleanObject::Cast()", |
2841 "Could not convert to BooleanObject"); | 2809 "Could not convert to BooleanObject"); |
2842 } | 2810 } |
2843 | 2811 |
2844 | 2812 |
2845 void v8::RegExp::CheckCast(v8::Value* that) { | 2813 void v8::RegExp::CheckCast(v8::Value* that) { |
2846 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2814 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2847 ApiCheck(obj->IsJSRegExp(), | 2815 Utils::ApiCheck(obj->IsJSRegExp(), |
2848 "v8::RegExp::Cast()", | 2816 "v8::RegExp::Cast()", |
2849 "Could not convert to regular expression"); | 2817 "Could not convert to regular expression"); |
2850 } | 2818 } |
2851 | 2819 |
2852 | 2820 |
2853 bool Value::BooleanValue() const { | 2821 bool Value::BooleanValue() const { |
2854 return Utils::OpenHandle(this)->BooleanValue(); | 2822 return Utils::OpenHandle(this)->BooleanValue(); |
2855 } | 2823 } |
2856 | 2824 |
2857 | 2825 |
2858 double Value::NumberValue() const { | 2826 double Value::NumberValue() const { |
2859 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2827 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2971 return i::Smi::cast(*num)->value(); | 2939 return i::Smi::cast(*num)->value(); |
2972 } else { | 2940 } else { |
2973 return static_cast<int32_t>(num->Number()); | 2941 return static_cast<int32_t>(num->Number()); |
2974 } | 2942 } |
2975 } | 2943 } |
2976 } | 2944 } |
2977 | 2945 |
2978 | 2946 |
2979 bool Value::Equals(Handle<Value> that) const { | 2947 bool Value::Equals(Handle<Value> that) const { |
2980 i::Isolate* isolate = i::Isolate::Current(); | 2948 i::Isolate* isolate = i::Isolate::Current(); |
2981 if (EmptyCheck("v8::Value::Equals()", this) || | 2949 if (!Utils::ApiCheck(this != NULL && !that.IsEmpty(), |
2982 EmptyCheck("v8::Value::Equals()", that)) { | 2950 "v8::Value::Equals()", |
| 2951 "Reading from empty handle")) { |
2983 return false; | 2952 return false; |
2984 } | 2953 } |
2985 LOG_API(isolate, "Equals"); | 2954 LOG_API(isolate, "Equals"); |
2986 ENTER_V8(isolate); | 2955 ENTER_V8(isolate); |
2987 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2956 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2988 i::Handle<i::Object> other = Utils::OpenHandle(*that); | 2957 i::Handle<i::Object> other = Utils::OpenHandle(*that); |
2989 // If both obj and other are JSObjects, we'd better compare by identity | 2958 // If both obj and other are JSObjects, we'd better compare by identity |
2990 // immediately when going into JS builtin. The reason is Invoke | 2959 // immediately when going into JS builtin. The reason is Invoke |
2991 // would overwrite global object receiver with global proxy. | 2960 // would overwrite global object receiver with global proxy. |
2992 if (obj->IsJSObject() && other->IsJSObject()) { | 2961 if (obj->IsJSObject() && other->IsJSObject()) { |
2993 return *obj == *other; | 2962 return *obj == *other; |
2994 } | 2963 } |
2995 i::Handle<i::Object> args[] = { other }; | 2964 i::Handle<i::Object> args[] = { other }; |
2996 EXCEPTION_PREAMBLE(isolate); | 2965 EXCEPTION_PREAMBLE(isolate); |
2997 i::Handle<i::Object> result = | 2966 i::Handle<i::Object> result = |
2998 CallV8HeapFunction("EQUALS", obj, ARRAY_SIZE(args), args, | 2967 CallV8HeapFunction("EQUALS", obj, ARRAY_SIZE(args), args, |
2999 &has_pending_exception); | 2968 &has_pending_exception); |
3000 EXCEPTION_BAILOUT_CHECK(isolate, false); | 2969 EXCEPTION_BAILOUT_CHECK(isolate, false); |
3001 return *result == i::Smi::FromInt(i::EQUAL); | 2970 return *result == i::Smi::FromInt(i::EQUAL); |
3002 } | 2971 } |
3003 | 2972 |
3004 | 2973 |
3005 bool Value::StrictEquals(Handle<Value> that) const { | 2974 bool Value::StrictEquals(Handle<Value> that) const { |
3006 i::Isolate* isolate = i::Isolate::Current(); | 2975 i::Isolate* isolate = i::Isolate::Current(); |
3007 if (EmptyCheck("v8::Value::StrictEquals()", this) || | 2976 if (!Utils::ApiCheck(this != NULL && !that.IsEmpty(), |
3008 EmptyCheck("v8::Value::StrictEquals()", that)) { | 2977 "v8::Value::StrictEquals()", |
| 2978 "Reading from empty handle")) { |
3009 return false; | 2979 return false; |
3010 } | 2980 } |
3011 LOG_API(isolate, "StrictEquals"); | 2981 LOG_API(isolate, "StrictEquals"); |
3012 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2982 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
3013 i::Handle<i::Object> other = Utils::OpenHandle(*that); | 2983 i::Handle<i::Object> other = Utils::OpenHandle(*that); |
3014 // Must check HeapNumber first, since NaN !== NaN. | 2984 // Must check HeapNumber first, since NaN !== NaN. |
3015 if (obj->IsHeapNumber()) { | 2985 if (obj->IsHeapNumber()) { |
3016 if (!other->IsNumber()) return false; | 2986 if (!other->IsNumber()) return false; |
3017 double x = obj->Number(); | 2987 double x = obj->Number(); |
3018 double y = other->Number(); | 2988 double y = other->Number(); |
3019 // Must check explicitly for NaN:s on Windows, but -0 works fine. | 2989 // Must check explicitly for NaN:s on Windows, but -0 works fine. |
3020 return x == y && !std::isnan(x) && !std::isnan(y); | 2990 return x == y && !std::isnan(x) && !std::isnan(y); |
3021 } else if (*obj == *other) { // Also covers Booleans. | 2991 } else if (*obj == *other) { // Also covers Booleans. |
3022 return true; | 2992 return true; |
3023 } else if (obj->IsSmi()) { | 2993 } else if (obj->IsSmi()) { |
3024 return other->IsNumber() && obj->Number() == other->Number(); | 2994 return other->IsNumber() && obj->Number() == other->Number(); |
3025 } else if (obj->IsString()) { | 2995 } else if (obj->IsString()) { |
3026 return other->IsString() && | 2996 return other->IsString() && |
3027 i::String::cast(*obj)->Equals(i::String::cast(*other)); | 2997 i::String::cast(*obj)->Equals(i::String::cast(*other)); |
3028 } else if (obj->IsUndefined() || obj->IsUndetectableObject()) { | 2998 } else if (obj->IsUndefined() || obj->IsUndetectableObject()) { |
3029 return other->IsUndefined() || other->IsUndetectableObject(); | 2999 return other->IsUndefined() || other->IsUndetectableObject(); |
3030 } else { | 3000 } else { |
3031 return false; | 3001 return false; |
3032 } | 3002 } |
3033 } | 3003 } |
3034 | 3004 |
3035 | 3005 |
3036 bool Value::SameValue(Handle<Value> that) const { | 3006 bool Value::SameValue(Handle<Value> that) const { |
3037 i::Isolate* isolate = i::Isolate::Current(); | 3007 i::Isolate* isolate = i::Isolate::Current(); |
3038 if (EmptyCheck("v8::Value::SameValue()", this) || | 3008 if (!Utils::ApiCheck(this != NULL && !that.IsEmpty(), |
3039 EmptyCheck("v8::Value::SameValue()", that)) { | 3009 "v8::Value::SameValue()", |
| 3010 "Reading from empty handle")) { |
3040 return false; | 3011 return false; |
3041 } | 3012 } |
3042 LOG_API(isolate, "SameValue"); | 3013 LOG_API(isolate, "SameValue"); |
3043 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 3014 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
3044 i::Handle<i::Object> other = Utils::OpenHandle(*that); | 3015 i::Handle<i::Object> other = Utils::OpenHandle(*that); |
3045 return obj->SameValue(*other); | 3016 return obj->SameValue(*other); |
3046 } | 3017 } |
3047 | 3018 |
3048 | 3019 |
3049 uint32_t Value::Uint32Value() const { | 3020 uint32_t Value::Uint32Value() const { |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3552 i::Object::GetProperty(receiver, receiver, lookup, name, | 3523 i::Object::GetProperty(receiver, receiver, lookup, name, |
3553 &ignored); | 3524 &ignored); |
3554 has_pending_exception = result.is_null(); | 3525 has_pending_exception = result.is_null(); |
3555 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); | 3526 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); |
3556 | 3527 |
3557 return Utils::ToLocal(result); | 3528 return Utils::ToLocal(result); |
3558 } | 3529 } |
3559 | 3530 |
3560 | 3531 |
3561 Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( | 3532 Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( |
3562 Handle<String> key) { | 3533 Handle<String> key) { |
3563 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3534 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3564 ON_BAILOUT(isolate, | 3535 ON_BAILOUT(isolate, |
3565 "v8::Object::GetRealNamedPropertyInPrototypeChain()", | 3536 "v8::Object::GetRealNamedPropertyInPrototypeChain()", |
3566 return Local<Value>()); | 3537 return Local<Value>()); |
3567 ENTER_V8(isolate); | 3538 ENTER_V8(isolate); |
3568 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); | 3539 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); |
3569 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); | 3540 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
3570 i::LookupResult lookup(isolate); | 3541 i::LookupResult lookup(isolate); |
3571 self_obj->LookupRealNamedPropertyInPrototypes(*key_obj, &lookup); | 3542 self_obj->LookupRealNamedPropertyInPrototypes(*key_obj, &lookup); |
3572 return GetPropertyByLookup(isolate, self_obj, key_obj, &lookup); | 3543 return GetPropertyByLookup(isolate, self_obj, key_obj, &lookup); |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3765 } | 3736 } |
3766 | 3737 |
3767 } // namespace | 3738 } // namespace |
3768 | 3739 |
3769 | 3740 |
3770 void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) { | 3741 void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) { |
3771 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3742 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3772 ON_BAILOUT(isolate, "v8::SetElementsToPixelData()", return); | 3743 ON_BAILOUT(isolate, "v8::SetElementsToPixelData()", return); |
3773 ENTER_V8(isolate); | 3744 ENTER_V8(isolate); |
3774 i::HandleScope scope(isolate); | 3745 i::HandleScope scope(isolate); |
3775 if (!ApiCheck(length >= 0 && length <= i::ExternalPixelArray::kMaxLength, | 3746 if (!Utils::ApiCheck(length >= 0 && |
3776 "v8::Object::SetIndexedPropertiesToPixelData()", | 3747 length <= i::ExternalPixelArray::kMaxLength, |
3777 "length exceeds max acceptable value")) { | 3748 "v8::Object::SetIndexedPropertiesToPixelData()", |
| 3749 "length exceeds max acceptable value")) { |
3778 return; | 3750 return; |
3779 } | 3751 } |
3780 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 3752 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
3781 if (!ApiCheck(!self->IsJSArray(), | 3753 if (!Utils::ApiCheck(!self->IsJSArray(), |
3782 "v8::Object::SetIndexedPropertiesToPixelData()", | 3754 "v8::Object::SetIndexedPropertiesToPixelData()", |
3783 "JSArray is not supported")) { | 3755 "JSArray is not supported")) { |
3784 return; | 3756 return; |
3785 } | 3757 } |
3786 PrepareExternalArrayElements(self, data, kExternalPixelArray, length); | 3758 PrepareExternalArrayElements(self, data, kExternalPixelArray, length); |
3787 } | 3759 } |
3788 | 3760 |
3789 | 3761 |
3790 bool v8::Object::HasIndexedPropertiesInPixelData() { | 3762 bool v8::Object::HasIndexedPropertiesInPixelData() { |
3791 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 3763 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
3792 ON_BAILOUT(self->GetIsolate(), "v8::HasIndexedPropertiesInPixelData()", | 3764 ON_BAILOUT(self->GetIsolate(), "v8::HasIndexedPropertiesInPixelData()", |
3793 return false); | 3765 return false); |
(...skipping 27 matching lines...) Expand all Loading... |
3821 | 3793 |
3822 | 3794 |
3823 void v8::Object::SetIndexedPropertiesToExternalArrayData( | 3795 void v8::Object::SetIndexedPropertiesToExternalArrayData( |
3824 void* data, | 3796 void* data, |
3825 ExternalArrayType array_type, | 3797 ExternalArrayType array_type, |
3826 int length) { | 3798 int length) { |
3827 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3799 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3828 ON_BAILOUT(isolate, "v8::SetIndexedPropertiesToExternalArrayData()", return); | 3800 ON_BAILOUT(isolate, "v8::SetIndexedPropertiesToExternalArrayData()", return); |
3829 ENTER_V8(isolate); | 3801 ENTER_V8(isolate); |
3830 i::HandleScope scope(isolate); | 3802 i::HandleScope scope(isolate); |
3831 if (!ApiCheck(length >= 0 && length <= i::ExternalArray::kMaxLength, | 3803 if (!Utils::ApiCheck(length >= 0 && length <= i::ExternalArray::kMaxLength, |
3832 "v8::Object::SetIndexedPropertiesToExternalArrayData()", | 3804 "v8::Object::SetIndexedPropertiesToExternalArrayData()", |
3833 "length exceeds max acceptable value")) { | 3805 "length exceeds max acceptable value")) { |
3834 return; | 3806 return; |
3835 } | 3807 } |
3836 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 3808 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
3837 if (!ApiCheck(!self->IsJSArray(), | 3809 if (!Utils::ApiCheck(!self->IsJSArray(), |
3838 "v8::Object::SetIndexedPropertiesToExternalArrayData()", | 3810 "v8::Object::SetIndexedPropertiesToExternalArrayData()", |
3839 "JSArray is not supported")) { | 3811 "JSArray is not supported")) { |
3840 return; | 3812 return; |
3841 } | 3813 } |
3842 PrepareExternalArrayElements(self, data, array_type, length); | 3814 PrepareExternalArrayElements(self, data, array_type, length); |
3843 } | 3815 } |
3844 | 3816 |
3845 | 3817 |
3846 bool v8::Object::HasIndexedPropertiesInExternalArrayData() { | 3818 bool v8::Object::HasIndexedPropertiesInExternalArrayData() { |
3847 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 3819 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
3848 ON_BAILOUT(self->GetIsolate(), | 3820 ON_BAILOUT(self->GetIsolate(), |
3849 "v8::HasIndexedPropertiesInExternalArrayData()", | 3821 "v8::HasIndexedPropertiesInExternalArrayData()", |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3993 | 3965 |
3994 Local<Function> Function::New(Isolate* v8_isolate, | 3966 Local<Function> Function::New(Isolate* v8_isolate, |
3995 FunctionCallback callback, | 3967 FunctionCallback callback, |
3996 Local<Value> data, | 3968 Local<Value> data, |
3997 int length) { | 3969 int length) { |
3998 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 3970 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
3999 LOG_API(isolate, "Function::New"); | 3971 LOG_API(isolate, "Function::New"); |
4000 ENTER_V8(isolate); | 3972 ENTER_V8(isolate); |
4001 return FunctionTemplateNew( | 3973 return FunctionTemplateNew( |
4002 isolate, callback, data, Local<Signature>(), length, true)-> | 3974 isolate, callback, data, Local<Signature>(), length, true)-> |
4003 GetFunction(); | 3975 GetFunction(); |
4004 } | 3976 } |
4005 | 3977 |
4006 | 3978 |
4007 Local<v8::Object> Function::NewInstance() const { | 3979 Local<v8::Object> Function::NewInstance() const { |
4008 return NewInstance(0, NULL); | 3980 return NewInstance(0, NULL); |
4009 } | 3981 } |
4010 | 3982 |
4011 | 3983 |
4012 Local<v8::Object> Function::NewInstance(int argc, | 3984 Local<v8::Object> Function::NewInstance(int argc, |
4013 v8::Handle<v8::Value> argv[]) const { | 3985 v8::Handle<v8::Value> argv[]) const { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4076 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | 4048 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
4077 return Utils::ToLocal(i::Handle<i::Object>(func->shared()->inferred_name(), | 4049 return Utils::ToLocal(i::Handle<i::Object>(func->shared()->inferred_name(), |
4078 func->GetIsolate())); | 4050 func->GetIsolate())); |
4079 } | 4051 } |
4080 | 4052 |
4081 | 4053 |
4082 Handle<Value> Function::GetDisplayName() const { | 4054 Handle<Value> Function::GetDisplayName() const { |
4083 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 4055 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
4084 ON_BAILOUT(isolate, "v8::Function::GetDisplayName()", | 4056 ON_BAILOUT(isolate, "v8::Function::GetDisplayName()", |
4085 return ToApiHandle<Primitive>( | 4057 return ToApiHandle<Primitive>( |
4086 isolate->factory()->undefined_value())); | 4058 isolate->factory()->undefined_value())); |
4087 ENTER_V8(isolate); | 4059 ENTER_V8(isolate); |
4088 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | 4060 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
4089 i::Handle<i::String> property_name = | 4061 i::Handle<i::String> property_name = |
4090 isolate->factory()->InternalizeOneByteString( | 4062 isolate->factory()->InternalizeOneByteString( |
4091 STATIC_ASCII_VECTOR("displayName")); | 4063 STATIC_ASCII_VECTOR("displayName")); |
4092 i::LookupResult lookup(isolate); | 4064 i::LookupResult lookup(isolate); |
4093 func->LookupRealNamedProperty(*property_name, &lookup); | 4065 func->LookupRealNamedProperty(*property_name, &lookup); |
4094 if (lookup.IsFound()) { | 4066 if (lookup.IsFound()) { |
4095 i::Object* value = lookup.GetLazyValue(); | 4067 i::Object* value = lookup.GetLazyValue(); |
4096 if (value && value->IsString()) { | 4068 if (value && value->IsString()) { |
4097 i::String* name = i::String::cast(value); | 4069 i::String* name = i::String::cast(value); |
4098 if (name->length() > 0) return Utils::ToLocal(i::Handle<i::String>(name)); | 4070 if (name->length() > 0) return Utils::ToLocal(i::Handle<i::String>(name)); |
4099 } | 4071 } |
4100 } | 4072 } |
4101 return ToApiHandle<Primitive>(isolate->factory()->undefined_value()); | 4073 return ToApiHandle<Primitive>(isolate->factory()->undefined_value()); |
4102 } | 4074 } |
4103 | 4075 |
4104 | 4076 |
4105 ScriptOrigin Function::GetScriptOrigin() const { | 4077 ScriptOrigin Function::GetScriptOrigin() const { |
4106 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | 4078 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
4107 if (func->shared()->script()->IsScript()) { | 4079 if (func->shared()->script()->IsScript()) { |
4108 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); | 4080 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); |
4109 i::Handle<i::Object> scriptName = GetScriptNameOrSourceURL(script); | 4081 i::Handle<i::Object> scriptName = GetScriptNameOrSourceURL(script); |
4110 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(func->GetIsolate()); | 4082 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(func->GetIsolate()); |
4111 v8::ScriptOrigin origin( | 4083 v8::ScriptOrigin origin( |
4112 Utils::ToLocal(scriptName), | 4084 Utils::ToLocal(scriptName), |
4113 v8::Integer::New(isolate, script->line_offset()->value()), | 4085 v8::Integer::New(isolate, script->line_offset()->value()), |
4114 v8::Integer::New(isolate, script->column_offset()->value())); | 4086 v8::Integer::New(isolate, script->column_offset()->value())); |
4115 return origin; | 4087 return origin; |
4116 } | 4088 } |
4117 return v8::ScriptOrigin(Handle<Value>()); | 4089 return v8::ScriptOrigin(Handle<Value>()); |
4118 } | 4090 } |
4119 | 4091 |
4120 | 4092 |
4121 const int Function::kLineOffsetNotFound = -1; | 4093 const int Function::kLineOffsetNotFound = -1; |
4122 | 4094 |
4123 | 4095 |
4124 int Function::GetScriptLineNumber() const { | 4096 int Function::GetScriptLineNumber() const { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4191 }; | 4163 }; |
4192 static const uintptr_t kOneByteMask = OneByteMask<sizeof(uintptr_t)>::value; | 4164 static const uintptr_t kOneByteMask = OneByteMask<sizeof(uintptr_t)>::value; |
4193 static const uintptr_t kAlignmentMask = sizeof(uintptr_t) - 1; | 4165 static const uintptr_t kAlignmentMask = sizeof(uintptr_t) - 1; |
4194 static inline bool Unaligned(const uint16_t* chars) { | 4166 static inline bool Unaligned(const uint16_t* chars) { |
4195 return reinterpret_cast<const uintptr_t>(chars) & kAlignmentMask; | 4167 return reinterpret_cast<const uintptr_t>(chars) & kAlignmentMask; |
4196 } | 4168 } |
4197 | 4169 |
4198 | 4170 |
4199 static inline const uint16_t* Align(const uint16_t* chars) { | 4171 static inline const uint16_t* Align(const uint16_t* chars) { |
4200 return reinterpret_cast<uint16_t*>( | 4172 return reinterpret_cast<uint16_t*>( |
4201 reinterpret_cast<uintptr_t>(chars) & ~kAlignmentMask); | 4173 reinterpret_cast<uintptr_t>(chars) & ~kAlignmentMask); |
4202 } | 4174 } |
4203 | 4175 |
4204 class ContainsOnlyOneByteHelper { | 4176 class ContainsOnlyOneByteHelper { |
4205 public: | 4177 public: |
4206 ContainsOnlyOneByteHelper() : is_one_byte_(true) {} | 4178 ContainsOnlyOneByteHelper() : is_one_byte_(true) {} |
4207 bool Check(i::String* string) { | 4179 bool Check(i::String* string) { |
4208 i::ConsString* cons_string = i::String::VisitFlat(this, string, 0); | 4180 i::ConsString* cons_string = i::String::VisitFlat(this, string, 0); |
4209 if (cons_string == NULL) return is_one_byte_; | 4181 if (cons_string == NULL) return is_one_byte_; |
4210 return CheckCons(cons_string); | 4182 return CheckCons(cons_string); |
4211 } | 4183 } |
4212 void VisitOneByteString(const uint8_t* chars, int length) { | 4184 void VisitOneByteString(const uint8_t* chars, int length) { |
4213 // Nothing to do. | 4185 // Nothing to do. |
4214 } | 4186 } |
4215 void VisitTwoByteString(const uint16_t* chars, int length) { | 4187 void VisitTwoByteString(const uint16_t* chars, int length) { |
4216 // Accumulated bits. | 4188 // Accumulated bits. |
4217 uintptr_t acc = 0; | 4189 uintptr_t acc = 0; |
4218 // Align to uintptr_t. | 4190 // Align to uintptr_t. |
4219 const uint16_t* end = chars + length; | 4191 const uint16_t* end = chars + length; |
4220 while (Unaligned(chars) && chars != end) { | 4192 while (Unaligned(chars) && chars != end) { |
4221 acc |= *chars++; | 4193 acc |= *chars++; |
4222 } | 4194 } |
4223 // Read word aligned in blocks, | 4195 // Read word aligned in blocks, |
4224 // checking the return value at the end of each block. | 4196 // checking the return value at the end of each block. |
4225 const uint16_t* aligned_end = Align(end); | 4197 const uint16_t* aligned_end = Align(end); |
4226 const int increment = sizeof(uintptr_t)/sizeof(uint16_t); | 4198 const int increment = sizeof(uintptr_t)/sizeof(uint16_t); |
4227 const int inner_loops = 16; | 4199 const int inner_loops = 16; |
4228 while (chars + inner_loops*increment < aligned_end) { | 4200 while (chars + inner_loops*increment < aligned_end) { |
4229 for (int i = 0; i < inner_loops; i++) { | 4201 for (int i = 0; i < inner_loops; i++) { |
4230 acc |= *reinterpret_cast<const uintptr_t*>(chars); | 4202 acc |= *reinterpret_cast<const uintptr_t*>(chars); |
4231 chars += increment; | 4203 chars += increment; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4315 return state & kEndsWithLeadingSurrogate; | 4287 return state & kEndsWithLeadingSurrogate; |
4316 } | 4288 } |
4317 | 4289 |
4318 static inline bool StartsWithSurrogate(uint8_t state) { | 4290 static inline bool StartsWithSurrogate(uint8_t state) { |
4319 return state & kStartsWithTrailingSurrogate; | 4291 return state & kStartsWithTrailingSurrogate; |
4320 } | 4292 } |
4321 | 4293 |
4322 class Visitor { | 4294 class Visitor { |
4323 public: | 4295 public: |
4324 inline explicit Visitor() | 4296 inline explicit Visitor() |
4325 : utf8_length_(0), | 4297 : utf8_length_(0), |
4326 state_(kInitialState) {} | 4298 state_(kInitialState) {} |
4327 | 4299 |
4328 void VisitOneByteString(const uint8_t* chars, int length) { | 4300 void VisitOneByteString(const uint8_t* chars, int length) { |
4329 int utf8_length = 0; | 4301 int utf8_length = 0; |
4330 // Add in length 1 for each non-ASCII character. | 4302 // Add in length 1 for each non-ASCII character. |
4331 for (int i = 0; i < length; i++) { | 4303 for (int i = 0; i < length; i++) { |
4332 utf8_length += *chars++ >> 7; | 4304 utf8_length += *chars++ >> 7; |
4333 } | 4305 } |
4334 // Add in length 1 for each character. | 4306 // Add in length 1 for each character. |
4335 utf8_length_ = utf8_length + length; | 4307 utf8_length_ = utf8_length + length; |
4336 state_ = kInitialState; | 4308 state_ = kInitialState; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4389 } | 4361 } |
4390 } | 4362 } |
4391 | 4363 |
4392 static inline void MergeLeafRight(int* length, | 4364 static inline void MergeLeafRight(int* length, |
4393 uint8_t* state, | 4365 uint8_t* state, |
4394 uint8_t leaf_state) { | 4366 uint8_t leaf_state) { |
4395 bool edge_surrogate = EndsWithSurrogate(leaf_state); | 4367 bool edge_surrogate = EndsWithSurrogate(leaf_state); |
4396 if (!(*state & kRightmostEdgeIsCalculated)) { | 4368 if (!(*state & kRightmostEdgeIsCalculated)) { |
4397 ASSERT(!(*state & kRightmostEdgeIsSurrogate)); | 4369 ASSERT(!(*state & kRightmostEdgeIsSurrogate)); |
4398 *state |= (kRightmostEdgeIsCalculated | 4370 *state |= (kRightmostEdgeIsCalculated |
4399 | (edge_surrogate ? kRightmostEdgeIsSurrogate : 0)); | 4371 | (edge_surrogate ? kRightmostEdgeIsSurrogate : 0)); |
4400 } else if (edge_surrogate && StartsWithSurrogate(*state)) { | 4372 } else if (edge_surrogate && StartsWithSurrogate(*state)) { |
4401 *length -= unibrow::Utf8::kBytesSavedByCombiningSurrogates; | 4373 *length -= unibrow::Utf8::kBytesSavedByCombiningSurrogates; |
4402 } | 4374 } |
4403 if (StartsWithSurrogate(leaf_state)) { | 4375 if (StartsWithSurrogate(leaf_state)) { |
4404 *state |= kStartsWithTrailingSurrogate; | 4376 *state |= kStartsWithTrailingSurrogate; |
4405 } else { | 4377 } else { |
4406 *state &= ~kStartsWithTrailingSurrogate; | 4378 *state &= ~kStartsWithTrailingSurrogate; |
4407 } | 4379 } |
4408 } | 4380 } |
4409 | 4381 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4496 i::Handle<i::String> str = Utils::OpenHandle(this); | 4468 i::Handle<i::String> str = Utils::OpenHandle(this); |
4497 i::Isolate* isolate = str->GetIsolate(); | 4469 i::Isolate* isolate = str->GetIsolate(); |
4498 return v8::Utf8Length(*str, isolate); | 4470 return v8::Utf8Length(*str, isolate); |
4499 } | 4471 } |
4500 | 4472 |
4501 | 4473 |
4502 class Utf8WriterVisitor { | 4474 class Utf8WriterVisitor { |
4503 public: | 4475 public: |
4504 Utf8WriterVisitor( | 4476 Utf8WriterVisitor( |
4505 char* buffer, int capacity, bool skip_capacity_check) | 4477 char* buffer, int capacity, bool skip_capacity_check) |
4506 : early_termination_(false), | 4478 : early_termination_(false), |
4507 last_character_(unibrow::Utf16::kNoPreviousCharacter), | 4479 last_character_(unibrow::Utf16::kNoPreviousCharacter), |
4508 buffer_(buffer), | 4480 buffer_(buffer), |
4509 start_(buffer), | 4481 start_(buffer), |
4510 capacity_(capacity), | 4482 capacity_(capacity), |
4511 skip_capacity_check_(capacity == -1 || skip_capacity_check), | 4483 skip_capacity_check_(capacity == -1 || skip_capacity_check), |
4512 utf16_chars_read_(0) { | 4484 utf16_chars_read_(0) { |
4513 } | 4485 } |
4514 | 4486 |
4515 static int WriteEndCharacter(uint16_t character, | 4487 static int WriteEndCharacter(uint16_t character, |
4516 int last_character, | 4488 int last_character, |
4517 int remaining, | 4489 int remaining, |
4518 char* const buffer) { | 4490 char* const buffer) { |
4519 using namespace unibrow; | 4491 using namespace unibrow; |
4520 ASSERT(remaining > 0); | 4492 ASSERT(remaining > 0); |
4521 // We can't use a local buffer here because Encode needs to modify | 4493 // We can't use a local buffer here because Encode needs to modify |
4522 // previous characters in the stream. We know, however, that | 4494 // previous characters in the stream. We know, however, that |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4649 char* buffer_; | 4621 char* buffer_; |
4650 char* const start_; | 4622 char* const start_; |
4651 int capacity_; | 4623 int capacity_; |
4652 bool const skip_capacity_check_; | 4624 bool const skip_capacity_check_; |
4653 int utf16_chars_read_; | 4625 int utf16_chars_read_; |
4654 DISALLOW_IMPLICIT_CONSTRUCTORS(Utf8WriterVisitor); | 4626 DISALLOW_IMPLICIT_CONSTRUCTORS(Utf8WriterVisitor); |
4655 }; | 4627 }; |
4656 | 4628 |
4657 | 4629 |
4658 static bool RecursivelySerializeToUtf8(i::String* current, | 4630 static bool RecursivelySerializeToUtf8(i::String* current, |
4659 Utf8WriterVisitor* writer, | 4631 Utf8WriterVisitor* writer, |
4660 int recursion_budget) { | 4632 int recursion_budget) { |
4661 while (!writer->IsDone()) { | 4633 while (!writer->IsDone()) { |
4662 i::ConsString* cons_string = i::String::VisitFlat(writer, current); | 4634 i::ConsString* cons_string = i::String::VisitFlat(writer, current); |
4663 if (cons_string == NULL) return true; // Leaf node. | 4635 if (cons_string == NULL) return true; // Leaf node. |
4664 if (recursion_budget <= 0) return false; | 4636 if (recursion_budget <= 0) return false; |
4665 // Must write the left branch first. | 4637 // Must write the left branch first. |
4666 i::String* first = cons_string->first(); | 4638 i::String* first = cons_string->first(); |
4667 bool success = RecursivelySerializeToUtf8(first, | 4639 bool success = RecursivelySerializeToUtf8(first, |
4668 writer, | 4640 writer, |
4669 recursion_budget - 1); | 4641 recursion_budget - 1); |
4670 if (!success) return false; | 4642 if (!success) return false; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4808 expected = reinterpret_cast<const ExternalStringResourceBase*>(resource); | 4780 expected = reinterpret_cast<const ExternalStringResourceBase*>(resource); |
4809 expectedEncoding = ASCII_ENCODING; | 4781 expectedEncoding = ASCII_ENCODING; |
4810 } else if (i::StringShape(*str).IsExternalTwoByte()) { | 4782 } else if (i::StringShape(*str).IsExternalTwoByte()) { |
4811 const void* resource = | 4783 const void* resource = |
4812 i::Handle<i::ExternalTwoByteString>::cast(str)->resource(); | 4784 i::Handle<i::ExternalTwoByteString>::cast(str)->resource(); |
4813 expected = reinterpret_cast<const ExternalStringResourceBase*>(resource); | 4785 expected = reinterpret_cast<const ExternalStringResourceBase*>(resource); |
4814 expectedEncoding = TWO_BYTE_ENCODING; | 4786 expectedEncoding = TWO_BYTE_ENCODING; |
4815 } else { | 4787 } else { |
4816 expected = NULL; | 4788 expected = NULL; |
4817 expectedEncoding = str->IsOneByteRepresentation() ? ASCII_ENCODING | 4789 expectedEncoding = str->IsOneByteRepresentation() ? ASCII_ENCODING |
4818 : TWO_BYTE_ENCODING; | 4790 : TWO_BYTE_ENCODING; |
4819 } | 4791 } |
4820 CHECK_EQ(expected, value); | 4792 CHECK_EQ(expected, value); |
4821 CHECK_EQ(expectedEncoding, encoding); | 4793 CHECK_EQ(expectedEncoding, encoding); |
4822 } | 4794 } |
4823 | 4795 |
4824 const v8::String::ExternalAsciiStringResource* | 4796 const v8::String::ExternalAsciiStringResource* |
4825 v8::String::GetExternalAsciiStringResource() const { | 4797 v8::String::GetExternalAsciiStringResource() const { |
4826 i::Handle<i::String> str = Utils::OpenHandle(this); | 4798 i::Handle<i::String> str = Utils::OpenHandle(this); |
4827 if (i::StringShape(*str).IsExternalAscii()) { | 4799 if (i::StringShape(*str).IsExternalAscii()) { |
4828 const void* resource = | 4800 const void* resource = |
4829 i::Handle<i::ExternalAsciiString>::cast(str)->resource(); | 4801 i::Handle<i::ExternalAsciiString>::cast(str)->resource(); |
4830 return reinterpret_cast<const ExternalAsciiStringResource*>(resource); | 4802 return reinterpret_cast<const ExternalAsciiStringResource*>(resource); |
4831 } else { | 4803 } else { |
4832 return NULL; | 4804 return NULL; |
4833 } | 4805 } |
4834 } | 4806 } |
4835 | 4807 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4890 | 4862 |
4891 int v8::Object::InternalFieldCount() { | 4863 int v8::Object::InternalFieldCount() { |
4892 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 4864 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
4893 return obj->GetInternalFieldCount(); | 4865 return obj->GetInternalFieldCount(); |
4894 } | 4866 } |
4895 | 4867 |
4896 | 4868 |
4897 static bool InternalFieldOK(i::Handle<i::JSObject> obj, | 4869 static bool InternalFieldOK(i::Handle<i::JSObject> obj, |
4898 int index, | 4870 int index, |
4899 const char* location) { | 4871 const char* location) { |
4900 return ApiCheck(index < obj->GetInternalFieldCount(), | 4872 return Utils::ApiCheck(index < obj->GetInternalFieldCount(), |
4901 location, | 4873 location, |
4902 "Internal field out of bounds"); | 4874 "Internal field out of bounds"); |
4903 } | 4875 } |
4904 | 4876 |
4905 | 4877 |
4906 Local<Value> v8::Object::SlowGetInternalField(int index) { | 4878 Local<Value> v8::Object::SlowGetInternalField(int index) { |
4907 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 4879 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
4908 const char* location = "v8::Object::GetInternalField()"; | 4880 const char* location = "v8::Object::GetInternalField()"; |
4909 if (!InternalFieldOK(obj, index, location)) return Local<Value>(); | 4881 if (!InternalFieldOK(obj, index, location)) return Local<Value>(); |
4910 i::Handle<i::Object> value(obj->GetInternalField(index), obj->GetIsolate()); | 4882 i::Handle<i::Object> value(obj->GetInternalField(index), obj->GetIsolate()); |
4911 return Utils::ToLocal(value); | 4883 return Utils::ToLocal(value); |
4912 } | 4884 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4976 return InitializeHelper(isolate); | 4948 return InitializeHelper(isolate); |
4977 } | 4949 } |
4978 | 4950 |
4979 | 4951 |
4980 void v8::V8::SetEntropySource(EntropySource entropy_source) { | 4952 void v8::V8::SetEntropySource(EntropySource entropy_source) { |
4981 i::RandomNumberGenerator::SetEntropySource(entropy_source); | 4953 i::RandomNumberGenerator::SetEntropySource(entropy_source); |
4982 } | 4954 } |
4983 | 4955 |
4984 | 4956 |
4985 void v8::V8::SetReturnAddressLocationResolver( | 4957 void v8::V8::SetReturnAddressLocationResolver( |
4986 ReturnAddressLocationResolver return_address_resolver) { | 4958 ReturnAddressLocationResolver return_address_resolver) { |
4987 i::V8::SetReturnAddressLocationResolver(return_address_resolver); | 4959 i::V8::SetReturnAddressLocationResolver(return_address_resolver); |
4988 } | 4960 } |
4989 | 4961 |
4990 | 4962 |
4991 bool v8::V8::SetFunctionEntryHook(Isolate* ext_isolate, | 4963 bool v8::V8::SetFunctionEntryHook(Isolate* ext_isolate, |
4992 FunctionEntryHook entry_hook) { | 4964 FunctionEntryHook entry_hook) { |
4993 ASSERT(ext_isolate != NULL); | 4965 ASSERT(ext_isolate != NULL); |
4994 ASSERT(entry_hook != NULL); | 4966 ASSERT(entry_hook != NULL); |
4995 | 4967 |
4996 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(ext_isolate); | 4968 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(ext_isolate); |
(...skipping 17 matching lines...) Expand all Loading... |
5014 void v8::V8::SetJitCodeEventHandler( | 4986 void v8::V8::SetJitCodeEventHandler( |
5015 JitCodeEventOptions options, JitCodeEventHandler event_handler) { | 4987 JitCodeEventOptions options, JitCodeEventHandler event_handler) { |
5016 i::Isolate* isolate = i::Isolate::Current(); | 4988 i::Isolate* isolate = i::Isolate::Current(); |
5017 // Ensure that logging is initialized for our isolate. | 4989 // Ensure that logging is initialized for our isolate. |
5018 isolate->InitializeLoggingAndCounters(); | 4990 isolate->InitializeLoggingAndCounters(); |
5019 isolate->logger()->SetCodeEventHandler(options, event_handler); | 4991 isolate->logger()->SetCodeEventHandler(options, event_handler); |
5020 } | 4992 } |
5021 | 4993 |
5022 void v8::V8::SetArrayBufferAllocator( | 4994 void v8::V8::SetArrayBufferAllocator( |
5023 ArrayBuffer::Allocator* allocator) { | 4995 ArrayBuffer::Allocator* allocator) { |
5024 if (!ApiCheck(i::V8::ArrayBufferAllocator() == NULL, | 4996 if (!Utils::ApiCheck(i::V8::ArrayBufferAllocator() == NULL, |
5025 "v8::V8::SetArrayBufferAllocator", | 4997 "v8::V8::SetArrayBufferAllocator", |
5026 "ArrayBufferAllocator might only be set once")) | 4998 "ArrayBufferAllocator might only be set once")) |
5027 return; | 4999 return; |
5028 i::V8::SetArrayBufferAllocator(allocator); | 5000 i::V8::SetArrayBufferAllocator(allocator); |
5029 } | 5001 } |
5030 | 5002 |
5031 | 5003 |
5032 bool v8::V8::Dispose() { | 5004 bool v8::V8::Dispose() { |
5033 i::Isolate* isolate = i::Isolate::Current(); | 5005 i::Isolate* isolate = i::Isolate::Current(); |
5034 if (!ApiCheck(isolate != NULL && isolate->IsDefaultIsolate(), | 5006 if (!Utils::ApiCheck(isolate != NULL && isolate->IsDefaultIsolate(), |
5035 "v8::V8::Dispose()", | 5007 "v8::V8::Dispose()", |
5036 "Use v8::Isolate::Dispose() for a non-default isolate.")) { | 5008 "Use v8::Isolate::Dispose() for non-default isolate.")) { |
5037 return false; | 5009 return false; |
5038 } | 5010 } |
5039 i::V8::TearDown(); | 5011 i::V8::TearDown(); |
5040 return true; | 5012 return true; |
5041 } | 5013 } |
5042 | 5014 |
5043 | 5015 |
5044 HeapStatistics::HeapStatistics(): total_heap_size_(0), | 5016 HeapStatistics::HeapStatistics(): total_heap_size_(0), |
5045 total_heap_size_executable_(0), | 5017 total_heap_size_executable_(0), |
5046 total_physical_size_(0), | 5018 total_physical_size_(0), |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5245 | 5217 |
5246 | 5218 |
5247 v8::Local<v8::Object> Context::Global() { | 5219 v8::Local<v8::Object> Context::Global() { |
5248 i::Handle<i::Context> context = Utils::OpenHandle(this); | 5220 i::Handle<i::Context> context = Utils::OpenHandle(this); |
5249 i::Isolate* isolate = context->GetIsolate(); | 5221 i::Isolate* isolate = context->GetIsolate(); |
5250 i::Handle<i::Object> global(context->global_proxy(), isolate); | 5222 i::Handle<i::Object> global(context->global_proxy(), isolate); |
5251 // TODO(dcarney): This should always return the global proxy | 5223 // TODO(dcarney): This should always return the global proxy |
5252 // but can't presently as calls to GetProtoype will return the wrong result. | 5224 // but can't presently as calls to GetProtoype will return the wrong result. |
5253 if (i::Handle<i::JSGlobalProxy>::cast( | 5225 if (i::Handle<i::JSGlobalProxy>::cast( |
5254 global)->IsDetachedFrom(context->global_object())) { | 5226 global)->IsDetachedFrom(context->global_object())) { |
5255 global = i::Handle<i::Object>(context->global_object(), isolate); | 5227 global = i::Handle<i::Object>(context->global_object(), isolate); |
5256 } | 5228 } |
5257 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global)); | 5229 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global)); |
5258 } | 5230 } |
5259 | 5231 |
5260 | 5232 |
5261 void Context::DetachGlobal() { | 5233 void Context::DetachGlobal() { |
5262 i::Handle<i::Context> context = Utils::OpenHandle(this); | 5234 i::Handle<i::Context> context = Utils::OpenHandle(this); |
5263 i::Isolate* isolate = context->GetIsolate(); | 5235 i::Isolate* isolate = context->GetIsolate(); |
5264 ENTER_V8(isolate); | 5236 ENTER_V8(isolate); |
5265 isolate->bootstrapper()->DetachGlobal(context); | 5237 isolate->bootstrapper()->DetachGlobal(context); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5465 EnsureInitializedForIsolate(isolate, "v8::String::New()"); | 5437 EnsureInitializedForIsolate(isolate, "v8::String::New()"); |
5466 LOG_API(isolate, "String::New(char)"); | 5438 LOG_API(isolate, "String::New(char)"); |
5467 ENTER_V8(isolate); | 5439 ENTER_V8(isolate); |
5468 i::Handle<i::String> right_string = Utils::OpenHandle(*right); | 5440 i::Handle<i::String> right_string = Utils::OpenHandle(*right); |
5469 i::Handle<i::String> result = isolate->factory()->NewConsString(left_string, | 5441 i::Handle<i::String> result = isolate->factory()->NewConsString(left_string, |
5470 right_string); | 5442 right_string); |
5471 return Utils::ToLocal(result); | 5443 return Utils::ToLocal(result); |
5472 } | 5444 } |
5473 | 5445 |
5474 | 5446 |
5475 i::Handle<i::String> NewExternalStringHandle(i::Isolate* isolate, | 5447 static i::Handle<i::String> NewExternalStringHandle( |
5476 v8::String::ExternalStringResource* resource) { | 5448 i::Isolate* isolate, |
5477 i::Handle<i::String> result = | 5449 v8::String::ExternalStringResource* resource) { |
5478 isolate->factory()->NewExternalStringFromTwoByte(resource); | 5450 return isolate->factory()->NewExternalStringFromTwoByte(resource); |
5479 return result; | |
5480 } | 5451 } |
5481 | 5452 |
5482 | 5453 |
5483 i::Handle<i::String> NewExternalAsciiStringHandle(i::Isolate* isolate, | 5454 static i::Handle<i::String> NewExternalAsciiStringHandle( |
5484 v8::String::ExternalAsciiStringResource* resource) { | 5455 i::Isolate* isolate, |
5485 i::Handle<i::String> result = | 5456 v8::String::ExternalAsciiStringResource* resource) { |
5486 isolate->factory()->NewExternalStringFromAscii(resource); | 5457 return isolate->factory()->NewExternalStringFromAscii(resource); |
5487 return result; | |
5488 } | 5458 } |
5489 | 5459 |
5490 | 5460 |
5491 bool RedirectToExternalString(i::Isolate* isolate, | 5461 static bool RedirectToExternalString(i::Isolate* isolate, |
5492 i::Handle<i::String> parent, | 5462 i::Handle<i::String> parent, |
5493 i::Handle<i::String> external) { | 5463 i::Handle<i::String> external) { |
5494 if (parent->IsConsString()) { | 5464 if (parent->IsConsString()) { |
5495 i::Handle<i::ConsString> cons = i::Handle<i::ConsString>::cast(parent); | 5465 i::Handle<i::ConsString> cons = i::Handle<i::ConsString>::cast(parent); |
5496 cons->set_first(*external); | 5466 cons->set_first(*external); |
5497 cons->set_second(isolate->heap()->empty_string()); | 5467 cons->set_second(isolate->heap()->empty_string()); |
5498 } else { | 5468 } else { |
5499 ASSERT(parent->IsSlicedString()); | 5469 ASSERT(parent->IsSlicedString()); |
5500 i::Handle<i::SlicedString> slice = i::Handle<i::SlicedString>::cast(parent); | 5470 i::Handle<i::SlicedString> slice = i::Handle<i::SlicedString>::cast(parent); |
5501 slice->set_parent(*external); | 5471 slice->set_parent(*external); |
5502 slice->set_offset(0); | 5472 slice->set_offset(0); |
5503 } | 5473 } |
5504 return true; | 5474 return true; |
5505 } | 5475 } |
5506 | 5476 |
5507 | 5477 |
5508 Local<String> v8::String::NewExternal( | 5478 Local<String> v8::String::NewExternal( |
5509 Isolate* isolate, | 5479 Isolate* isolate, |
5510 v8::String::ExternalStringResource* resource) { | 5480 v8::String::ExternalStringResource* resource) { |
5511 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 5481 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
5512 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()"); | 5482 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()"); |
5513 LOG_API(i_isolate, "String::NewExternal"); | 5483 LOG_API(i_isolate, "String::NewExternal"); |
5514 ENTER_V8(i_isolate); | 5484 ENTER_V8(i_isolate); |
5515 CHECK(resource && resource->data()); | 5485 CHECK(resource && resource->data()); |
5516 i::Handle<i::String> result = NewExternalStringHandle(i_isolate, resource); | 5486 i::Handle<i::String> result = NewExternalStringHandle(i_isolate, resource); |
5517 i_isolate->heap()->external_string_table()->AddString(*result); | 5487 i_isolate->heap()->external_string_table()->AddString(*result); |
5518 return Utils::ToLocal(result); | 5488 return Utils::ToLocal(result); |
5519 } | 5489 } |
5520 | 5490 |
(...skipping 28 matching lines...) Expand all Loading... |
5549 | 5519 |
5550 if (result) { | 5520 if (result) { |
5551 ASSERT(external->IsExternalString()); | 5521 ASSERT(external->IsExternalString()); |
5552 isolate->heap()->external_string_table()->AddString(*external); | 5522 isolate->heap()->external_string_table()->AddString(*external); |
5553 } | 5523 } |
5554 return result; | 5524 return result; |
5555 } | 5525 } |
5556 | 5526 |
5557 | 5527 |
5558 Local<String> v8::String::NewExternal( | 5528 Local<String> v8::String::NewExternal( |
5559 Isolate* isolate, | 5529 Isolate* isolate, |
5560 v8::String::ExternalAsciiStringResource* resource) { | 5530 v8::String::ExternalAsciiStringResource* resource) { |
5561 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 5531 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
5562 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()"); | 5532 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()"); |
5563 LOG_API(i_isolate, "String::NewExternal"); | 5533 LOG_API(i_isolate, "String::NewExternal"); |
5564 ENTER_V8(i_isolate); | 5534 ENTER_V8(i_isolate); |
5565 CHECK(resource && resource->data()); | 5535 CHECK(resource && resource->data()); |
5566 i::Handle<i::String> result = | 5536 i::Handle<i::String> result = |
5567 NewExternalAsciiStringHandle(i_isolate, resource); | 5537 NewExternalAsciiStringHandle(i_isolate, resource); |
5568 i_isolate->heap()->external_string_table()->AddString(*result); | 5538 i_isolate->heap()->external_string_table()->AddString(*result); |
5569 return Utils::ToLocal(result); | 5539 return Utils::ToLocal(result); |
5570 } | 5540 } |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5812 } | 5782 } |
5813 | 5783 |
5814 | 5784 |
5815 Local<v8::String> v8::RegExp::GetSource() const { | 5785 Local<v8::String> v8::RegExp::GetSource() const { |
5816 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); | 5786 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); |
5817 return Utils::ToLocal(i::Handle<i::String>(obj->Pattern())); | 5787 return Utils::ToLocal(i::Handle<i::String>(obj->Pattern())); |
5818 } | 5788 } |
5819 | 5789 |
5820 | 5790 |
5821 // Assert that the static flags cast in GetFlags is valid. | 5791 // Assert that the static flags cast in GetFlags is valid. |
5822 #define REGEXP_FLAG_ASSERT_EQ(api_flag, internal_flag) \ | 5792 #define REGEXP_FLAG_ASSERT_EQ(api_flag, internal_flag) \ |
5823 STATIC_ASSERT(static_cast<int>(v8::RegExp::api_flag) == \ | 5793 STATIC_ASSERT(static_cast<int>(v8::RegExp::api_flag) == \ |
5824 static_cast<int>(i::JSRegExp::internal_flag)) | 5794 static_cast<int>(i::JSRegExp::internal_flag)) |
5825 REGEXP_FLAG_ASSERT_EQ(kNone, NONE); | 5795 REGEXP_FLAG_ASSERT_EQ(kNone, NONE); |
5826 REGEXP_FLAG_ASSERT_EQ(kGlobal, GLOBAL); | 5796 REGEXP_FLAG_ASSERT_EQ(kGlobal, GLOBAL); |
5827 REGEXP_FLAG_ASSERT_EQ(kIgnoreCase, IGNORE_CASE); | 5797 REGEXP_FLAG_ASSERT_EQ(kIgnoreCase, IGNORE_CASE); |
5828 REGEXP_FLAG_ASSERT_EQ(kMultiline, MULTILINE); | 5798 REGEXP_FLAG_ASSERT_EQ(kMultiline, MULTILINE); |
5829 #undef REGEXP_FLAG_ASSERT_EQ | 5799 #undef REGEXP_FLAG_ASSERT_EQ |
5830 | 5800 |
5831 v8::RegExp::Flags v8::RegExp::GetFlags() const { | 5801 v8::RegExp::Flags v8::RegExp::GetFlags() const { |
5832 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); | 5802 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); |
5833 return static_cast<RegExp::Flags>(obj->GetFlags().value()); | 5803 return static_cast<RegExp::Flags>(obj->GetFlags().value()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5881 } | 5851 } |
5882 | 5852 |
5883 | 5853 |
5884 bool v8::ArrayBuffer::IsExternal() const { | 5854 bool v8::ArrayBuffer::IsExternal() const { |
5885 return Utils::OpenHandle(this)->is_external(); | 5855 return Utils::OpenHandle(this)->is_external(); |
5886 } | 5856 } |
5887 | 5857 |
5888 | 5858 |
5889 v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() { | 5859 v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() { |
5890 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); | 5860 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); |
5891 ApiCheck(!obj->is_external(), | 5861 Utils::ApiCheck(!obj->is_external(), |
5892 "v8::ArrayBuffer::Externalize", | 5862 "v8::ArrayBuffer::Externalize", |
5893 "ArrayBuffer already externalized"); | 5863 "ArrayBuffer already externalized"); |
5894 obj->set_is_external(true); | 5864 obj->set_is_external(true); |
5895 size_t byte_length = static_cast<size_t>(obj->byte_length()->Number()); | 5865 size_t byte_length = static_cast<size_t>(obj->byte_length()->Number()); |
5896 Contents contents; | 5866 Contents contents; |
5897 contents.data_ = obj->backing_store(); | 5867 contents.data_ = obj->backing_store(); |
5898 contents.byte_length_ = byte_length; | 5868 contents.byte_length_ = byte_length; |
5899 return contents; | 5869 return contents; |
5900 } | 5870 } |
5901 | 5871 |
5902 | 5872 |
5903 void v8::ArrayBuffer::Neuter() { | 5873 void v8::ArrayBuffer::Neuter() { |
5904 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); | 5874 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); |
5905 i::Isolate* isolate = obj->GetIsolate(); | 5875 i::Isolate* isolate = obj->GetIsolate(); |
5906 ApiCheck(obj->is_external(), | 5876 Utils::ApiCheck(obj->is_external(), |
5907 "v8::ArrayBuffer::Neuter", | 5877 "v8::ArrayBuffer::Neuter", |
5908 "Only externalized ArrayBuffers can be neutered"); | 5878 "Only externalized ArrayBuffers can be neutered"); |
5909 LOG_API(obj->GetIsolate(), "v8::ArrayBuffer::Neuter()"); | 5879 LOG_API(obj->GetIsolate(), "v8::ArrayBuffer::Neuter()"); |
5910 ENTER_V8(isolate); | 5880 ENTER_V8(isolate); |
5911 | 5881 |
5912 for (i::Handle<i::Object> view_obj(obj->weak_first_view(), isolate); | 5882 for (i::Handle<i::Object> view_obj(obj->weak_first_view(), isolate); |
5913 !view_obj->IsUndefined();) { | 5883 !view_obj->IsUndefined();) { |
5914 i::Handle<i::JSArrayBufferView> view(i::JSArrayBufferView::cast(*view_obj)); | 5884 i::Handle<i::JSArrayBufferView> view(i::JSArrayBufferView::cast(*view_obj)); |
5915 if (view->IsJSTypedArray()) { | 5885 if (view->IsJSTypedArray()) { |
5916 i::JSTypedArray::cast(*view)->Neuter(); | 5886 i::JSTypedArray::cast(*view)->Neuter(); |
5917 } else if (view->IsJSDataView()) { | 5887 } else if (view->IsJSDataView()) { |
5918 i::JSDataView::cast(*view)->Neuter(); | 5888 i::JSDataView::cast(*view)->Neuter(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5982 } | 5952 } |
5983 | 5953 |
5984 | 5954 |
5985 static inline void SetupArrayBufferView( | 5955 static inline void SetupArrayBufferView( |
5986 i::Isolate* isolate, | 5956 i::Isolate* isolate, |
5987 i::Handle<i::JSArrayBufferView> obj, | 5957 i::Handle<i::JSArrayBufferView> obj, |
5988 i::Handle<i::JSArrayBuffer> buffer, | 5958 i::Handle<i::JSArrayBuffer> buffer, |
5989 size_t byte_offset, | 5959 size_t byte_offset, |
5990 size_t byte_length) { | 5960 size_t byte_length) { |
5991 ASSERT(byte_offset + byte_length <= | 5961 ASSERT(byte_offset + byte_length <= |
5992 static_cast<size_t>(buffer->byte_length()->Number())); | 5962 static_cast<size_t>(buffer->byte_length()->Number())); |
5993 | 5963 |
5994 obj->set_buffer(*buffer); | 5964 obj->set_buffer(*buffer); |
5995 | 5965 |
5996 obj->set_weak_next(buffer->weak_first_view()); | 5966 obj->set_weak_next(buffer->weak_first_view()); |
5997 buffer->set_weak_first_view(*obj); | 5967 buffer->set_weak_first_view(*obj); |
5998 | 5968 |
5999 i::Handle<i::Object> byte_offset_object = | 5969 i::Handle<i::Object> byte_offset_object = |
6000 isolate->factory()->NewNumberFromSize(byte_offset); | 5970 isolate->factory()->NewNumberFromSize(byte_offset); |
6001 obj->set_byte_offset(*byte_offset_object); | 5971 obj->set_byte_offset(*byte_offset_object); |
6002 | 5972 |
6003 i::Handle<i::Object> byte_length_object = | 5973 i::Handle<i::Object> byte_length_object = |
6004 isolate->factory()->NewNumberFromSize(byte_length); | 5974 isolate->factory()->NewNumberFromSize(byte_length); |
6005 obj->set_byte_length(*byte_length_object); | 5975 obj->set_byte_length(*byte_length_object); |
6006 } | 5976 } |
6007 | 5977 |
6008 template<typename ElementType, | 5978 template<typename ElementType, |
6009 ExternalArrayType array_type, | 5979 ExternalArrayType array_type, |
6010 i::ElementsKind elements_kind> | 5980 i::ElementsKind elements_kind> |
6011 i::Handle<i::JSTypedArray> NewTypedArray( | 5981 i::Handle<i::JSTypedArray> NewTypedArray( |
6012 i::Isolate* isolate, | 5982 i::Isolate* isolate, |
6013 Handle<ArrayBuffer> array_buffer, size_t byte_offset, size_t length) { | 5983 Handle<ArrayBuffer> array_buffer, size_t byte_offset, size_t length) { |
6014 i::Handle<i::JSTypedArray> obj = | 5984 i::Handle<i::JSTypedArray> obj = |
6015 isolate->factory()->NewJSTypedArray(array_type); | 5985 isolate->factory()->NewJSTypedArray(array_type); |
6016 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer); | 5986 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer); |
6017 | 5987 |
6018 ASSERT(byte_offset % sizeof(ElementType) == 0); | 5988 ASSERT(byte_offset % sizeof(ElementType) == 0); |
6019 | 5989 |
6020 CHECK(length <= (std::numeric_limits<size_t>::max() / sizeof(ElementType))); | 5990 CHECK(length <= (std::numeric_limits<size_t>::max() / sizeof(ElementType))); |
6021 size_t byte_length = length * sizeof(ElementType); | 5991 size_t byte_length = length * sizeof(ElementType); |
6022 SetupArrayBufferView( | 5992 SetupArrayBufferView( |
6023 isolate, obj, buffer, byte_offset, byte_length); | 5993 isolate, obj, buffer, byte_offset, byte_length); |
6024 | 5994 |
6025 i::Handle<i::Object> length_object = | 5995 i::Handle<i::Object> length_object = |
6026 isolate->factory()->NewNumberFromSize(length); | 5996 isolate->factory()->NewNumberFromSize(length); |
6027 obj->set_length(*length_object); | 5997 obj->set_length(*length_object); |
6028 | 5998 |
6029 i::Handle<i::ExternalArray> elements = | 5999 i::Handle<i::ExternalArray> elements = |
6030 isolate->factory()->NewExternalArray( | 6000 isolate->factory()->NewExternalArray( |
6031 static_cast<int>(length), array_type, | 6001 static_cast<int>(length), array_type, |
6032 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); | 6002 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); |
6033 obj->set_elements(*elements); | 6003 obj->set_elements(*elements); |
6034 return obj; | 6004 return obj; |
6035 } | 6005 } |
6036 | 6006 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6168 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) { | 6138 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) { |
6169 i::Isolate* isolate = i::Isolate::Current(); | 6139 i::Isolate* isolate = i::Isolate::Current(); |
6170 EnsureInitializedForIsolate(isolate, "v8::V8::AddMessageListener()"); | 6140 EnsureInitializedForIsolate(isolate, "v8::V8::AddMessageListener()"); |
6171 ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false); | 6141 ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false); |
6172 ENTER_V8(isolate); | 6142 ENTER_V8(isolate); |
6173 i::HandleScope scope(isolate); | 6143 i::HandleScope scope(isolate); |
6174 NeanderArray listeners(isolate->factory()->message_listeners()); | 6144 NeanderArray listeners(isolate->factory()->message_listeners()); |
6175 NeanderObject obj(isolate, 2); | 6145 NeanderObject obj(isolate, 2); |
6176 obj.set(0, *isolate->factory()->NewForeign(FUNCTION_ADDR(that))); | 6146 obj.set(0, *isolate->factory()->NewForeign(FUNCTION_ADDR(that))); |
6177 obj.set(1, data.IsEmpty() ? isolate->heap()->undefined_value() | 6147 obj.set(1, data.IsEmpty() ? isolate->heap()->undefined_value() |
6178 : *Utils::OpenHandle(*data)); | 6148 : *Utils::OpenHandle(*data)); |
6179 listeners.add(obj.value()); | 6149 listeners.add(obj.value()); |
6180 return true; | 6150 return true; |
6181 } | 6151 } |
6182 | 6152 |
6183 | 6153 |
6184 void V8::RemoveMessageListeners(MessageCallback that) { | 6154 void V8::RemoveMessageListeners(MessageCallback that) { |
6185 i::Isolate* isolate = i::Isolate::Current(); | 6155 i::Isolate* isolate = i::Isolate::Current(); |
6186 EnsureInitializedForIsolate(isolate, "v8::V8::RemoveMessageListener()"); | 6156 EnsureInitializedForIsolate(isolate, "v8::V8::RemoveMessageListener()"); |
6187 ON_BAILOUT(isolate, "v8::V8::RemoveMessageListeners()", return); | 6157 ON_BAILOUT(isolate, "v8::V8::RemoveMessageListeners()", return); |
6188 ENTER_V8(isolate); | 6158 ENTER_V8(isolate); |
6189 i::HandleScope scope(isolate); | 6159 i::HandleScope scope(isolate); |
6190 NeanderArray listeners(isolate->factory()->message_listeners()); | 6160 NeanderArray listeners(isolate->factory()->message_listeners()); |
6191 for (int i = 0; i < listeners.length(); i++) { | 6161 for (int i = 0; i < listeners.length(); i++) { |
6192 if (listeners.get(i)->IsUndefined()) continue; // skip deleted ones | 6162 if (listeners.get(i)->IsUndefined()) continue; // skip deleted ones |
6193 | 6163 |
6194 NeanderObject listener(i::JSObject::cast(listeners.get(i))); | 6164 NeanderObject listener(i::JSObject::cast(listeners.get(i))); |
6195 i::Handle<i::Foreign> callback_obj(i::Foreign::cast(listener.get(0))); | 6165 i::Handle<i::Foreign> callback_obj(i::Foreign::cast(listener.get(0))); |
6196 if (callback_obj->foreign_address() == FUNCTION_ADDR(that)) { | 6166 if (callback_obj->foreign_address() == FUNCTION_ADDR(that)) { |
6197 listeners.set(i, isolate->heap()->undefined_value()); | 6167 listeners.set(i, isolate->heap()->undefined_value()); |
6198 } | 6168 } |
6199 } | 6169 } |
6200 } | 6170 } |
6201 | 6171 |
6202 | 6172 |
6203 void V8::SetCaptureStackTraceForUncaughtExceptions( | 6173 void V8::SetCaptureStackTraceForUncaughtExceptions( |
6204 bool capture, | 6174 bool capture, |
6205 int frame_limit, | 6175 int frame_limit, |
6206 StackTrace::StackTraceOptions options) { | 6176 StackTrace::StackTraceOptions options) { |
6207 i::Isolate::Current()->SetCaptureStackTraceForUncaughtExceptions( | 6177 i::Isolate::Current()->SetCaptureStackTraceForUncaughtExceptions( |
6208 capture, | 6178 capture, |
6209 frame_limit, | 6179 frame_limit, |
6210 options); | 6180 options); |
6211 } | 6181 } |
6212 | 6182 |
6213 | 6183 |
6214 void V8::SetCounterFunction(CounterLookupCallback callback) { | 6184 void V8::SetCounterFunction(CounterLookupCallback callback) { |
6215 i::Isolate* isolate = EnterIsolateIfNeeded(); | 6185 i::Isolate* isolate = EnterIsolateIfNeeded(); |
6216 isolate->stats_table()->SetCounterFunction(callback); | 6186 isolate->stats_table()->SetCounterFunction(callback); |
6217 } | 6187 } |
6218 | 6188 |
6219 | 6189 |
6220 void V8::SetCreateHistogramFunction(CreateHistogramCallback callback) { | 6190 void V8::SetCreateHistogramFunction(CreateHistogramCallback callback) { |
6221 i::Isolate* isolate = EnterIsolateIfNeeded(); | 6191 i::Isolate* isolate = EnterIsolateIfNeeded(); |
6222 isolate->stats_table()->SetCreateHistogramFunction(callback); | 6192 isolate->stats_table()->SetCreateHistogramFunction(callback); |
6223 isolate->InitializeLoggingAndCounters(); | 6193 isolate->InitializeLoggingAndCounters(); |
6224 isolate->counters()->ResetHistograms(); | 6194 isolate->counters()->ResetHistograms(); |
6225 } | 6195 } |
6226 | 6196 |
6227 | 6197 |
6228 void V8::SetAddHistogramSampleFunction(AddHistogramSampleCallback callback) { | 6198 void V8::SetAddHistogramSampleFunction(AddHistogramSampleCallback callback) { |
6229 i::Isolate* isolate = EnterIsolateIfNeeded(); | 6199 i::Isolate* isolate = EnterIsolateIfNeeded(); |
6230 isolate->stats_table()-> | 6200 isolate->stats_table()-> |
6231 SetAddHistogramSampleFunction(callback); | 6201 SetAddHistogramSampleFunction(callback); |
6232 } | 6202 } |
6233 | 6203 |
6234 void V8::SetFailedAccessCheckCallbackFunction( | 6204 void V8::SetFailedAccessCheckCallbackFunction( |
6235 FailedAccessCheckCallback callback) { | 6205 FailedAccessCheckCallback callback) { |
6236 i::Isolate* isolate = i::Isolate::Current(); | 6206 i::Isolate* isolate = i::Isolate::Current(); |
6237 isolate->SetFailedAccessCheckCallback(callback); | 6207 isolate->SetFailedAccessCheckCallback(callback); |
6238 } | 6208 } |
6239 | 6209 |
6240 | 6210 |
6241 int64_t Isolate::AdjustAmountOfExternalAllocatedMemory( | 6211 int64_t Isolate::AdjustAmountOfExternalAllocatedMemory( |
6242 int64_t change_in_bytes) { | 6212 int64_t change_in_bytes) { |
6243 i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap(); | 6213 i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap(); |
6244 return heap->AdjustAmountOfExternalAllocatedMemory(change_in_bytes); | 6214 return heap->AdjustAmountOfExternalAllocatedMemory(change_in_bytes); |
6245 } | 6215 } |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6459 | 6429 |
6460 | 6430 |
6461 Isolate* Isolate::New() { | 6431 Isolate* Isolate::New() { |
6462 i::Isolate* isolate = new i::Isolate(); | 6432 i::Isolate* isolate = new i::Isolate(); |
6463 return reinterpret_cast<Isolate*>(isolate); | 6433 return reinterpret_cast<Isolate*>(isolate); |
6464 } | 6434 } |
6465 | 6435 |
6466 | 6436 |
6467 void Isolate::Dispose() { | 6437 void Isolate::Dispose() { |
6468 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 6438 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
6469 if (!ApiCheck(!isolate->IsInUse(), | 6439 if (!Utils::ApiCheck(!isolate->IsInUse(), |
6470 "v8::Isolate::Dispose()", | 6440 "v8::Isolate::Dispose()", |
6471 "Disposing the isolate that is entered by a thread.")) { | 6441 "Disposing the isolate that is entered by a thread.")) { |
6472 return; | 6442 return; |
6473 } | 6443 } |
6474 isolate->TearDown(); | 6444 isolate->TearDown(); |
6475 } | 6445 } |
6476 | 6446 |
6477 | 6447 |
6478 void Isolate::Enter() { | 6448 void Isolate::Enter() { |
6479 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 6449 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
6480 isolate->Enter(); | 6450 isolate->Enter(); |
6481 } | 6451 } |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7123 } | 7093 } |
7124 | 7094 |
7125 | 7095 |
7126 SnapshotObjectId HeapSnapshot::GetMaxSnapshotJSObjectId() const { | 7096 SnapshotObjectId HeapSnapshot::GetMaxSnapshotJSObjectId() const { |
7127 return ToInternal(this)->max_snapshot_js_object_id(); | 7097 return ToInternal(this)->max_snapshot_js_object_id(); |
7128 } | 7098 } |
7129 | 7099 |
7130 | 7100 |
7131 void HeapSnapshot::Serialize(OutputStream* stream, | 7101 void HeapSnapshot::Serialize(OutputStream* stream, |
7132 HeapSnapshot::SerializationFormat format) const { | 7102 HeapSnapshot::SerializationFormat format) const { |
7133 ApiCheck(format == kJSON, | 7103 Utils::ApiCheck(format == kJSON, |
7134 "v8::HeapSnapshot::Serialize", | 7104 "v8::HeapSnapshot::Serialize", |
7135 "Unknown serialization format"); | 7105 "Unknown serialization format"); |
7136 ApiCheck(stream->GetOutputEncoding() == OutputStream::kAscii, | 7106 Utils::ApiCheck(stream->GetOutputEncoding() == OutputStream::kAscii, |
7137 "v8::HeapSnapshot::Serialize", | 7107 "v8::HeapSnapshot::Serialize", |
7138 "Unsupported output encoding"); | 7108 "Unsupported output encoding"); |
7139 ApiCheck(stream->GetChunkSize() > 0, | 7109 Utils::ApiCheck(stream->GetChunkSize() > 0, |
7140 "v8::HeapSnapshot::Serialize", | 7110 "v8::HeapSnapshot::Serialize", |
7141 "Invalid stream chunk size"); | 7111 "Invalid stream chunk size"); |
7142 i::HeapSnapshotJSONSerializer serializer(ToInternal(this)); | 7112 i::HeapSnapshotJSONSerializer serializer(ToInternal(this)); |
7143 serializer.Serialize(stream); | 7113 serializer.Serialize(stream); |
7144 } | 7114 } |
7145 | 7115 |
7146 | 7116 |
7147 int HeapProfiler::GetSnapshotCount() { | 7117 int HeapProfiler::GetSnapshotCount() { |
7148 return reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshotsCount(); | 7118 return reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshotsCount(); |
7149 } | 7119 } |
7150 | 7120 |
7151 | 7121 |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7458 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7428 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7459 Address callback_address = | 7429 Address callback_address = |
7460 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7430 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7461 VMState<EXTERNAL> state(isolate); | 7431 VMState<EXTERNAL> state(isolate); |
7462 ExternalCallbackScope call_scope(isolate, callback_address); | 7432 ExternalCallbackScope call_scope(isolate, callback_address); |
7463 callback(info); | 7433 callback(info); |
7464 } | 7434 } |
7465 | 7435 |
7466 | 7436 |
7467 } } // namespace v8::internal | 7437 } } // namespace v8::internal |
OLD | NEW |