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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 70 |
71 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) | 71 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) |
72 | 72 |
73 #define ENTER_V8(isolate) \ | 73 #define ENTER_V8(isolate) \ |
74 ASSERT((isolate)->IsInitialized()); \ | 74 ASSERT((isolate)->IsInitialized()); \ |
75 i::VMState<i::OTHER> __state__((isolate)) | 75 i::VMState<i::OTHER> __state__((isolate)) |
76 | 76 |
77 namespace v8 { | 77 namespace v8 { |
78 | 78 |
79 #define ON_BAILOUT(isolate, location, code) \ | 79 #define ON_BAILOUT(isolate, location, code) \ |
80 if (IsDeadCheck(isolate, location) || \ | 80 if (IsExecutionTerminatingCheck(isolate)) { \ |
81 IsExecutionTerminatingCheck(isolate)) { \ | |
82 code; \ | 81 code; \ |
83 UNREACHABLE(); \ | 82 UNREACHABLE(); \ |
84 } | 83 } |
85 | 84 |
86 | 85 |
87 #define EXCEPTION_PREAMBLE(isolate) \ | 86 #define EXCEPTION_PREAMBLE(isolate) \ |
88 (isolate)->handle_scope_implementer()->IncrementCallDepth(); \ | 87 (isolate)->handle_scope_implementer()->IncrementCallDepth(); \ |
89 ASSERT(!(isolate)->external_caught_exception()); \ | 88 ASSERT(!(isolate)->external_caught_exception()); \ |
90 bool has_pending_exception = false | 89 bool has_pending_exception = false |
91 | 90 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 } | 245 } |
247 | 246 |
248 | 247 |
249 static inline bool ApiCheck(bool condition, | 248 static inline bool ApiCheck(bool condition, |
250 const char* location, | 249 const char* location, |
251 const char* message) { | 250 const char* message) { |
252 return condition ? true : Utils::ReportApiFailure(location, message); | 251 return condition ? true : Utils::ReportApiFailure(location, message); |
253 } | 252 } |
254 | 253 |
255 | 254 |
256 static bool ReportV8Dead(const char* location) { | |
257 FatalErrorCallback callback = GetFatalErrorHandler(); | |
258 callback(location, "V8 is no longer usable"); | |
259 return true; | |
260 } | |
261 | |
262 | |
263 static bool ReportEmptyHandle(const char* location) { | 255 static bool ReportEmptyHandle(const char* location) { |
264 FatalErrorCallback callback = GetFatalErrorHandler(); | 256 FatalErrorCallback callback = GetFatalErrorHandler(); |
265 callback(location, "Reading from empty handle"); | 257 callback(location, "Reading from empty handle"); |
266 return true; | 258 return true; |
267 } | 259 } |
268 | 260 |
269 | 261 |
270 /** | |
271 * IsDeadCheck checks that the vm is usable. If, for instance, the vm has been | |
272 * out of memory at some point this check will fail. It should be called on | |
273 * entry to all methods that touch anything in the heap, except destructors | |
274 * which you sometimes can't avoid calling after the vm has crashed. Functions | |
275 * that call EnsureInitialized or ON_BAILOUT don't have to also call | |
276 * IsDeadCheck. ON_BAILOUT has the advantage over EnsureInitialized that you | |
277 * can arrange to return if the VM is dead. This is needed to ensure that no VM | |
278 * heap allocations are attempted on a dead VM. EnsureInitialized has the | |
279 * advantage over ON_BAILOUT that it actually initializes the VM if this has not | |
280 * yet been done. | |
281 */ | |
282 static inline bool IsDeadCheck(i::Isolate* isolate, const char* location) { | |
283 return !isolate->IsInitialized() | |
284 && isolate->IsDead() ? ReportV8Dead(location) : false; | |
285 } | |
286 | |
287 | |
288 static inline bool IsExecutionTerminatingCheck(i::Isolate* isolate) { | 262 static inline bool IsExecutionTerminatingCheck(i::Isolate* isolate) { |
289 if (!isolate->IsInitialized()) return false; | 263 if (!isolate->IsInitialized()) return false; |
290 if (isolate->has_scheduled_exception()) { | 264 if (isolate->has_scheduled_exception()) { |
291 return isolate->scheduled_exception() == | 265 return isolate->scheduled_exception() == |
292 isolate->heap()->termination_exception(); | 266 isolate->heap()->termination_exception(); |
293 } | 267 } |
294 return false; | 268 return false; |
295 } | 269 } |
296 | 270 |
297 | 271 |
(...skipping 16 matching lines...) Expand all Loading... |
314 if (isolate == NULL || isolate->function_entry_hook() == NULL) { | 288 if (isolate == NULL || isolate->function_entry_hook() == NULL) { |
315 if (i::Snapshot::Initialize()) | 289 if (i::Snapshot::Initialize()) |
316 return true; | 290 return true; |
317 } | 291 } |
318 return i::V8::Initialize(NULL); | 292 return i::V8::Initialize(NULL); |
319 } | 293 } |
320 | 294 |
321 | 295 |
322 static inline bool EnsureInitializedForIsolate(i::Isolate* isolate, | 296 static inline bool EnsureInitializedForIsolate(i::Isolate* isolate, |
323 const char* location) { | 297 const char* location) { |
324 if (IsDeadCheck(isolate, location)) return false; | |
325 if (isolate != NULL) { | 298 if (isolate != NULL) { |
326 if (isolate->IsInitialized()) return true; | 299 if (isolate->IsInitialized()) return true; |
327 } | 300 } |
328 ASSERT(isolate == i::Isolate::Current()); | 301 ASSERT(isolate == i::Isolate::Current()); |
329 return ApiCheck(InitializeHelper(isolate), location, "Error initializing V8"); | 302 return ApiCheck(InitializeHelper(isolate), location, "Error initializing V8"); |
330 } | 303 } |
331 | 304 |
332 | 305 |
333 // Some initializing API functions are called early and may be | 306 // Some initializing API functions are called early and may be |
334 // called on a thread different from static initializer thread. | 307 // called on a thread different from static initializer thread. |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 } | 467 } |
495 | 468 |
496 | 469 |
497 void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) { | 470 void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) { |
498 i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags); | 471 i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags); |
499 } | 472 } |
500 | 473 |
501 | 474 |
502 v8::Handle<Value> ThrowException(v8::Handle<v8::Value> value) { | 475 v8::Handle<Value> ThrowException(v8::Handle<v8::Value> value) { |
503 i::Isolate* isolate = i::Isolate::Current(); | 476 i::Isolate* isolate = i::Isolate::Current(); |
504 if (IsDeadCheck(isolate, "v8::ThrowException()")) { | |
505 return v8::Handle<Value>(); | |
506 } | |
507 ENTER_V8(isolate); | 477 ENTER_V8(isolate); |
508 // If we're passed an empty handle, we throw an undefined exception | 478 // If we're passed an empty handle, we throw an undefined exception |
509 // to deal more gracefully with out of memory situations. | 479 // to deal more gracefully with out of memory situations. |
510 if (value.IsEmpty()) { | 480 if (value.IsEmpty()) { |
511 isolate->ScheduleThrow(isolate->heap()->undefined_value()); | 481 isolate->ScheduleThrow(isolate->heap()->undefined_value()); |
512 } else { | 482 } else { |
513 isolate->ScheduleThrow(*Utils::OpenHandle(*value)); | 483 isolate->ScheduleThrow(*Utils::OpenHandle(*value)); |
514 } | 484 } |
515 return v8::Undefined(); | 485 return v8::Undefined(); |
516 } | 486 } |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 if (constraints->is_memory_constrained().has_value && | 597 if (constraints->is_memory_constrained().has_value && |
628 !i::FLAG_force_memory_constrained.has_value) { | 598 !i::FLAG_force_memory_constrained.has_value) { |
629 isolate->set_is_memory_constrained( | 599 isolate->set_is_memory_constrained( |
630 constraints->is_memory_constrained().value); | 600 constraints->is_memory_constrained().value); |
631 } | 601 } |
632 return true; | 602 return true; |
633 } | 603 } |
634 | 604 |
635 | 605 |
636 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { | 606 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { |
637 if (IsDeadCheck(isolate, "V8::Persistent::New")) return NULL; | |
638 LOG_API(isolate, "Persistent::New"); | 607 LOG_API(isolate, "Persistent::New"); |
639 i::Handle<i::Object> result = isolate->global_handles()->Create(*obj); | 608 i::Handle<i::Object> result = isolate->global_handles()->Create(*obj); |
640 #ifdef DEBUG | 609 #ifdef DEBUG |
641 (*obj)->Verify(); | 610 (*obj)->Verify(); |
642 #endif // DEBUG | 611 #endif // DEBUG |
643 return result.location(); | 612 return result.location(); |
644 } | 613 } |
645 | 614 |
646 | 615 |
647 i::Object** V8::CopyPersistent(i::Object** obj) { | 616 i::Object** V8::CopyPersistent(i::Object** obj) { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 i::Handle<i::Context> env = Utils::OpenHandle(this); | 720 i::Handle<i::Context> env = Utils::OpenHandle(this); |
752 i::Isolate* isolate = env->GetIsolate(); | 721 i::Isolate* isolate = env->GetIsolate(); |
753 ENTER_V8(isolate); | 722 ENTER_V8(isolate); |
754 isolate->handle_scope_implementer()->EnterContext(env); | 723 isolate->handle_scope_implementer()->EnterContext(env); |
755 isolate->handle_scope_implementer()->SaveContext(isolate->context()); | 724 isolate->handle_scope_implementer()->SaveContext(isolate->context()); |
756 isolate->set_context(*env); | 725 isolate->set_context(*env); |
757 } | 726 } |
758 | 727 |
759 | 728 |
760 void Context::Exit() { | 729 void Context::Exit() { |
761 i::Handle<i::Context> context = Utils::OpenHandle(this); | 730 // TODO(dcarney): fix this once chrome is fixed. |
762 i::Isolate* isolate = context->GetIsolate(); | 731 i::Isolate* isolate = i::Isolate::Current(); |
| 732 i::Handle<i::Context> context = i::Handle<i::Context>::null(); |
763 ENTER_V8(isolate); | 733 ENTER_V8(isolate); |
764 if (!ApiCheck(isolate->handle_scope_implementer()->LeaveContext(context), | 734 if (!ApiCheck(isolate->handle_scope_implementer()->LeaveContext(context), |
765 "v8::Context::Exit()", | 735 "v8::Context::Exit()", |
766 "Cannot exit non-entered context")) { | 736 "Cannot exit non-entered context")) { |
767 return; | 737 return; |
768 } | 738 } |
769 // Content of 'last_context' could be NULL. | 739 // Content of 'last_context' could be NULL. |
770 i::Context* last_context = | 740 i::Context* last_context = |
771 isolate->handle_scope_implementer()->RestoreContext(); | 741 isolate->handle_scope_implementer()->RestoreContext(); |
772 isolate->set_context(last_context); | 742 isolate->set_context(last_context); |
(...skipping 11 matching lines...) Expand all Loading... |
784 ApiCheck(smi->IsSmi(), location, "Pointer is not aligned"); | 754 ApiCheck(smi->IsSmi(), location, "Pointer is not aligned"); |
785 return smi; | 755 return smi; |
786 } | 756 } |
787 | 757 |
788 | 758 |
789 static i::Handle<i::FixedArray> EmbedderDataFor(Context* context, | 759 static i::Handle<i::FixedArray> EmbedderDataFor(Context* context, |
790 int index, | 760 int index, |
791 bool can_grow, | 761 bool can_grow, |
792 const char* location) { | 762 const char* location) { |
793 i::Handle<i::Context> env = Utils::OpenHandle(context); | 763 i::Handle<i::Context> env = Utils::OpenHandle(context); |
794 bool ok = !IsDeadCheck(env->GetIsolate(), location) && | 764 bool ok = |
795 ApiCheck(env->IsNativeContext(), location, "Not a native context") && | 765 ApiCheck(env->IsNativeContext(), location, "Not a native context") && |
796 ApiCheck(index >= 0, location, "Negative index"); | 766 ApiCheck(index >= 0, location, "Negative index"); |
797 if (!ok) return i::Handle<i::FixedArray>(); | 767 if (!ok) return i::Handle<i::FixedArray>(); |
798 i::Handle<i::FixedArray> data(env->embedder_data()); | 768 i::Handle<i::FixedArray> data(env->embedder_data()); |
799 if (index < data->length()) return data; | 769 if (index < data->length()) return data; |
800 if (!can_grow) { | 770 if (!can_grow) { |
801 Utils::ReportApiFailure(location, "Index too large"); | 771 Utils::ReportApiFailure(location, "Index too large"); |
802 return i::Handle<i::FixedArray>(); | 772 return i::Handle<i::FixedArray>(); |
803 } | 773 } |
804 int new_size = i::Max(index, data->length() << 1) + 1; | 774 int new_size = i::Max(index, data->length() << 1) + 1; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 Utils::OpenHandle(*data[i]); | 931 Utils::OpenHandle(*data[i]); |
962 array.add(value); | 932 array.add(value); |
963 } | 933 } |
964 } | 934 } |
965 | 935 |
966 | 936 |
967 void Template::Set(v8::Handle<String> name, | 937 void Template::Set(v8::Handle<String> name, |
968 v8::Handle<Data> value, | 938 v8::Handle<Data> value, |
969 v8::PropertyAttribute attribute) { | 939 v8::PropertyAttribute attribute) { |
970 i::Isolate* isolate = i::Isolate::Current(); | 940 i::Isolate* isolate = i::Isolate::Current(); |
971 if (IsDeadCheck(isolate, "v8::Template::Set()")) return; | |
972 ENTER_V8(isolate); | 941 ENTER_V8(isolate); |
973 i::HandleScope scope(isolate); | 942 i::HandleScope scope(isolate); |
974 const int kSize = 3; | 943 const int kSize = 3; |
975 v8::Handle<v8::Data> data[kSize] = { | 944 v8::Handle<v8::Data> data[kSize] = { |
976 name, | 945 name, |
977 value, | 946 value, |
978 v8::Integer::New(attribute)}; | 947 v8::Integer::New(attribute)}; |
979 TemplateSet(isolate, this, kSize, data); | 948 TemplateSet(isolate, this, kSize, data); |
980 } | 949 } |
981 | 950 |
982 | 951 |
983 void Template::SetAccessorProperty( | 952 void Template::SetAccessorProperty( |
984 v8::Local<v8::String> name, | 953 v8::Local<v8::String> name, |
985 v8::Local<FunctionTemplate> getter, | 954 v8::Local<FunctionTemplate> getter, |
986 v8::Local<FunctionTemplate> setter, | 955 v8::Local<FunctionTemplate> setter, |
987 v8::PropertyAttribute attribute, | 956 v8::PropertyAttribute attribute, |
988 v8::AccessControl access_control) { | 957 v8::AccessControl access_control) { |
989 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 958 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
990 if (IsDeadCheck(isolate, "v8::Template::SetAccessor()")) return; | |
991 ENTER_V8(isolate); | 959 ENTER_V8(isolate); |
992 ASSERT(!name.IsEmpty()); | 960 ASSERT(!name.IsEmpty()); |
993 ASSERT(!getter.IsEmpty() || !setter.IsEmpty()); | 961 ASSERT(!getter.IsEmpty() || !setter.IsEmpty()); |
994 i::HandleScope scope(isolate); | 962 i::HandleScope scope(isolate); |
995 const int kSize = 5; | 963 const int kSize = 5; |
996 v8::Handle<v8::Data> data[kSize] = { | 964 v8::Handle<v8::Data> data[kSize] = { |
997 name, | 965 name, |
998 getter, | 966 getter, |
999 setter, | 967 setter, |
1000 v8::Integer::New(attribute), | 968 v8::Integer::New(attribute), |
1001 v8::Integer::New(access_control)}; | 969 v8::Integer::New(access_control)}; |
1002 TemplateSet(isolate, this, kSize, data); | 970 TemplateSet(isolate, this, kSize, data); |
1003 } | 971 } |
1004 | 972 |
1005 | 973 |
1006 // --- F u n c t i o n T e m p l a t e --- | 974 // --- F u n c t i o n T e m p l a t e --- |
1007 static void InitializeFunctionTemplate( | 975 static void InitializeFunctionTemplate( |
1008 i::Handle<i::FunctionTemplateInfo> info) { | 976 i::Handle<i::FunctionTemplateInfo> info) { |
1009 info->set_tag(i::Smi::FromInt(Consts::FUNCTION_TEMPLATE)); | 977 info->set_tag(i::Smi::FromInt(Consts::FUNCTION_TEMPLATE)); |
1010 info->set_flag(0); | 978 info->set_flag(0); |
1011 } | 979 } |
1012 | 980 |
1013 | 981 |
1014 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() { | 982 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() { |
1015 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 983 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1016 if (IsDeadCheck(isolate, "v8::FunctionTemplate::PrototypeTemplate()")) { | |
1017 return Local<ObjectTemplate>(); | |
1018 } | |
1019 ENTER_V8(isolate); | 984 ENTER_V8(isolate); |
1020 i::Handle<i::Object> result(Utils::OpenHandle(this)->prototype_template(), | 985 i::Handle<i::Object> result(Utils::OpenHandle(this)->prototype_template(), |
1021 isolate); | 986 isolate); |
1022 if (result->IsUndefined()) { | 987 if (result->IsUndefined()) { |
1023 result = Utils::OpenHandle(*ObjectTemplate::New()); | 988 result = Utils::OpenHandle(*ObjectTemplate::New()); |
1024 Utils::OpenHandle(this)->set_prototype_template(*result); | 989 Utils::OpenHandle(this)->set_prototype_template(*result); |
1025 } | 990 } |
1026 return ToApiHandle<ObjectTemplate>(result); | 991 return ToApiHandle<ObjectTemplate>(result); |
1027 } | 992 } |
1028 | 993 |
1029 | 994 |
1030 void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) { | 995 void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) { |
1031 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 996 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1032 if (IsDeadCheck(isolate, "v8::FunctionTemplate::Inherit()")) return; | |
1033 ENTER_V8(isolate); | 997 ENTER_V8(isolate); |
1034 Utils::OpenHandle(this)->set_parent_template(*Utils::OpenHandle(*value)); | 998 Utils::OpenHandle(this)->set_parent_template(*Utils::OpenHandle(*value)); |
1035 } | 999 } |
1036 | 1000 |
1037 | 1001 |
1038 static Local<FunctionTemplate> FunctionTemplateNew( | 1002 static Local<FunctionTemplate> FunctionTemplateNew( |
1039 i::Isolate* isolate, | 1003 i::Isolate* isolate, |
1040 FunctionCallback callback, | 1004 FunctionCallback callback, |
1041 v8::Handle<Value> data, | 1005 v8::Handle<Value> data, |
1042 v8::Handle<Signature> signature, | 1006 v8::Handle<Signature> signature, |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1265 | 1229 |
1266 #define SET_FIELD_WRAPPED(obj, setter, cdata) do { \ | 1230 #define SET_FIELD_WRAPPED(obj, setter, cdata) do { \ |
1267 i::Handle<i::Object> foreign = FromCData(obj->GetIsolate(), cdata); \ | 1231 i::Handle<i::Object> foreign = FromCData(obj->GetIsolate(), cdata); \ |
1268 (obj)->setter(*foreign); \ | 1232 (obj)->setter(*foreign); \ |
1269 } while (false) | 1233 } while (false) |
1270 | 1234 |
1271 | 1235 |
1272 void FunctionTemplate::SetCallHandler(FunctionCallback callback, | 1236 void FunctionTemplate::SetCallHandler(FunctionCallback callback, |
1273 v8::Handle<Value> data) { | 1237 v8::Handle<Value> data) { |
1274 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1238 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1275 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetCallHandler()")) return; | |
1276 ENTER_V8(isolate); | 1239 ENTER_V8(isolate); |
1277 i::HandleScope scope(isolate); | 1240 i::HandleScope scope(isolate); |
1278 i::Handle<i::Struct> struct_obj = | 1241 i::Handle<i::Struct> struct_obj = |
1279 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); | 1242 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); |
1280 i::Handle<i::CallHandlerInfo> obj = | 1243 i::Handle<i::CallHandlerInfo> obj = |
1281 i::Handle<i::CallHandlerInfo>::cast(struct_obj); | 1244 i::Handle<i::CallHandlerInfo>::cast(struct_obj); |
1282 SET_FIELD_WRAPPED(obj, set_callback, callback); | 1245 SET_FIELD_WRAPPED(obj, set_callback, callback); |
1283 if (data.IsEmpty()) data = v8::Undefined(); | 1246 if (data.IsEmpty()) data = v8::Undefined(); |
1284 obj->set_data(*Utils::OpenHandle(*data)); | 1247 obj->set_data(*Utils::OpenHandle(*data)); |
1285 Utils::OpenHandle(this)->set_call_code(*obj); | 1248 Utils::OpenHandle(this)->set_call_code(*obj); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1336 if (descriptor.IsEmpty()) return i::Handle<i::DeclaredAccessorInfo>(); | 1299 if (descriptor.IsEmpty()) return i::Handle<i::DeclaredAccessorInfo>(); |
1337 i::Handle<i::DeclaredAccessorInfo> obj = | 1300 i::Handle<i::DeclaredAccessorInfo> obj = |
1338 isolate->factory()->NewDeclaredAccessorInfo(); | 1301 isolate->factory()->NewDeclaredAccessorInfo(); |
1339 obj->set_descriptor(*Utils::OpenHandle(*descriptor)); | 1302 obj->set_descriptor(*Utils::OpenHandle(*descriptor)); |
1340 return SetAccessorInfoProperties(obj, name, settings, attributes, signature); | 1303 return SetAccessorInfoProperties(obj, name, settings, attributes, signature); |
1341 } | 1304 } |
1342 | 1305 |
1343 | 1306 |
1344 Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() { | 1307 Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() { |
1345 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1308 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1346 if (IsDeadCheck(isolate, "v8::FunctionTemplate::InstanceTemplate()") | 1309 if (EmptyCheck("v8::FunctionTemplate::InstanceTemplate()", this)) |
1347 || EmptyCheck("v8::FunctionTemplate::InstanceTemplate()", this)) | |
1348 return Local<ObjectTemplate>(); | 1310 return Local<ObjectTemplate>(); |
1349 ENTER_V8(isolate); | 1311 ENTER_V8(isolate); |
1350 i::Handle<i::FunctionTemplateInfo> handle = Utils::OpenHandle(this); | 1312 i::Handle<i::FunctionTemplateInfo> handle = Utils::OpenHandle(this); |
1351 if (handle->instance_template()->IsUndefined()) { | 1313 if (handle->instance_template()->IsUndefined()) { |
1352 Local<ObjectTemplate> templ = | 1314 Local<ObjectTemplate> templ = |
1353 ObjectTemplate::New(ToApiHandle<FunctionTemplate>(handle)); | 1315 ObjectTemplate::New(ToApiHandle<FunctionTemplate>(handle)); |
1354 handle->set_instance_template(*Utils::OpenHandle(*templ)); | 1316 handle->set_instance_template(*Utils::OpenHandle(*templ)); |
1355 } | 1317 } |
1356 i::Handle<i::ObjectTemplateInfo> result( | 1318 i::Handle<i::ObjectTemplateInfo> result( |
1357 i::ObjectTemplateInfo::cast(handle->instance_template())); | 1319 i::ObjectTemplateInfo::cast(handle->instance_template())); |
1358 return Utils::ToLocal(result); | 1320 return Utils::ToLocal(result); |
1359 } | 1321 } |
1360 | 1322 |
1361 | 1323 |
1362 void FunctionTemplate::SetLength(int length) { | 1324 void FunctionTemplate::SetLength(int length) { |
1363 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1325 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1364 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetLength()")) return; | |
1365 ENTER_V8(isolate); | 1326 ENTER_V8(isolate); |
1366 Utils::OpenHandle(this)->set_length(length); | 1327 Utils::OpenHandle(this)->set_length(length); |
1367 } | 1328 } |
1368 | 1329 |
1369 | 1330 |
1370 void FunctionTemplate::SetClassName(Handle<String> name) { | 1331 void FunctionTemplate::SetClassName(Handle<String> name) { |
1371 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1332 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1372 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetClassName()")) return; | |
1373 ENTER_V8(isolate); | 1333 ENTER_V8(isolate); |
1374 Utils::OpenHandle(this)->set_class_name(*Utils::OpenHandle(*name)); | 1334 Utils::OpenHandle(this)->set_class_name(*Utils::OpenHandle(*name)); |
1375 } | 1335 } |
1376 | 1336 |
1377 | 1337 |
1378 void FunctionTemplate::SetHiddenPrototype(bool value) { | 1338 void FunctionTemplate::SetHiddenPrototype(bool value) { |
1379 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1339 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1380 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetHiddenPrototype()")) { | |
1381 return; | |
1382 } | |
1383 ENTER_V8(isolate); | 1340 ENTER_V8(isolate); |
1384 Utils::OpenHandle(this)->set_hidden_prototype(value); | 1341 Utils::OpenHandle(this)->set_hidden_prototype(value); |
1385 } | 1342 } |
1386 | 1343 |
1387 | 1344 |
1388 void FunctionTemplate::ReadOnlyPrototype() { | 1345 void FunctionTemplate::ReadOnlyPrototype() { |
1389 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1346 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1390 if (IsDeadCheck(isolate, "v8::FunctionTemplate::ReadOnlyPrototype()")) { | |
1391 return; | |
1392 } | |
1393 ENTER_V8(isolate); | 1347 ENTER_V8(isolate); |
1394 Utils::OpenHandle(this)->set_read_only_prototype(true); | 1348 Utils::OpenHandle(this)->set_read_only_prototype(true); |
1395 } | 1349 } |
1396 | 1350 |
1397 | 1351 |
1398 void FunctionTemplate::RemovePrototype() { | 1352 void FunctionTemplate::RemovePrototype() { |
1399 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1353 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1400 if (IsDeadCheck(isolate, "v8::FunctionTemplate::RemovePrototype()")) { | |
1401 return; | |
1402 } | |
1403 ENTER_V8(isolate); | 1354 ENTER_V8(isolate); |
1404 Utils::OpenHandle(this)->set_remove_prototype(true); | 1355 Utils::OpenHandle(this)->set_remove_prototype(true); |
1405 } | 1356 } |
1406 | 1357 |
1407 | 1358 |
1408 // --- O b j e c t T e m p l a t e --- | 1359 // --- O b j e c t T e m p l a t e --- |
1409 | 1360 |
1410 | 1361 |
1411 Local<ObjectTemplate> ObjectTemplate::New() { | 1362 Local<ObjectTemplate> ObjectTemplate::New() { |
1412 return New(Local<FunctionTemplate>()); | 1363 return New(Local<FunctionTemplate>()); |
1413 } | 1364 } |
1414 | 1365 |
1415 | 1366 |
1416 Local<ObjectTemplate> ObjectTemplate::New( | 1367 Local<ObjectTemplate> ObjectTemplate::New( |
1417 v8::Handle<FunctionTemplate> constructor) { | 1368 v8::Handle<FunctionTemplate> constructor) { |
1418 i::Isolate* isolate = i::Isolate::Current(); | 1369 i::Isolate* isolate = i::Isolate::Current(); |
1419 if (IsDeadCheck(isolate, "v8::ObjectTemplate::New()")) { | |
1420 return Local<ObjectTemplate>(); | |
1421 } | |
1422 EnsureInitializedForIsolate(isolate, "v8::ObjectTemplate::New()"); | 1370 EnsureInitializedForIsolate(isolate, "v8::ObjectTemplate::New()"); |
1423 LOG_API(isolate, "ObjectTemplate::New"); | 1371 LOG_API(isolate, "ObjectTemplate::New"); |
1424 ENTER_V8(isolate); | 1372 ENTER_V8(isolate); |
1425 i::Handle<i::Struct> struct_obj = | 1373 i::Handle<i::Struct> struct_obj = |
1426 isolate->factory()->NewStruct(i::OBJECT_TEMPLATE_INFO_TYPE); | 1374 isolate->factory()->NewStruct(i::OBJECT_TEMPLATE_INFO_TYPE); |
1427 i::Handle<i::ObjectTemplateInfo> obj = | 1375 i::Handle<i::ObjectTemplateInfo> obj = |
1428 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj); | 1376 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj); |
1429 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE); | 1377 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE); |
1430 if (!constructor.IsEmpty()) | 1378 if (!constructor.IsEmpty()) |
1431 obj->set_constructor(*Utils::OpenHandle(*constructor)); | 1379 obj->set_constructor(*Utils::OpenHandle(*constructor)); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1482 static bool TemplateSetAccessor( | 1430 static bool TemplateSetAccessor( |
1483 Template* template_obj, | 1431 Template* template_obj, |
1484 v8::Local<String> name, | 1432 v8::Local<String> name, |
1485 Getter getter, | 1433 Getter getter, |
1486 Setter setter, | 1434 Setter setter, |
1487 Data data, | 1435 Data data, |
1488 AccessControl settings, | 1436 AccessControl settings, |
1489 PropertyAttribute attribute, | 1437 PropertyAttribute attribute, |
1490 v8::Local<AccessorSignature> signature) { | 1438 v8::Local<AccessorSignature> signature) { |
1491 i::Isolate* isolate = Utils::OpenHandle(template_obj)->GetIsolate(); | 1439 i::Isolate* isolate = Utils::OpenHandle(template_obj)->GetIsolate(); |
1492 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetAccessor()")) return false; | |
1493 ENTER_V8(isolate); | 1440 ENTER_V8(isolate); |
1494 i::HandleScope scope(isolate); | 1441 i::HandleScope scope(isolate); |
1495 i::Handle<i::AccessorInfo> obj = MakeAccessorInfo( | 1442 i::Handle<i::AccessorInfo> obj = MakeAccessorInfo( |
1496 name, getter, setter, data, settings, attribute, signature); | 1443 name, getter, setter, data, settings, attribute, signature); |
1497 if (obj.is_null()) return false; | 1444 if (obj.is_null()) return false; |
1498 i::Handle<i::TemplateInfo> info = GetTemplateInfo(template_obj); | 1445 i::Handle<i::TemplateInfo> info = GetTemplateInfo(template_obj); |
1499 AddPropertyToTemplate(info, obj); | 1446 AddPropertyToTemplate(info, obj); |
1500 return true; | 1447 return true; |
1501 } | 1448 } |
1502 | 1449 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1538 | 1485 |
1539 | 1486 |
1540 void ObjectTemplate::SetNamedPropertyHandler( | 1487 void ObjectTemplate::SetNamedPropertyHandler( |
1541 NamedPropertyGetterCallback getter, | 1488 NamedPropertyGetterCallback getter, |
1542 NamedPropertySetterCallback setter, | 1489 NamedPropertySetterCallback setter, |
1543 NamedPropertyQueryCallback query, | 1490 NamedPropertyQueryCallback query, |
1544 NamedPropertyDeleterCallback remover, | 1491 NamedPropertyDeleterCallback remover, |
1545 NamedPropertyEnumeratorCallback enumerator, | 1492 NamedPropertyEnumeratorCallback enumerator, |
1546 Handle<Value> data) { | 1493 Handle<Value> data) { |
1547 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1494 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1548 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetNamedPropertyHandler()")) { | |
1549 return; | |
1550 } | |
1551 ENTER_V8(isolate); | 1495 ENTER_V8(isolate); |
1552 i::HandleScope scope(isolate); | 1496 i::HandleScope scope(isolate); |
1553 EnsureConstructor(this); | 1497 EnsureConstructor(this); |
1554 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( | 1498 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( |
1555 Utils::OpenHandle(this)->constructor()); | 1499 Utils::OpenHandle(this)->constructor()); |
1556 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 1500 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
1557 i::Handle<i::Struct> struct_obj = | 1501 i::Handle<i::Struct> struct_obj = |
1558 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); | 1502 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); |
1559 i::Handle<i::InterceptorInfo> obj = | 1503 i::Handle<i::InterceptorInfo> obj = |
1560 i::Handle<i::InterceptorInfo>::cast(struct_obj); | 1504 i::Handle<i::InterceptorInfo>::cast(struct_obj); |
1561 | 1505 |
1562 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); | 1506 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); |
1563 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); | 1507 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); |
1564 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); | 1508 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); |
1565 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); | 1509 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); |
1566 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); | 1510 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); |
1567 | 1511 |
1568 if (data.IsEmpty()) data = v8::Undefined(); | 1512 if (data.IsEmpty()) data = v8::Undefined(); |
1569 obj->set_data(*Utils::OpenHandle(*data)); | 1513 obj->set_data(*Utils::OpenHandle(*data)); |
1570 cons->set_named_property_handler(*obj); | 1514 cons->set_named_property_handler(*obj); |
1571 } | 1515 } |
1572 | 1516 |
1573 | 1517 |
1574 void ObjectTemplate::MarkAsUndetectable() { | 1518 void ObjectTemplate::MarkAsUndetectable() { |
1575 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1519 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1576 if (IsDeadCheck(isolate, "v8::ObjectTemplate::MarkAsUndetectable()")) return; | |
1577 ENTER_V8(isolate); | 1520 ENTER_V8(isolate); |
1578 i::HandleScope scope(isolate); | 1521 i::HandleScope scope(isolate); |
1579 EnsureConstructor(this); | 1522 EnsureConstructor(this); |
1580 i::FunctionTemplateInfo* constructor = | 1523 i::FunctionTemplateInfo* constructor = |
1581 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); | 1524 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); |
1582 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 1525 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
1583 cons->set_undetectable(true); | 1526 cons->set_undetectable(true); |
1584 } | 1527 } |
1585 | 1528 |
1586 | 1529 |
1587 void ObjectTemplate::SetAccessCheckCallbacks( | 1530 void ObjectTemplate::SetAccessCheckCallbacks( |
1588 NamedSecurityCallback named_callback, | 1531 NamedSecurityCallback named_callback, |
1589 IndexedSecurityCallback indexed_callback, | 1532 IndexedSecurityCallback indexed_callback, |
1590 Handle<Value> data, | 1533 Handle<Value> data, |
1591 bool turned_on_by_default) { | 1534 bool turned_on_by_default) { |
1592 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1535 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1593 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetAccessCheckCallbacks()")) { | |
1594 return; | |
1595 } | |
1596 ENTER_V8(isolate); | 1536 ENTER_V8(isolate); |
1597 i::HandleScope scope(isolate); | 1537 i::HandleScope scope(isolate); |
1598 EnsureConstructor(this); | 1538 EnsureConstructor(this); |
1599 | 1539 |
1600 i::Handle<i::Struct> struct_info = | 1540 i::Handle<i::Struct> struct_info = |
1601 isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE); | 1541 isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE); |
1602 i::Handle<i::AccessCheckInfo> info = | 1542 i::Handle<i::AccessCheckInfo> info = |
1603 i::Handle<i::AccessCheckInfo>::cast(struct_info); | 1543 i::Handle<i::AccessCheckInfo>::cast(struct_info); |
1604 | 1544 |
1605 SET_FIELD_WRAPPED(info, set_named_callback, named_callback); | 1545 SET_FIELD_WRAPPED(info, set_named_callback, named_callback); |
(...skipping 11 matching lines...) Expand all Loading... |
1617 | 1557 |
1618 | 1558 |
1619 void ObjectTemplate::SetIndexedPropertyHandler( | 1559 void ObjectTemplate::SetIndexedPropertyHandler( |
1620 IndexedPropertyGetterCallback getter, | 1560 IndexedPropertyGetterCallback getter, |
1621 IndexedPropertySetterCallback setter, | 1561 IndexedPropertySetterCallback setter, |
1622 IndexedPropertyQueryCallback query, | 1562 IndexedPropertyQueryCallback query, |
1623 IndexedPropertyDeleterCallback remover, | 1563 IndexedPropertyDeleterCallback remover, |
1624 IndexedPropertyEnumeratorCallback enumerator, | 1564 IndexedPropertyEnumeratorCallback enumerator, |
1625 Handle<Value> data) { | 1565 Handle<Value> data) { |
1626 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1566 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1627 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetIndexedPropertyHandler()")) { | |
1628 return; | |
1629 } | |
1630 ENTER_V8(isolate); | 1567 ENTER_V8(isolate); |
1631 i::HandleScope scope(isolate); | 1568 i::HandleScope scope(isolate); |
1632 EnsureConstructor(this); | 1569 EnsureConstructor(this); |
1633 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( | 1570 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( |
1634 Utils::OpenHandle(this)->constructor()); | 1571 Utils::OpenHandle(this)->constructor()); |
1635 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 1572 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
1636 i::Handle<i::Struct> struct_obj = | 1573 i::Handle<i::Struct> struct_obj = |
1637 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); | 1574 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); |
1638 i::Handle<i::InterceptorInfo> obj = | 1575 i::Handle<i::InterceptorInfo> obj = |
1639 i::Handle<i::InterceptorInfo>::cast(struct_obj); | 1576 i::Handle<i::InterceptorInfo>::cast(struct_obj); |
1640 | 1577 |
1641 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); | 1578 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); |
1642 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); | 1579 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); |
1643 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); | 1580 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); |
1644 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); | 1581 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); |
1645 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); | 1582 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); |
1646 | 1583 |
1647 if (data.IsEmpty()) data = v8::Undefined(); | 1584 if (data.IsEmpty()) data = v8::Undefined(); |
1648 obj->set_data(*Utils::OpenHandle(*data)); | 1585 obj->set_data(*Utils::OpenHandle(*data)); |
1649 cons->set_indexed_property_handler(*obj); | 1586 cons->set_indexed_property_handler(*obj); |
1650 } | 1587 } |
1651 | 1588 |
1652 | 1589 |
1653 void ObjectTemplate::SetCallAsFunctionHandler(FunctionCallback callback, | 1590 void ObjectTemplate::SetCallAsFunctionHandler(FunctionCallback callback, |
1654 Handle<Value> data) { | 1591 Handle<Value> data) { |
1655 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1592 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1656 if (IsDeadCheck(isolate, | |
1657 "v8::ObjectTemplate::SetCallAsFunctionHandler()")) { | |
1658 return; | |
1659 } | |
1660 ENTER_V8(isolate); | 1593 ENTER_V8(isolate); |
1661 i::HandleScope scope(isolate); | 1594 i::HandleScope scope(isolate); |
1662 EnsureConstructor(this); | 1595 EnsureConstructor(this); |
1663 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( | 1596 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( |
1664 Utils::OpenHandle(this)->constructor()); | 1597 Utils::OpenHandle(this)->constructor()); |
1665 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 1598 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
1666 i::Handle<i::Struct> struct_obj = | 1599 i::Handle<i::Struct> struct_obj = |
1667 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); | 1600 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); |
1668 i::Handle<i::CallHandlerInfo> obj = | 1601 i::Handle<i::CallHandlerInfo> obj = |
1669 i::Handle<i::CallHandlerInfo>::cast(struct_obj); | 1602 i::Handle<i::CallHandlerInfo>::cast(struct_obj); |
1670 SET_FIELD_WRAPPED(obj, set_callback, callback); | 1603 SET_FIELD_WRAPPED(obj, set_callback, callback); |
1671 if (data.IsEmpty()) data = v8::Undefined(); | 1604 if (data.IsEmpty()) data = v8::Undefined(); |
1672 obj->set_data(*Utils::OpenHandle(*data)); | 1605 obj->set_data(*Utils::OpenHandle(*data)); |
1673 cons->set_instance_call_handler(*obj); | 1606 cons->set_instance_call_handler(*obj); |
1674 } | 1607 } |
1675 | 1608 |
1676 | 1609 |
1677 int ObjectTemplate::InternalFieldCount() { | 1610 int ObjectTemplate::InternalFieldCount() { |
1678 if (IsDeadCheck(Utils::OpenHandle(this)->GetIsolate(), | |
1679 "v8::ObjectTemplate::InternalFieldCount()")) { | |
1680 return 0; | |
1681 } | |
1682 return i::Smi::cast(Utils::OpenHandle(this)->internal_field_count())->value(); | 1611 return i::Smi::cast(Utils::OpenHandle(this)->internal_field_count())->value(); |
1683 } | 1612 } |
1684 | 1613 |
1685 | 1614 |
1686 void ObjectTemplate::SetInternalFieldCount(int value) { | 1615 void ObjectTemplate::SetInternalFieldCount(int value) { |
1687 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1616 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1688 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetInternalFieldCount()")) { | |
1689 return; | |
1690 } | |
1691 if (!ApiCheck(i::Smi::IsValid(value), | 1617 if (!ApiCheck(i::Smi::IsValid(value), |
1692 "v8::ObjectTemplate::SetInternalFieldCount()", | 1618 "v8::ObjectTemplate::SetInternalFieldCount()", |
1693 "Invalid internal field count")) { | 1619 "Invalid internal field count")) { |
1694 return; | 1620 return; |
1695 } | 1621 } |
1696 ENTER_V8(isolate); | 1622 ENTER_V8(isolate); |
1697 if (value > 0) { | 1623 if (value > 0) { |
1698 // The internal field count is set by the constructor function's | 1624 // The internal field count is set by the constructor function's |
1699 // construct code, so we ensure that there is a constructor | 1625 // construct code, so we ensure that there is a constructor |
1700 // function to do the setting. | 1626 // function to do the setting. |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2103 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 2029 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
2104 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2030 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2105 i::Handle<i::String> raw_result = i::MessageHandler::GetMessage(isolate, obj); | 2031 i::Handle<i::String> raw_result = i::MessageHandler::GetMessage(isolate, obj); |
2106 Local<String> result = Utils::ToLocal(raw_result); | 2032 Local<String> result = Utils::ToLocal(raw_result); |
2107 return scope.Close(result); | 2033 return scope.Close(result); |
2108 } | 2034 } |
2109 | 2035 |
2110 | 2036 |
2111 v8::Handle<Value> Message::GetScriptResourceName() const { | 2037 v8::Handle<Value> Message::GetScriptResourceName() const { |
2112 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2038 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2113 if (IsDeadCheck(isolate, "v8::Message::GetScriptResourceName()")) { | |
2114 return Local<String>(); | |
2115 } | |
2116 ENTER_V8(isolate); | 2039 ENTER_V8(isolate); |
2117 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 2040 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
2118 i::Handle<i::JSMessageObject> message = | 2041 i::Handle<i::JSMessageObject> message = |
2119 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); | 2042 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); |
2120 // Return this.script.name. | 2043 // Return this.script.name. |
2121 i::Handle<i::JSValue> script = | 2044 i::Handle<i::JSValue> script = |
2122 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(), | 2045 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(), |
2123 isolate)); | 2046 isolate)); |
2124 i::Handle<i::Object> resource_name(i::Script::cast(script->value())->name(), | 2047 i::Handle<i::Object> resource_name(i::Script::cast(script->value())->name(), |
2125 isolate); | 2048 isolate); |
2126 return scope.Close(Utils::ToLocal(resource_name)); | 2049 return scope.Close(Utils::ToLocal(resource_name)); |
2127 } | 2050 } |
2128 | 2051 |
2129 | 2052 |
2130 v8::Handle<Value> Message::GetScriptData() const { | 2053 v8::Handle<Value> Message::GetScriptData() const { |
2131 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2054 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2132 if (IsDeadCheck(isolate, "v8::Message::GetScriptResourceData()")) { | |
2133 return Local<Value>(); | |
2134 } | |
2135 ENTER_V8(isolate); | 2055 ENTER_V8(isolate); |
2136 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 2056 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
2137 i::Handle<i::JSMessageObject> message = | 2057 i::Handle<i::JSMessageObject> message = |
2138 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); | 2058 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); |
2139 // Return this.script.data. | 2059 // Return this.script.data. |
2140 i::Handle<i::JSValue> script = | 2060 i::Handle<i::JSValue> script = |
2141 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(), | 2061 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(), |
2142 isolate)); | 2062 isolate)); |
2143 i::Handle<i::Object> data(i::Script::cast(script->value())->data(), isolate); | 2063 i::Handle<i::Object> data(i::Script::cast(script->value())->data(), isolate); |
2144 return scope.Close(Utils::ToLocal(data)); | 2064 return scope.Close(Utils::ToLocal(data)); |
2145 } | 2065 } |
2146 | 2066 |
2147 | 2067 |
2148 v8::Handle<v8::StackTrace> Message::GetStackTrace() const { | 2068 v8::Handle<v8::StackTrace> Message::GetStackTrace() const { |
2149 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2069 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2150 if (IsDeadCheck(isolate, "v8::Message::GetStackTrace()")) { | |
2151 return Local<v8::StackTrace>(); | |
2152 } | |
2153 ENTER_V8(isolate); | 2070 ENTER_V8(isolate); |
2154 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 2071 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
2155 i::Handle<i::JSMessageObject> message = | 2072 i::Handle<i::JSMessageObject> message = |
2156 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); | 2073 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); |
2157 i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate); | 2074 i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate); |
2158 if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>(); | 2075 if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>(); |
2159 i::Handle<i::JSArray> stackTrace = | 2076 i::Handle<i::JSArray> stackTrace = |
2160 i::Handle<i::JSArray>::cast(stackFramesObj); | 2077 i::Handle<i::JSArray>::cast(stackFramesObj); |
2161 return scope.Close(Utils::StackTraceToLocal(stackTrace)); | 2078 return scope.Close(Utils::StackTraceToLocal(stackTrace)); |
2162 } | 2079 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2202 i::Handle<i::Object> result = CallV8HeapFunction("GetLineNumber", | 2119 i::Handle<i::Object> result = CallV8HeapFunction("GetLineNumber", |
2203 Utils::OpenHandle(this), | 2120 Utils::OpenHandle(this), |
2204 &has_pending_exception); | 2121 &has_pending_exception); |
2205 EXCEPTION_BAILOUT_CHECK(isolate, 0); | 2122 EXCEPTION_BAILOUT_CHECK(isolate, 0); |
2206 return static_cast<int>(result->Number()); | 2123 return static_cast<int>(result->Number()); |
2207 } | 2124 } |
2208 | 2125 |
2209 | 2126 |
2210 int Message::GetStartPosition() const { | 2127 int Message::GetStartPosition() const { |
2211 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2128 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2212 if (IsDeadCheck(isolate, "v8::Message::GetStartPosition()")) return 0; | |
2213 ENTER_V8(isolate); | 2129 ENTER_V8(isolate); |
2214 i::HandleScope scope(isolate); | 2130 i::HandleScope scope(isolate); |
2215 i::Handle<i::JSMessageObject> message = | 2131 i::Handle<i::JSMessageObject> message = |
2216 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); | 2132 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); |
2217 return message->start_position(); | 2133 return message->start_position(); |
2218 } | 2134 } |
2219 | 2135 |
2220 | 2136 |
2221 int Message::GetEndPosition() const { | 2137 int Message::GetEndPosition() const { |
2222 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2138 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2223 if (IsDeadCheck(isolate, "v8::Message::GetEndPosition()")) return 0; | |
2224 ENTER_V8(isolate); | 2139 ENTER_V8(isolate); |
2225 i::HandleScope scope(isolate); | 2140 i::HandleScope scope(isolate); |
2226 i::Handle<i::JSMessageObject> message = | 2141 i::Handle<i::JSMessageObject> message = |
2227 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); | 2142 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); |
2228 return message->end_position(); | 2143 return message->end_position(); |
2229 } | 2144 } |
2230 | 2145 |
2231 | 2146 |
2232 int Message::GetStartColumn() const { | 2147 int Message::GetStartColumn() const { |
2233 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2148 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2234 if (IsDeadCheck(isolate, "v8::Message::GetStartColumn()")) { | |
2235 return kNoColumnInfo; | |
2236 } | |
2237 ENTER_V8(isolate); | 2149 ENTER_V8(isolate); |
2238 i::HandleScope scope(isolate); | 2150 i::HandleScope scope(isolate); |
2239 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); | 2151 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); |
2240 EXCEPTION_PREAMBLE(isolate); | 2152 EXCEPTION_PREAMBLE(isolate); |
2241 i::Handle<i::Object> start_col_obj = CallV8HeapFunction( | 2153 i::Handle<i::Object> start_col_obj = CallV8HeapFunction( |
2242 "GetPositionInLine", | 2154 "GetPositionInLine", |
2243 data_obj, | 2155 data_obj, |
2244 &has_pending_exception); | 2156 &has_pending_exception); |
2245 EXCEPTION_BAILOUT_CHECK(isolate, 0); | 2157 EXCEPTION_BAILOUT_CHECK(isolate, 0); |
2246 return static_cast<int>(start_col_obj->Number()); | 2158 return static_cast<int>(start_col_obj->Number()); |
2247 } | 2159 } |
2248 | 2160 |
2249 | 2161 |
2250 int Message::GetEndColumn() const { | 2162 int Message::GetEndColumn() const { |
2251 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2163 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2252 if (IsDeadCheck(isolate, "v8::Message::GetEndColumn()")) return kNoColumnInfo; | |
2253 ENTER_V8(isolate); | 2164 ENTER_V8(isolate); |
2254 i::HandleScope scope(isolate); | 2165 i::HandleScope scope(isolate); |
2255 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); | 2166 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); |
2256 EXCEPTION_PREAMBLE(isolate); | 2167 EXCEPTION_PREAMBLE(isolate); |
2257 i::Handle<i::Object> start_col_obj = CallV8HeapFunction( | 2168 i::Handle<i::Object> start_col_obj = CallV8HeapFunction( |
2258 "GetPositionInLine", | 2169 "GetPositionInLine", |
2259 data_obj, | 2170 data_obj, |
2260 &has_pending_exception); | 2171 &has_pending_exception); |
2261 EXCEPTION_BAILOUT_CHECK(isolate, 0); | 2172 EXCEPTION_BAILOUT_CHECK(isolate, 0); |
2262 i::Handle<i::JSMessageObject> message = | 2173 i::Handle<i::JSMessageObject> message = |
2263 i::Handle<i::JSMessageObject>::cast(data_obj); | 2174 i::Handle<i::JSMessageObject>::cast(data_obj); |
2264 int start = message->start_position(); | 2175 int start = message->start_position(); |
2265 int end = message->end_position(); | 2176 int end = message->end_position(); |
2266 return static_cast<int>(start_col_obj->Number()) + (end - start); | 2177 return static_cast<int>(start_col_obj->Number()) + (end - start); |
2267 } | 2178 } |
2268 | 2179 |
2269 | 2180 |
2270 bool Message::IsSharedCrossOrigin() const { | 2181 bool Message::IsSharedCrossOrigin() const { |
2271 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2182 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2272 if (IsDeadCheck(isolate, "v8::Message::IsSharedCrossOrigin()")) return 0; | |
2273 ENTER_V8(isolate); | 2183 ENTER_V8(isolate); |
2274 i::HandleScope scope(isolate); | 2184 i::HandleScope scope(isolate); |
2275 i::Handle<i::JSMessageObject> message = | 2185 i::Handle<i::JSMessageObject> message = |
2276 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); | 2186 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); |
2277 i::Handle<i::JSValue> script = | 2187 i::Handle<i::JSValue> script = |
2278 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(), | 2188 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(), |
2279 isolate)); | 2189 isolate)); |
2280 return i::Script::cast(script->value())->is_shared_cross_origin(); | 2190 return i::Script::cast(script->value())->is_shared_cross_origin(); |
2281 } | 2191 } |
2282 | 2192 |
(...skipping 11 matching lines...) Expand all Loading... |
2294 if (result->IsString()) { | 2204 if (result->IsString()) { |
2295 return scope.Close(Utils::ToLocal(i::Handle<i::String>::cast(result))); | 2205 return scope.Close(Utils::ToLocal(i::Handle<i::String>::cast(result))); |
2296 } else { | 2206 } else { |
2297 return Local<String>(); | 2207 return Local<String>(); |
2298 } | 2208 } |
2299 } | 2209 } |
2300 | 2210 |
2301 | 2211 |
2302 void Message::PrintCurrentStackTrace(FILE* out) { | 2212 void Message::PrintCurrentStackTrace(FILE* out) { |
2303 i::Isolate* isolate = i::Isolate::Current(); | 2213 i::Isolate* isolate = i::Isolate::Current(); |
2304 if (IsDeadCheck(isolate, "v8::Message::PrintCurrentStackTrace()")) return; | |
2305 ENTER_V8(isolate); | 2214 ENTER_V8(isolate); |
2306 isolate->PrintCurrentStackTrace(out); | 2215 isolate->PrintCurrentStackTrace(out); |
2307 } | 2216 } |
2308 | 2217 |
2309 | 2218 |
2310 // --- S t a c k T r a c e --- | 2219 // --- S t a c k T r a c e --- |
2311 | 2220 |
2312 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const { | 2221 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const { |
2313 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2222 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2314 if (IsDeadCheck(isolate, "v8::StackTrace::GetFrame()")) { | |
2315 return Local<StackFrame>(); | |
2316 } | |
2317 ENTER_V8(isolate); | 2223 ENTER_V8(isolate); |
2318 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 2224 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
2319 i::Handle<i::JSArray> self = Utils::OpenHandle(this); | 2225 i::Handle<i::JSArray> self = Utils::OpenHandle(this); |
2320 i::Object* raw_object = self->GetElementNoExceptionThrown(isolate, index); | 2226 i::Object* raw_object = self->GetElementNoExceptionThrown(isolate, index); |
2321 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_object)); | 2227 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_object)); |
2322 return scope.Close(Utils::StackFrameToLocal(obj)); | 2228 return scope.Close(Utils::StackFrameToLocal(obj)); |
2323 } | 2229 } |
2324 | 2230 |
2325 | 2231 |
2326 int StackTrace::GetFrameCount() const { | 2232 int StackTrace::GetFrameCount() const { |
2327 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2233 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2328 if (IsDeadCheck(isolate, "v8::StackTrace::GetFrameCount()")) return -1; | |
2329 ENTER_V8(isolate); | 2234 ENTER_V8(isolate); |
2330 return i::Smi::cast(Utils::OpenHandle(this)->length())->value(); | 2235 return i::Smi::cast(Utils::OpenHandle(this)->length())->value(); |
2331 } | 2236 } |
2332 | 2237 |
2333 | 2238 |
2334 Local<Array> StackTrace::AsArray() { | 2239 Local<Array> StackTrace::AsArray() { |
2335 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2240 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2336 if (IsDeadCheck(isolate, "v8::StackTrace::AsArray()")) Local<Array>(); | |
2337 ENTER_V8(isolate); | 2241 ENTER_V8(isolate); |
2338 return Utils::ToLocal(Utils::OpenHandle(this)); | 2242 return Utils::ToLocal(Utils::OpenHandle(this)); |
2339 } | 2243 } |
2340 | 2244 |
2341 | 2245 |
2342 Local<StackTrace> StackTrace::CurrentStackTrace(int frame_limit, | 2246 Local<StackTrace> StackTrace::CurrentStackTrace(int frame_limit, |
2343 StackTraceOptions options) { | 2247 StackTraceOptions options) { |
2344 i::Isolate* isolate = i::Isolate::Current(); | 2248 i::Isolate* isolate = i::Isolate::Current(); |
2345 if (IsDeadCheck(isolate, "v8::StackTrace::CurrentStackTrace()")) { | |
2346 Local<StackTrace>(); | |
2347 } | |
2348 ENTER_V8(isolate); | 2249 ENTER_V8(isolate); |
2349 i::Handle<i::JSArray> stackTrace = | 2250 i::Handle<i::JSArray> stackTrace = |
2350 isolate->CaptureCurrentStackTrace(frame_limit, options); | 2251 isolate->CaptureCurrentStackTrace(frame_limit, options); |
2351 return Utils::StackTraceToLocal(stackTrace); | 2252 return Utils::StackTraceToLocal(stackTrace); |
2352 } | 2253 } |
2353 | 2254 |
2354 | 2255 |
2355 // --- S t a c k F r a m e --- | 2256 // --- S t a c k F r a m e --- |
2356 | 2257 |
2357 int StackFrame::GetLineNumber() const { | 2258 int StackFrame::GetLineNumber() const { |
2358 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2259 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2359 if (IsDeadCheck(isolate, "v8::StackFrame::GetLineNumber()")) { | |
2360 return Message::kNoLineNumberInfo; | |
2361 } | |
2362 ENTER_V8(isolate); | 2260 ENTER_V8(isolate); |
2363 i::HandleScope scope(isolate); | 2261 i::HandleScope scope(isolate); |
2364 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2262 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
2365 i::Handle<i::Object> line = GetProperty(self, "lineNumber"); | 2263 i::Handle<i::Object> line = GetProperty(self, "lineNumber"); |
2366 if (!line->IsSmi()) { | 2264 if (!line->IsSmi()) { |
2367 return Message::kNoLineNumberInfo; | 2265 return Message::kNoLineNumberInfo; |
2368 } | 2266 } |
2369 return i::Smi::cast(*line)->value(); | 2267 return i::Smi::cast(*line)->value(); |
2370 } | 2268 } |
2371 | 2269 |
2372 | 2270 |
2373 int StackFrame::GetColumn() const { | 2271 int StackFrame::GetColumn() const { |
2374 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2272 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2375 if (IsDeadCheck(isolate, "v8::StackFrame::GetColumn()")) { | |
2376 return Message::kNoColumnInfo; | |
2377 } | |
2378 ENTER_V8(isolate); | 2273 ENTER_V8(isolate); |
2379 i::HandleScope scope(isolate); | 2274 i::HandleScope scope(isolate); |
2380 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2275 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
2381 i::Handle<i::Object> column = GetProperty(self, "column"); | 2276 i::Handle<i::Object> column = GetProperty(self, "column"); |
2382 if (!column->IsSmi()) { | 2277 if (!column->IsSmi()) { |
2383 return Message::kNoColumnInfo; | 2278 return Message::kNoColumnInfo; |
2384 } | 2279 } |
2385 return i::Smi::cast(*column)->value(); | 2280 return i::Smi::cast(*column)->value(); |
2386 } | 2281 } |
2387 | 2282 |
2388 | 2283 |
2389 int StackFrame::GetScriptId() const { | 2284 int StackFrame::GetScriptId() const { |
2390 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2285 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2391 if (IsDeadCheck(isolate, "v8::StackFrame::GetScriptId()")) { | |
2392 return Message::kNoScriptIdInfo; | |
2393 } | |
2394 ENTER_V8(isolate); | 2286 ENTER_V8(isolate); |
2395 i::HandleScope scope(isolate); | 2287 i::HandleScope scope(isolate); |
2396 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2288 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
2397 i::Handle<i::Object> scriptId = GetProperty(self, "scriptId"); | 2289 i::Handle<i::Object> scriptId = GetProperty(self, "scriptId"); |
2398 if (!scriptId->IsSmi()) { | 2290 if (!scriptId->IsSmi()) { |
2399 return Message::kNoScriptIdInfo; | 2291 return Message::kNoScriptIdInfo; |
2400 } | 2292 } |
2401 return i::Smi::cast(*scriptId)->value(); | 2293 return i::Smi::cast(*scriptId)->value(); |
2402 } | 2294 } |
2403 | 2295 |
2404 | 2296 |
2405 Local<String> StackFrame::GetScriptName() const { | 2297 Local<String> StackFrame::GetScriptName() const { |
2406 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2298 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2407 if (IsDeadCheck(isolate, "v8::StackFrame::GetScriptName()")) { | |
2408 return Local<String>(); | |
2409 } | |
2410 ENTER_V8(isolate); | 2299 ENTER_V8(isolate); |
2411 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 2300 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
2412 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2301 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
2413 i::Handle<i::Object> name = GetProperty(self, "scriptName"); | 2302 i::Handle<i::Object> name = GetProperty(self, "scriptName"); |
2414 if (!name->IsString()) { | 2303 if (!name->IsString()) { |
2415 return Local<String>(); | 2304 return Local<String>(); |
2416 } | 2305 } |
2417 return scope.Close(Local<String>::Cast(Utils::ToLocal(name))); | 2306 return scope.Close(Local<String>::Cast(Utils::ToLocal(name))); |
2418 } | 2307 } |
2419 | 2308 |
2420 | 2309 |
2421 Local<String> StackFrame::GetScriptNameOrSourceURL() const { | 2310 Local<String> StackFrame::GetScriptNameOrSourceURL() const { |
2422 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2311 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2423 if (IsDeadCheck(isolate, "v8::StackFrame::GetScriptNameOrSourceURL()")) { | |
2424 return Local<String>(); | |
2425 } | |
2426 ENTER_V8(isolate); | 2312 ENTER_V8(isolate); |
2427 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 2313 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
2428 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2314 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
2429 i::Handle<i::Object> name = GetProperty(self, "scriptNameOrSourceURL"); | 2315 i::Handle<i::Object> name = GetProperty(self, "scriptNameOrSourceURL"); |
2430 if (!name->IsString()) { | 2316 if (!name->IsString()) { |
2431 return Local<String>(); | 2317 return Local<String>(); |
2432 } | 2318 } |
2433 return scope.Close(Local<String>::Cast(Utils::ToLocal(name))); | 2319 return scope.Close(Local<String>::Cast(Utils::ToLocal(name))); |
2434 } | 2320 } |
2435 | 2321 |
2436 | 2322 |
2437 Local<String> StackFrame::GetFunctionName() const { | 2323 Local<String> StackFrame::GetFunctionName() const { |
2438 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2324 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2439 if (IsDeadCheck(isolate, "v8::StackFrame::GetFunctionName()")) { | |
2440 return Local<String>(); | |
2441 } | |
2442 ENTER_V8(isolate); | 2325 ENTER_V8(isolate); |
2443 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 2326 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
2444 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2327 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
2445 i::Handle<i::Object> name = GetProperty(self, "functionName"); | 2328 i::Handle<i::Object> name = GetProperty(self, "functionName"); |
2446 if (!name->IsString()) { | 2329 if (!name->IsString()) { |
2447 return Local<String>(); | 2330 return Local<String>(); |
2448 } | 2331 } |
2449 return scope.Close(Local<String>::Cast(Utils::ToLocal(name))); | 2332 return scope.Close(Local<String>::Cast(Utils::ToLocal(name))); |
2450 } | 2333 } |
2451 | 2334 |
2452 | 2335 |
2453 bool StackFrame::IsEval() const { | 2336 bool StackFrame::IsEval() const { |
2454 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2337 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2455 if (IsDeadCheck(isolate, "v8::StackFrame::IsEval()")) return false; | |
2456 ENTER_V8(isolate); | 2338 ENTER_V8(isolate); |
2457 i::HandleScope scope(isolate); | 2339 i::HandleScope scope(isolate); |
2458 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2340 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
2459 i::Handle<i::Object> is_eval = GetProperty(self, "isEval"); | 2341 i::Handle<i::Object> is_eval = GetProperty(self, "isEval"); |
2460 return is_eval->IsTrue(); | 2342 return is_eval->IsTrue(); |
2461 } | 2343 } |
2462 | 2344 |
2463 | 2345 |
2464 bool StackFrame::IsConstructor() const { | 2346 bool StackFrame::IsConstructor() const { |
2465 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2347 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2466 if (IsDeadCheck(isolate, "v8::StackFrame::IsConstructor()")) return false; | |
2467 ENTER_V8(isolate); | 2348 ENTER_V8(isolate); |
2468 i::HandleScope scope(isolate); | 2349 i::HandleScope scope(isolate); |
2469 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2350 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
2470 i::Handle<i::Object> is_constructor = GetProperty(self, "isConstructor"); | 2351 i::Handle<i::Object> is_constructor = GetProperty(self, "isConstructor"); |
2471 return is_constructor->IsTrue(); | 2352 return is_constructor->IsTrue(); |
2472 } | 2353 } |
2473 | 2354 |
2474 | 2355 |
2475 // --- J S O N --- | 2356 // --- J S O N --- |
2476 | 2357 |
(...skipping 14 matching lines...) Expand all Loading... |
2491 has_pending_exception = result.is_null(); | 2372 has_pending_exception = result.is_null(); |
2492 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>()); | 2373 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>()); |
2493 return Utils::ToLocal( | 2374 return Utils::ToLocal( |
2494 i::Handle<i::Object>::cast(scope.CloseAndEscape(result))); | 2375 i::Handle<i::Object>::cast(scope.CloseAndEscape(result))); |
2495 } | 2376 } |
2496 | 2377 |
2497 | 2378 |
2498 // --- D a t a --- | 2379 // --- D a t a --- |
2499 | 2380 |
2500 bool Value::FullIsUndefined() const { | 2381 bool Value::FullIsUndefined() const { |
2501 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsUndefined()")) { | |
2502 return false; | |
2503 } | |
2504 bool result = Utils::OpenHandle(this)->IsUndefined(); | 2382 bool result = Utils::OpenHandle(this)->IsUndefined(); |
2505 ASSERT_EQ(result, QuickIsUndefined()); | 2383 ASSERT_EQ(result, QuickIsUndefined()); |
2506 return result; | 2384 return result; |
2507 } | 2385 } |
2508 | 2386 |
2509 | 2387 |
2510 bool Value::FullIsNull() const { | 2388 bool Value::FullIsNull() const { |
2511 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsNull()")) return false; | |
2512 bool result = Utils::OpenHandle(this)->IsNull(); | 2389 bool result = Utils::OpenHandle(this)->IsNull(); |
2513 ASSERT_EQ(result, QuickIsNull()); | 2390 ASSERT_EQ(result, QuickIsNull()); |
2514 return result; | 2391 return result; |
2515 } | 2392 } |
2516 | 2393 |
2517 | 2394 |
2518 bool Value::IsTrue() const { | 2395 bool Value::IsTrue() const { |
2519 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsTrue()")) return false; | |
2520 return Utils::OpenHandle(this)->IsTrue(); | 2396 return Utils::OpenHandle(this)->IsTrue(); |
2521 } | 2397 } |
2522 | 2398 |
2523 | 2399 |
2524 bool Value::IsFalse() const { | 2400 bool Value::IsFalse() const { |
2525 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsFalse()")) return false; | |
2526 return Utils::OpenHandle(this)->IsFalse(); | 2401 return Utils::OpenHandle(this)->IsFalse(); |
2527 } | 2402 } |
2528 | 2403 |
2529 | 2404 |
2530 bool Value::IsFunction() const { | 2405 bool Value::IsFunction() const { |
2531 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsFunction()")) { | |
2532 return false; | |
2533 } | |
2534 return Utils::OpenHandle(this)->IsJSFunction(); | 2406 return Utils::OpenHandle(this)->IsJSFunction(); |
2535 } | 2407 } |
2536 | 2408 |
2537 | 2409 |
2538 bool Value::FullIsString() const { | 2410 bool Value::FullIsString() const { |
2539 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsString()")) return false; | |
2540 bool result = Utils::OpenHandle(this)->IsString(); | 2411 bool result = Utils::OpenHandle(this)->IsString(); |
2541 ASSERT_EQ(result, QuickIsString()); | 2412 ASSERT_EQ(result, QuickIsString()); |
2542 return result; | 2413 return result; |
2543 } | 2414 } |
2544 | 2415 |
2545 | 2416 |
2546 bool Value::IsSymbol() const { | 2417 bool Value::IsSymbol() const { |
2547 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsSymbol()")) return false; | |
2548 return Utils::OpenHandle(this)->IsSymbol(); | 2418 return Utils::OpenHandle(this)->IsSymbol(); |
2549 } | 2419 } |
2550 | 2420 |
2551 | 2421 |
2552 bool Value::IsArray() const { | 2422 bool Value::IsArray() const { |
2553 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsArray()")) return false; | |
2554 return Utils::OpenHandle(this)->IsJSArray(); | 2423 return Utils::OpenHandle(this)->IsJSArray(); |
2555 } | 2424 } |
2556 | 2425 |
2557 | 2426 |
2558 bool Value::IsArrayBuffer() const { | 2427 bool Value::IsArrayBuffer() const { |
2559 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsArrayBuffer()")) | |
2560 return false; | |
2561 return Utils::OpenHandle(this)->IsJSArrayBuffer(); | 2428 return Utils::OpenHandle(this)->IsJSArrayBuffer(); |
2562 } | 2429 } |
2563 | 2430 |
2564 | 2431 |
2565 bool Value::IsArrayBufferView() const { | 2432 bool Value::IsArrayBufferView() const { |
2566 return Utils::OpenHandle(this)->IsJSArrayBufferView(); | 2433 return Utils::OpenHandle(this)->IsJSArrayBufferView(); |
2567 } | 2434 } |
2568 | 2435 |
2569 | 2436 |
2570 bool Value::IsTypedArray() const { | 2437 bool Value::IsTypedArray() const { |
2571 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsArrayBuffer()")) | |
2572 return false; | |
2573 return Utils::OpenHandle(this)->IsJSTypedArray(); | 2438 return Utils::OpenHandle(this)->IsJSTypedArray(); |
2574 } | 2439 } |
2575 | 2440 |
2576 | 2441 |
2577 #define TYPED_ARRAY_LIST(F) \ | 2442 #define TYPED_ARRAY_LIST(F) \ |
2578 F(Uint8Array, kExternalUnsignedByteArray) \ | 2443 F(Uint8Array, kExternalUnsignedByteArray) \ |
2579 F(Int8Array, kExternalByteArray) \ | 2444 F(Int8Array, kExternalByteArray) \ |
2580 F(Uint16Array, kExternalUnsignedShortArray) \ | 2445 F(Uint16Array, kExternalUnsignedShortArray) \ |
2581 F(Int16Array, kExternalShortArray) \ | 2446 F(Int16Array, kExternalShortArray) \ |
2582 F(Uint32Array, kExternalUnsignedIntArray) \ | 2447 F(Uint32Array, kExternalUnsignedIntArray) \ |
2583 F(Int32Array, kExternalIntArray) \ | 2448 F(Int32Array, kExternalIntArray) \ |
2584 F(Float32Array, kExternalFloatArray) \ | 2449 F(Float32Array, kExternalFloatArray) \ |
2585 F(Float64Array, kExternalDoubleArray) \ | 2450 F(Float64Array, kExternalDoubleArray) \ |
2586 F(Uint8ClampedArray, kExternalPixelArray) | 2451 F(Uint8ClampedArray, kExternalPixelArray) |
2587 | 2452 |
2588 | 2453 |
2589 #define VALUE_IS_TYPED_ARRAY(TypedArray, type_const) \ | 2454 #define VALUE_IS_TYPED_ARRAY(TypedArray, type_const) \ |
2590 bool Value::Is##TypedArray() const { \ | 2455 bool Value::Is##TypedArray() const { \ |
2591 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::Is" #TypedArray "()")) \ | |
2592 return false; \ | |
2593 i::Handle<i::Object> obj = Utils::OpenHandle(this); \ | 2456 i::Handle<i::Object> obj = Utils::OpenHandle(this); \ |
2594 if (!obj->IsJSTypedArray()) return false; \ | 2457 if (!obj->IsJSTypedArray()) return false; \ |
2595 return i::JSTypedArray::cast(*obj)->type() == type_const; \ | 2458 return i::JSTypedArray::cast(*obj)->type() == type_const; \ |
2596 } | 2459 } |
2597 | 2460 |
2598 TYPED_ARRAY_LIST(VALUE_IS_TYPED_ARRAY) | 2461 TYPED_ARRAY_LIST(VALUE_IS_TYPED_ARRAY) |
2599 | 2462 |
2600 #undef VALUE_IS_TYPED_ARRAY | 2463 #undef VALUE_IS_TYPED_ARRAY |
2601 | 2464 |
2602 | 2465 |
2603 bool Value::IsDataView() const { | 2466 bool Value::IsDataView() const { |
2604 return Utils::OpenHandle(this)->IsJSDataView(); | 2467 return Utils::OpenHandle(this)->IsJSDataView(); |
2605 } | 2468 } |
2606 | 2469 |
2607 | 2470 |
2608 bool Value::IsObject() const { | 2471 bool Value::IsObject() const { |
2609 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsObject()")) return false; | |
2610 return Utils::OpenHandle(this)->IsJSObject(); | 2472 return Utils::OpenHandle(this)->IsJSObject(); |
2611 } | 2473 } |
2612 | 2474 |
2613 | 2475 |
2614 bool Value::IsNumber() const { | 2476 bool Value::IsNumber() const { |
2615 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsNumber()")) return false; | |
2616 return Utils::OpenHandle(this)->IsNumber(); | 2477 return Utils::OpenHandle(this)->IsNumber(); |
2617 } | 2478 } |
2618 | 2479 |
2619 | 2480 |
2620 bool Value::IsBoolean() const { | 2481 bool Value::IsBoolean() const { |
2621 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsBoolean()")) { | |
2622 return false; | |
2623 } | |
2624 return Utils::OpenHandle(this)->IsBoolean(); | 2482 return Utils::OpenHandle(this)->IsBoolean(); |
2625 } | 2483 } |
2626 | 2484 |
2627 | 2485 |
2628 bool Value::IsExternal() const { | 2486 bool Value::IsExternal() const { |
2629 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsExternal()")) { | |
2630 return false; | |
2631 } | |
2632 return Utils::OpenHandle(this)->IsExternal(); | 2487 return Utils::OpenHandle(this)->IsExternal(); |
2633 } | 2488 } |
2634 | 2489 |
2635 | 2490 |
2636 bool Value::IsInt32() const { | 2491 bool Value::IsInt32() const { |
2637 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsInt32()")) return false; | |
2638 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2492 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2639 if (obj->IsSmi()) return true; | 2493 if (obj->IsSmi()) return true; |
2640 if (obj->IsNumber()) { | 2494 if (obj->IsNumber()) { |
2641 double value = obj->Number(); | 2495 double value = obj->Number(); |
2642 static const i::DoubleRepresentation minus_zero(-0.0); | 2496 static const i::DoubleRepresentation minus_zero(-0.0); |
2643 i::DoubleRepresentation rep(value); | 2497 i::DoubleRepresentation rep(value); |
2644 if (rep.bits == minus_zero.bits) { | 2498 if (rep.bits == minus_zero.bits) { |
2645 return false; | 2499 return false; |
2646 } | 2500 } |
2647 return i::FastI2D(i::FastD2I(value)) == value; | 2501 return i::FastI2D(i::FastD2I(value)) == value; |
2648 } | 2502 } |
2649 return false; | 2503 return false; |
2650 } | 2504 } |
2651 | 2505 |
2652 | 2506 |
2653 bool Value::IsUint32() const { | 2507 bool Value::IsUint32() const { |
2654 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsUint32()")) return false; | |
2655 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2508 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2656 if (obj->IsSmi()) return i::Smi::cast(*obj)->value() >= 0; | 2509 if (obj->IsSmi()) return i::Smi::cast(*obj)->value() >= 0; |
2657 if (obj->IsNumber()) { | 2510 if (obj->IsNumber()) { |
2658 double value = obj->Number(); | 2511 double value = obj->Number(); |
2659 static const i::DoubleRepresentation minus_zero(-0.0); | 2512 static const i::DoubleRepresentation minus_zero(-0.0); |
2660 i::DoubleRepresentation rep(value); | 2513 i::DoubleRepresentation rep(value); |
2661 if (rep.bits == minus_zero.bits) { | 2514 if (rep.bits == minus_zero.bits) { |
2662 return false; | 2515 return false; |
2663 } | 2516 } |
2664 return i::FastUI2D(i::FastD2UI(value)) == value; | 2517 return i::FastUI2D(i::FastD2UI(value)) == value; |
2665 } | 2518 } |
2666 return false; | 2519 return false; |
2667 } | 2520 } |
2668 | 2521 |
2669 | 2522 |
2670 bool Value::IsDate() const { | 2523 bool Value::IsDate() const { |
2671 i::Isolate* isolate = i::Isolate::Current(); | 2524 i::Isolate* isolate = i::Isolate::Current(); |
2672 if (IsDeadCheck(isolate, "v8::Value::IsDate()")) return false; | |
2673 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2525 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2674 return obj->HasSpecificClassOf(isolate->heap()->Date_string()); | 2526 return obj->HasSpecificClassOf(isolate->heap()->Date_string()); |
2675 } | 2527 } |
2676 | 2528 |
2677 | 2529 |
2678 bool Value::IsStringObject() const { | 2530 bool Value::IsStringObject() const { |
2679 i::Isolate* isolate = i::Isolate::Current(); | 2531 i::Isolate* isolate = i::Isolate::Current(); |
2680 if (IsDeadCheck(isolate, "v8::Value::IsStringObject()")) return false; | |
2681 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2532 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2682 return obj->HasSpecificClassOf(isolate->heap()->String_string()); | 2533 return obj->HasSpecificClassOf(isolate->heap()->String_string()); |
2683 } | 2534 } |
2684 | 2535 |
2685 | 2536 |
2686 bool Value::IsSymbolObject() const { | 2537 bool Value::IsSymbolObject() const { |
2687 // TODO(svenpanne): these and other test functions should be written such | 2538 // TODO(svenpanne): these and other test functions should be written such |
2688 // that they do not use Isolate::Current(). | 2539 // that they do not use Isolate::Current(). |
2689 i::Isolate* isolate = i::Isolate::Current(); | 2540 i::Isolate* isolate = i::Isolate::Current(); |
2690 if (IsDeadCheck(isolate, "v8::Value::IsSymbolObject()")) return false; | |
2691 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2541 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2692 return obj->HasSpecificClassOf(isolate->heap()->Symbol_string()); | 2542 return obj->HasSpecificClassOf(isolate->heap()->Symbol_string()); |
2693 } | 2543 } |
2694 | 2544 |
2695 | 2545 |
2696 bool Value::IsNumberObject() const { | 2546 bool Value::IsNumberObject() const { |
2697 i::Isolate* isolate = i::Isolate::Current(); | 2547 i::Isolate* isolate = i::Isolate::Current(); |
2698 if (IsDeadCheck(isolate, "v8::Value::IsNumberObject()")) return false; | |
2699 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2548 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2700 return obj->HasSpecificClassOf(isolate->heap()->Number_string()); | 2549 return obj->HasSpecificClassOf(isolate->heap()->Number_string()); |
2701 } | 2550 } |
2702 | 2551 |
2703 | 2552 |
2704 static i::Object* LookupBuiltin(i::Isolate* isolate, | 2553 static i::Object* LookupBuiltin(i::Isolate* isolate, |
2705 const char* builtin_name) { | 2554 const char* builtin_name) { |
2706 i::Handle<i::String> string = | 2555 i::Handle<i::String> string = |
2707 isolate->factory()->InternalizeUtf8String(builtin_name); | 2556 isolate->factory()->InternalizeUtf8String(builtin_name); |
2708 i::Handle<i::JSBuiltinsObject> builtins = isolate->js_builtins_object(); | 2557 i::Handle<i::JSBuiltinsObject> builtins = isolate->js_builtins_object(); |
2709 return builtins->GetPropertyNoExceptionThrown(*string); | 2558 return builtins->GetPropertyNoExceptionThrown(*string); |
2710 } | 2559 } |
2711 | 2560 |
2712 | 2561 |
2713 static bool CheckConstructor(i::Isolate* isolate, | 2562 static bool CheckConstructor(i::Isolate* isolate, |
2714 i::Handle<i::JSObject> obj, | 2563 i::Handle<i::JSObject> obj, |
2715 const char* class_name) { | 2564 const char* class_name) { |
2716 i::Object* constr = obj->map()->constructor(); | 2565 i::Object* constr = obj->map()->constructor(); |
2717 if (!constr->IsJSFunction()) return false; | 2566 if (!constr->IsJSFunction()) return false; |
2718 i::JSFunction* func = i::JSFunction::cast(constr); | 2567 i::JSFunction* func = i::JSFunction::cast(constr); |
2719 return func->shared()->native() && | 2568 return func->shared()->native() && |
2720 constr == LookupBuiltin(isolate, class_name); | 2569 constr == LookupBuiltin(isolate, class_name); |
2721 } | 2570 } |
2722 | 2571 |
2723 | 2572 |
2724 bool Value::IsNativeError() const { | 2573 bool Value::IsNativeError() const { |
2725 i::Isolate* isolate = i::Isolate::Current(); | 2574 i::Isolate* isolate = i::Isolate::Current(); |
2726 if (IsDeadCheck(isolate, "v8::Value::IsNativeError()")) return false; | |
2727 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2575 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2728 if (obj->IsJSObject()) { | 2576 if (obj->IsJSObject()) { |
2729 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*obj)); | 2577 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*obj)); |
2730 return CheckConstructor(isolate, js_obj, "$Error") || | 2578 return CheckConstructor(isolate, js_obj, "$Error") || |
2731 CheckConstructor(isolate, js_obj, "$EvalError") || | 2579 CheckConstructor(isolate, js_obj, "$EvalError") || |
2732 CheckConstructor(isolate, js_obj, "$RangeError") || | 2580 CheckConstructor(isolate, js_obj, "$RangeError") || |
2733 CheckConstructor(isolate, js_obj, "$ReferenceError") || | 2581 CheckConstructor(isolate, js_obj, "$ReferenceError") || |
2734 CheckConstructor(isolate, js_obj, "$SyntaxError") || | 2582 CheckConstructor(isolate, js_obj, "$SyntaxError") || |
2735 CheckConstructor(isolate, js_obj, "$TypeError") || | 2583 CheckConstructor(isolate, js_obj, "$TypeError") || |
2736 CheckConstructor(isolate, js_obj, "$URIError"); | 2584 CheckConstructor(isolate, js_obj, "$URIError"); |
2737 } else { | 2585 } else { |
2738 return false; | 2586 return false; |
2739 } | 2587 } |
2740 } | 2588 } |
2741 | 2589 |
2742 | 2590 |
2743 bool Value::IsBooleanObject() const { | 2591 bool Value::IsBooleanObject() const { |
2744 i::Isolate* isolate = i::Isolate::Current(); | 2592 i::Isolate* isolate = i::Isolate::Current(); |
2745 if (IsDeadCheck(isolate, "v8::Value::IsBooleanObject()")) return false; | |
2746 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2593 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2747 return obj->HasSpecificClassOf(isolate->heap()->Boolean_string()); | 2594 return obj->HasSpecificClassOf(isolate->heap()->Boolean_string()); |
2748 } | 2595 } |
2749 | 2596 |
2750 | 2597 |
2751 bool Value::IsRegExp() const { | 2598 bool Value::IsRegExp() const { |
2752 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsRegExp()")) return false; | |
2753 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2599 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2754 return obj->IsJSRegExp(); | 2600 return obj->IsJSRegExp(); |
2755 } | 2601 } |
2756 | 2602 |
2757 | 2603 |
2758 Local<String> Value::ToString() const { | 2604 Local<String> Value::ToString() const { |
2759 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2605 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2760 i::Handle<i::Object> str; | 2606 i::Handle<i::Object> str; |
2761 if (obj->IsString()) { | 2607 if (obj->IsString()) { |
2762 str = obj; | 2608 str = obj; |
2763 } else { | 2609 } else { |
2764 i::Isolate* isolate = i::Isolate::Current(); | 2610 i::Isolate* isolate = i::Isolate::Current(); |
2765 if (IsDeadCheck(isolate, "v8::Value::ToString()")) { | |
2766 return Local<String>(); | |
2767 } | |
2768 LOG_API(isolate, "ToString"); | 2611 LOG_API(isolate, "ToString"); |
2769 ENTER_V8(isolate); | 2612 ENTER_V8(isolate); |
2770 EXCEPTION_PREAMBLE(isolate); | 2613 EXCEPTION_PREAMBLE(isolate); |
2771 str = i::Execution::ToString(isolate, obj, &has_pending_exception); | 2614 str = i::Execution::ToString(isolate, obj, &has_pending_exception); |
2772 EXCEPTION_BAILOUT_CHECK(isolate, Local<String>()); | 2615 EXCEPTION_BAILOUT_CHECK(isolate, Local<String>()); |
2773 } | 2616 } |
2774 return ToApiHandle<String>(str); | 2617 return ToApiHandle<String>(str); |
2775 } | 2618 } |
2776 | 2619 |
2777 | 2620 |
2778 Local<String> Value::ToDetailString() const { | 2621 Local<String> Value::ToDetailString() const { |
2779 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2622 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2780 i::Handle<i::Object> str; | 2623 i::Handle<i::Object> str; |
2781 if (obj->IsString()) { | 2624 if (obj->IsString()) { |
2782 str = obj; | 2625 str = obj; |
2783 } else { | 2626 } else { |
2784 i::Isolate* isolate = i::Isolate::Current(); | 2627 i::Isolate* isolate = i::Isolate::Current(); |
2785 if (IsDeadCheck(isolate, "v8::Value::ToDetailString()")) { | |
2786 return Local<String>(); | |
2787 } | |
2788 LOG_API(isolate, "ToDetailString"); | 2628 LOG_API(isolate, "ToDetailString"); |
2789 ENTER_V8(isolate); | 2629 ENTER_V8(isolate); |
2790 EXCEPTION_PREAMBLE(isolate); | 2630 EXCEPTION_PREAMBLE(isolate); |
2791 str = i::Execution::ToDetailString(isolate, obj, &has_pending_exception); | 2631 str = i::Execution::ToDetailString(isolate, obj, &has_pending_exception); |
2792 EXCEPTION_BAILOUT_CHECK(isolate, Local<String>()); | 2632 EXCEPTION_BAILOUT_CHECK(isolate, Local<String>()); |
2793 } | 2633 } |
2794 return ToApiHandle<String>(str); | 2634 return ToApiHandle<String>(str); |
2795 } | 2635 } |
2796 | 2636 |
2797 | 2637 |
2798 Local<v8::Object> Value::ToObject() const { | 2638 Local<v8::Object> Value::ToObject() const { |
2799 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2639 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2800 i::Handle<i::Object> val; | 2640 i::Handle<i::Object> val; |
2801 if (obj->IsJSObject()) { | 2641 if (obj->IsJSObject()) { |
2802 val = obj; | 2642 val = obj; |
2803 } else { | 2643 } else { |
2804 i::Isolate* isolate = i::Isolate::Current(); | 2644 i::Isolate* isolate = i::Isolate::Current(); |
2805 if (IsDeadCheck(isolate, "v8::Value::ToObject()")) { | |
2806 return Local<v8::Object>(); | |
2807 } | |
2808 LOG_API(isolate, "ToObject"); | 2645 LOG_API(isolate, "ToObject"); |
2809 ENTER_V8(isolate); | 2646 ENTER_V8(isolate); |
2810 EXCEPTION_PREAMBLE(isolate); | 2647 EXCEPTION_PREAMBLE(isolate); |
2811 val = i::Execution::ToObject(isolate, obj, &has_pending_exception); | 2648 val = i::Execution::ToObject(isolate, obj, &has_pending_exception); |
2812 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>()); | 2649 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>()); |
2813 } | 2650 } |
2814 return ToApiHandle<Object>(val); | 2651 return ToApiHandle<Object>(val); |
2815 } | 2652 } |
2816 | 2653 |
2817 | 2654 |
2818 Local<Boolean> Value::ToBoolean() const { | 2655 Local<Boolean> Value::ToBoolean() const { |
2819 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2656 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2820 if (obj->IsBoolean()) { | 2657 if (obj->IsBoolean()) { |
2821 return ToApiHandle<Boolean>(obj); | 2658 return ToApiHandle<Boolean>(obj); |
2822 } else { | 2659 } else { |
2823 i::Isolate* isolate = i::Isolate::Current(); | 2660 i::Isolate* isolate = i::Isolate::Current(); |
2824 if (IsDeadCheck(isolate, "v8::Value::ToBoolean()")) { | |
2825 return Local<Boolean>(); | |
2826 } | |
2827 LOG_API(isolate, "ToBoolean"); | 2661 LOG_API(isolate, "ToBoolean"); |
2828 ENTER_V8(isolate); | 2662 ENTER_V8(isolate); |
2829 i::Handle<i::Object> val = | 2663 i::Handle<i::Object> val = |
2830 isolate->factory()->ToBoolean(obj->BooleanValue()); | 2664 isolate->factory()->ToBoolean(obj->BooleanValue()); |
2831 return ToApiHandle<Boolean>(val); | 2665 return ToApiHandle<Boolean>(val); |
2832 } | 2666 } |
2833 } | 2667 } |
2834 | 2668 |
2835 | 2669 |
2836 Local<Number> Value::ToNumber() const { | 2670 Local<Number> Value::ToNumber() const { |
2837 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2671 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2838 i::Handle<i::Object> num; | 2672 i::Handle<i::Object> num; |
2839 if (obj->IsNumber()) { | 2673 if (obj->IsNumber()) { |
2840 num = obj; | 2674 num = obj; |
2841 } else { | 2675 } else { |
2842 i::Isolate* isolate = i::Isolate::Current(); | 2676 i::Isolate* isolate = i::Isolate::Current(); |
2843 if (IsDeadCheck(isolate, "v8::Value::ToNumber()")) { | |
2844 return Local<Number>(); | |
2845 } | |
2846 LOG_API(isolate, "ToNumber"); | 2677 LOG_API(isolate, "ToNumber"); |
2847 ENTER_V8(isolate); | 2678 ENTER_V8(isolate); |
2848 EXCEPTION_PREAMBLE(isolate); | 2679 EXCEPTION_PREAMBLE(isolate); |
2849 num = i::Execution::ToNumber(isolate, obj, &has_pending_exception); | 2680 num = i::Execution::ToNumber(isolate, obj, &has_pending_exception); |
2850 EXCEPTION_BAILOUT_CHECK(isolate, Local<Number>()); | 2681 EXCEPTION_BAILOUT_CHECK(isolate, Local<Number>()); |
2851 } | 2682 } |
2852 return ToApiHandle<Number>(num); | 2683 return ToApiHandle<Number>(num); |
2853 } | 2684 } |
2854 | 2685 |
2855 | 2686 |
2856 Local<Integer> Value::ToInteger() const { | 2687 Local<Integer> Value::ToInteger() const { |
2857 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2688 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2858 i::Handle<i::Object> num; | 2689 i::Handle<i::Object> num; |
2859 if (obj->IsSmi()) { | 2690 if (obj->IsSmi()) { |
2860 num = obj; | 2691 num = obj; |
2861 } else { | 2692 } else { |
2862 i::Isolate* isolate = i::Isolate::Current(); | 2693 i::Isolate* isolate = i::Isolate::Current(); |
2863 if (IsDeadCheck(isolate, "v8::Value::ToInteger()")) return Local<Integer>(); | |
2864 LOG_API(isolate, "ToInteger"); | 2694 LOG_API(isolate, "ToInteger"); |
2865 ENTER_V8(isolate); | 2695 ENTER_V8(isolate); |
2866 EXCEPTION_PREAMBLE(isolate); | 2696 EXCEPTION_PREAMBLE(isolate); |
2867 num = i::Execution::ToInteger(isolate, obj, &has_pending_exception); | 2697 num = i::Execution::ToInteger(isolate, obj, &has_pending_exception); |
2868 EXCEPTION_BAILOUT_CHECK(isolate, Local<Integer>()); | 2698 EXCEPTION_BAILOUT_CHECK(isolate, Local<Integer>()); |
2869 } | 2699 } |
2870 return ToApiHandle<Integer>(num); | 2700 return ToApiHandle<Integer>(num); |
2871 } | 2701 } |
2872 | 2702 |
2873 | 2703 |
2874 void i::Internals::CheckInitializedImpl(v8::Isolate* external_isolate) { | 2704 void i::Internals::CheckInitializedImpl(v8::Isolate* external_isolate) { |
2875 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate); | 2705 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate); |
2876 ApiCheck(isolate != NULL && isolate->IsInitialized() && !isolate->IsDead(), | 2706 ApiCheck(isolate != NULL && isolate->IsInitialized() && !isolate->IsDead(), |
2877 "v8::internal::Internals::CheckInitialized()", | 2707 "v8::internal::Internals::CheckInitialized()", |
2878 "Isolate is not initialized or V8 has died"); | 2708 "Isolate is not initialized or V8 has died"); |
2879 } | 2709 } |
2880 | 2710 |
2881 | 2711 |
2882 void External::CheckCast(v8::Value* that) { | 2712 void External::CheckCast(v8::Value* that) { |
2883 if (IsDeadCheck(i::Isolate::Current(), "v8::External::Cast()")) return; | |
2884 ApiCheck(Utils::OpenHandle(that)->IsExternal(), | 2713 ApiCheck(Utils::OpenHandle(that)->IsExternal(), |
2885 "v8::External::Cast()", | 2714 "v8::External::Cast()", |
2886 "Could not convert to external"); | 2715 "Could not convert to external"); |
2887 } | 2716 } |
2888 | 2717 |
2889 | 2718 |
2890 void v8::Object::CheckCast(Value* that) { | 2719 void v8::Object::CheckCast(Value* that) { |
2891 if (IsDeadCheck(i::Isolate::Current(), "v8::Object::Cast()")) return; | |
2892 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2720 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2893 ApiCheck(obj->IsJSObject(), | 2721 ApiCheck(obj->IsJSObject(), |
2894 "v8::Object::Cast()", | 2722 "v8::Object::Cast()", |
2895 "Could not convert to object"); | 2723 "Could not convert to object"); |
2896 } | 2724 } |
2897 | 2725 |
2898 | 2726 |
2899 void v8::Function::CheckCast(Value* that) { | 2727 void v8::Function::CheckCast(Value* that) { |
2900 if (IsDeadCheck(i::Isolate::Current(), "v8::Function::Cast()")) return; | |
2901 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2728 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2902 ApiCheck(obj->IsJSFunction(), | 2729 ApiCheck(obj->IsJSFunction(), |
2903 "v8::Function::Cast()", | 2730 "v8::Function::Cast()", |
2904 "Could not convert to function"); | 2731 "Could not convert to function"); |
2905 } | 2732 } |
2906 | 2733 |
2907 | 2734 |
2908 void v8::String::CheckCast(v8::Value* that) { | 2735 void v8::String::CheckCast(v8::Value* that) { |
2909 if (IsDeadCheck(i::Isolate::Current(), "v8::String::Cast()")) return; | |
2910 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2736 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2911 ApiCheck(obj->IsString(), | 2737 ApiCheck(obj->IsString(), |
2912 "v8::String::Cast()", | 2738 "v8::String::Cast()", |
2913 "Could not convert to string"); | 2739 "Could not convert to string"); |
2914 } | 2740 } |
2915 | 2741 |
2916 | 2742 |
2917 void v8::Symbol::CheckCast(v8::Value* that) { | 2743 void v8::Symbol::CheckCast(v8::Value* that) { |
2918 if (IsDeadCheck(i::Isolate::Current(), "v8::Symbol::Cast()")) return; | |
2919 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2744 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2920 ApiCheck(obj->IsSymbol(), | 2745 ApiCheck(obj->IsSymbol(), |
2921 "v8::Symbol::Cast()", | 2746 "v8::Symbol::Cast()", |
2922 "Could not convert to symbol"); | 2747 "Could not convert to symbol"); |
2923 } | 2748 } |
2924 | 2749 |
2925 | 2750 |
2926 void v8::Number::CheckCast(v8::Value* that) { | 2751 void v8::Number::CheckCast(v8::Value* that) { |
2927 if (IsDeadCheck(i::Isolate::Current(), "v8::Number::Cast()")) return; | |
2928 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2752 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2929 ApiCheck(obj->IsNumber(), | 2753 ApiCheck(obj->IsNumber(), |
2930 "v8::Number::Cast()", | 2754 "v8::Number::Cast()", |
2931 "Could not convert to number"); | 2755 "Could not convert to number"); |
2932 } | 2756 } |
2933 | 2757 |
2934 | 2758 |
2935 void v8::Integer::CheckCast(v8::Value* that) { | 2759 void v8::Integer::CheckCast(v8::Value* that) { |
2936 if (IsDeadCheck(i::Isolate::Current(), "v8::Integer::Cast()")) return; | |
2937 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2760 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2938 ApiCheck(obj->IsNumber(), | 2761 ApiCheck(obj->IsNumber(), |
2939 "v8::Integer::Cast()", | 2762 "v8::Integer::Cast()", |
2940 "Could not convert to number"); | 2763 "Could not convert to number"); |
2941 } | 2764 } |
2942 | 2765 |
2943 | 2766 |
2944 void v8::Array::CheckCast(Value* that) { | 2767 void v8::Array::CheckCast(Value* that) { |
2945 if (IsDeadCheck(i::Isolate::Current(), "v8::Array::Cast()")) return; | |
2946 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2768 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2947 ApiCheck(obj->IsJSArray(), | 2769 ApiCheck(obj->IsJSArray(), |
2948 "v8::Array::Cast()", | 2770 "v8::Array::Cast()", |
2949 "Could not convert to array"); | 2771 "Could not convert to array"); |
2950 } | 2772 } |
2951 | 2773 |
2952 | 2774 |
2953 void v8::ArrayBuffer::CheckCast(Value* that) { | 2775 void v8::ArrayBuffer::CheckCast(Value* that) { |
2954 if (IsDeadCheck(i::Isolate::Current(), "v8::ArrayBuffer::Cast()")) return; | |
2955 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2776 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2956 ApiCheck(obj->IsJSArrayBuffer(), | 2777 ApiCheck(obj->IsJSArrayBuffer(), |
2957 "v8::ArrayBuffer::Cast()", | 2778 "v8::ArrayBuffer::Cast()", |
2958 "Could not convert to ArrayBuffer"); | 2779 "Could not convert to ArrayBuffer"); |
2959 } | 2780 } |
2960 | 2781 |
2961 | 2782 |
2962 void v8::ArrayBufferView::CheckCast(Value* that) { | 2783 void v8::ArrayBufferView::CheckCast(Value* that) { |
2963 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2784 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2964 ApiCheck(obj->IsJSArrayBufferView(), | 2785 ApiCheck(obj->IsJSArrayBufferView(), |
2965 "v8::ArrayBufferView::Cast()", | 2786 "v8::ArrayBufferView::Cast()", |
2966 "Could not convert to ArrayBufferView"); | 2787 "Could not convert to ArrayBufferView"); |
2967 } | 2788 } |
2968 | 2789 |
2969 | 2790 |
2970 void v8::TypedArray::CheckCast(Value* that) { | 2791 void v8::TypedArray::CheckCast(Value* that) { |
2971 if (IsDeadCheck(i::Isolate::Current(), "v8::TypedArray::Cast()")) return; | |
2972 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2792 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2973 ApiCheck(obj->IsJSTypedArray(), | 2793 ApiCheck(obj->IsJSTypedArray(), |
2974 "v8::TypedArray::Cast()", | 2794 "v8::TypedArray::Cast()", |
2975 "Could not convert to TypedArray"); | 2795 "Could not convert to TypedArray"); |
2976 } | 2796 } |
2977 | 2797 |
2978 | 2798 |
2979 #define CHECK_TYPED_ARRAY_CAST(ApiClass, typeConst) \ | 2799 #define CHECK_TYPED_ARRAY_CAST(ApiClass, typeConst) \ |
2980 void v8::ApiClass::CheckCast(Value* that) { \ | 2800 void v8::ApiClass::CheckCast(Value* that) { \ |
2981 if (IsDeadCheck(i::Isolate::Current(), "v8::" #ApiClass "::Cast()")) \ | |
2982 return; \ | |
2983 i::Handle<i::Object> obj = Utils::OpenHandle(that); \ | 2801 i::Handle<i::Object> obj = Utils::OpenHandle(that); \ |
2984 ApiCheck(obj->IsJSTypedArray() && \ | 2802 ApiCheck(obj->IsJSTypedArray() && \ |
2985 i::JSTypedArray::cast(*obj)->type() == typeConst, \ | 2803 i::JSTypedArray::cast(*obj)->type() == typeConst, \ |
2986 "v8::" #ApiClass "::Cast()", \ | 2804 "v8::" #ApiClass "::Cast()", \ |
2987 "Could not convert to " #ApiClass); \ | 2805 "Could not convert to " #ApiClass); \ |
2988 } | 2806 } |
2989 | 2807 |
2990 | 2808 |
2991 TYPED_ARRAY_LIST(CHECK_TYPED_ARRAY_CAST) | 2809 TYPED_ARRAY_LIST(CHECK_TYPED_ARRAY_CAST) |
2992 | 2810 |
2993 #undef CHECK_TYPED_ARRAY_CAST | 2811 #undef CHECK_TYPED_ARRAY_CAST |
2994 | 2812 |
2995 | 2813 |
2996 void v8::DataView::CheckCast(Value* that) { | 2814 void v8::DataView::CheckCast(Value* that) { |
2997 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2815 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
2998 ApiCheck(obj->IsJSDataView(), | 2816 ApiCheck(obj->IsJSDataView(), |
2999 "v8::DataView::Cast()", | 2817 "v8::DataView::Cast()", |
3000 "Could not convert to DataView"); | 2818 "Could not convert to DataView"); |
3001 } | 2819 } |
3002 | 2820 |
3003 | 2821 |
3004 void v8::Date::CheckCast(v8::Value* that) { | 2822 void v8::Date::CheckCast(v8::Value* that) { |
3005 i::Isolate* isolate = i::Isolate::Current(); | 2823 i::Isolate* isolate = i::Isolate::Current(); |
3006 if (IsDeadCheck(isolate, "v8::Date::Cast()")) return; | |
3007 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2824 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
3008 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Date_string()), | 2825 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Date_string()), |
3009 "v8::Date::Cast()", | 2826 "v8::Date::Cast()", |
3010 "Could not convert to date"); | 2827 "Could not convert to date"); |
3011 } | 2828 } |
3012 | 2829 |
3013 | 2830 |
3014 void v8::StringObject::CheckCast(v8::Value* that) { | 2831 void v8::StringObject::CheckCast(v8::Value* that) { |
3015 i::Isolate* isolate = i::Isolate::Current(); | 2832 i::Isolate* isolate = i::Isolate::Current(); |
3016 if (IsDeadCheck(isolate, "v8::StringObject::Cast()")) return; | |
3017 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2833 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
3018 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->String_string()), | 2834 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->String_string()), |
3019 "v8::StringObject::Cast()", | 2835 "v8::StringObject::Cast()", |
3020 "Could not convert to StringObject"); | 2836 "Could not convert to StringObject"); |
3021 } | 2837 } |
3022 | 2838 |
3023 | 2839 |
3024 void v8::SymbolObject::CheckCast(v8::Value* that) { | 2840 void v8::SymbolObject::CheckCast(v8::Value* that) { |
3025 i::Isolate* isolate = i::Isolate::Current(); | 2841 i::Isolate* isolate = i::Isolate::Current(); |
3026 if (IsDeadCheck(isolate, "v8::SymbolObject::Cast()")) return; | |
3027 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2842 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
3028 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Symbol_string()), | 2843 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Symbol_string()), |
3029 "v8::SymbolObject::Cast()", | 2844 "v8::SymbolObject::Cast()", |
3030 "Could not convert to SymbolObject"); | 2845 "Could not convert to SymbolObject"); |
3031 } | 2846 } |
3032 | 2847 |
3033 | 2848 |
3034 void v8::NumberObject::CheckCast(v8::Value* that) { | 2849 void v8::NumberObject::CheckCast(v8::Value* that) { |
3035 i::Isolate* isolate = i::Isolate::Current(); | 2850 i::Isolate* isolate = i::Isolate::Current(); |
3036 if (IsDeadCheck(isolate, "v8::NumberObject::Cast()")) return; | |
3037 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2851 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
3038 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Number_string()), | 2852 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Number_string()), |
3039 "v8::NumberObject::Cast()", | 2853 "v8::NumberObject::Cast()", |
3040 "Could not convert to NumberObject"); | 2854 "Could not convert to NumberObject"); |
3041 } | 2855 } |
3042 | 2856 |
3043 | 2857 |
3044 void v8::BooleanObject::CheckCast(v8::Value* that) { | 2858 void v8::BooleanObject::CheckCast(v8::Value* that) { |
3045 i::Isolate* isolate = i::Isolate::Current(); | 2859 i::Isolate* isolate = i::Isolate::Current(); |
3046 if (IsDeadCheck(isolate, "v8::BooleanObject::Cast()")) return; | |
3047 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2860 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
3048 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Boolean_string()), | 2861 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Boolean_string()), |
3049 "v8::BooleanObject::Cast()", | 2862 "v8::BooleanObject::Cast()", |
3050 "Could not convert to BooleanObject"); | 2863 "Could not convert to BooleanObject"); |
3051 } | 2864 } |
3052 | 2865 |
3053 | 2866 |
3054 void v8::RegExp::CheckCast(v8::Value* that) { | 2867 void v8::RegExp::CheckCast(v8::Value* that) { |
3055 if (IsDeadCheck(i::Isolate::Current(), "v8::RegExp::Cast()")) return; | |
3056 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2868 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
3057 ApiCheck(obj->IsJSRegExp(), | 2869 ApiCheck(obj->IsJSRegExp(), |
3058 "v8::RegExp::Cast()", | 2870 "v8::RegExp::Cast()", |
3059 "Could not convert to regular expression"); | 2871 "Could not convert to regular expression"); |
3060 } | 2872 } |
3061 | 2873 |
3062 | 2874 |
3063 bool Value::BooleanValue() const { | 2875 bool Value::BooleanValue() const { |
3064 return Utils::OpenHandle(this)->BooleanValue(); | 2876 return Utils::OpenHandle(this)->BooleanValue(); |
3065 } | 2877 } |
3066 | 2878 |
3067 | 2879 |
3068 double Value::NumberValue() const { | 2880 double Value::NumberValue() const { |
3069 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2881 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
3070 i::Handle<i::Object> num; | 2882 i::Handle<i::Object> num; |
3071 if (obj->IsNumber()) { | 2883 if (obj->IsNumber()) { |
3072 num = obj; | 2884 num = obj; |
3073 } else { | 2885 } else { |
3074 i::Isolate* isolate = i::Isolate::Current(); | 2886 i::Isolate* isolate = i::Isolate::Current(); |
3075 if (IsDeadCheck(isolate, "v8::Value::NumberValue()")) { | |
3076 return i::OS::nan_value(); | |
3077 } | |
3078 LOG_API(isolate, "NumberValue"); | 2887 LOG_API(isolate, "NumberValue"); |
3079 ENTER_V8(isolate); | 2888 ENTER_V8(isolate); |
3080 EXCEPTION_PREAMBLE(isolate); | 2889 EXCEPTION_PREAMBLE(isolate); |
3081 num = i::Execution::ToNumber(isolate, obj, &has_pending_exception); | 2890 num = i::Execution::ToNumber(isolate, obj, &has_pending_exception); |
3082 EXCEPTION_BAILOUT_CHECK(isolate, i::OS::nan_value()); | 2891 EXCEPTION_BAILOUT_CHECK(isolate, i::OS::nan_value()); |
3083 } | 2892 } |
3084 return num->Number(); | 2893 return num->Number(); |
3085 } | 2894 } |
3086 | 2895 |
3087 | 2896 |
3088 int64_t Value::IntegerValue() const { | 2897 int64_t Value::IntegerValue() const { |
3089 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2898 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
3090 i::Handle<i::Object> num; | 2899 i::Handle<i::Object> num; |
3091 if (obj->IsNumber()) { | 2900 if (obj->IsNumber()) { |
3092 num = obj; | 2901 num = obj; |
3093 } else { | 2902 } else { |
3094 i::Isolate* isolate = i::Isolate::Current(); | 2903 i::Isolate* isolate = i::Isolate::Current(); |
3095 if (IsDeadCheck(isolate, "v8::Value::IntegerValue()")) return 0; | |
3096 LOG_API(isolate, "IntegerValue"); | 2904 LOG_API(isolate, "IntegerValue"); |
3097 ENTER_V8(isolate); | 2905 ENTER_V8(isolate); |
3098 EXCEPTION_PREAMBLE(isolate); | 2906 EXCEPTION_PREAMBLE(isolate); |
3099 num = i::Execution::ToInteger(isolate, obj, &has_pending_exception); | 2907 num = i::Execution::ToInteger(isolate, obj, &has_pending_exception); |
3100 EXCEPTION_BAILOUT_CHECK(isolate, 0); | 2908 EXCEPTION_BAILOUT_CHECK(isolate, 0); |
3101 } | 2909 } |
3102 if (num->IsSmi()) { | 2910 if (num->IsSmi()) { |
3103 return i::Smi::cast(*num)->value(); | 2911 return i::Smi::cast(*num)->value(); |
3104 } else { | 2912 } else { |
3105 return static_cast<int64_t>(num->Number()); | 2913 return static_cast<int64_t>(num->Number()); |
3106 } | 2914 } |
3107 } | 2915 } |
3108 | 2916 |
3109 | 2917 |
3110 Local<Int32> Value::ToInt32() const { | 2918 Local<Int32> Value::ToInt32() const { |
3111 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2919 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
3112 i::Handle<i::Object> num; | 2920 i::Handle<i::Object> num; |
3113 if (obj->IsSmi()) { | 2921 if (obj->IsSmi()) { |
3114 num = obj; | 2922 num = obj; |
3115 } else { | 2923 } else { |
3116 i::Isolate* isolate = i::Isolate::Current(); | 2924 i::Isolate* isolate = i::Isolate::Current(); |
3117 if (IsDeadCheck(isolate, "v8::Value::ToInt32()")) return Local<Int32>(); | |
3118 LOG_API(isolate, "ToInt32"); | 2925 LOG_API(isolate, "ToInt32"); |
3119 ENTER_V8(isolate); | 2926 ENTER_V8(isolate); |
3120 EXCEPTION_PREAMBLE(isolate); | 2927 EXCEPTION_PREAMBLE(isolate); |
3121 num = i::Execution::ToInt32(isolate, obj, &has_pending_exception); | 2928 num = i::Execution::ToInt32(isolate, obj, &has_pending_exception); |
3122 EXCEPTION_BAILOUT_CHECK(isolate, Local<Int32>()); | 2929 EXCEPTION_BAILOUT_CHECK(isolate, Local<Int32>()); |
3123 } | 2930 } |
3124 return ToApiHandle<Int32>(num); | 2931 return ToApiHandle<Int32>(num); |
3125 } | 2932 } |
3126 | 2933 |
3127 | 2934 |
3128 Local<Uint32> Value::ToUint32() const { | 2935 Local<Uint32> Value::ToUint32() const { |
3129 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2936 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
3130 i::Handle<i::Object> num; | 2937 i::Handle<i::Object> num; |
3131 if (obj->IsSmi()) { | 2938 if (obj->IsSmi()) { |
3132 num = obj; | 2939 num = obj; |
3133 } else { | 2940 } else { |
3134 i::Isolate* isolate = i::Isolate::Current(); | 2941 i::Isolate* isolate = i::Isolate::Current(); |
3135 if (IsDeadCheck(isolate, "v8::Value::ToUint32()")) return Local<Uint32>(); | |
3136 LOG_API(isolate, "ToUInt32"); | 2942 LOG_API(isolate, "ToUInt32"); |
3137 ENTER_V8(isolate); | 2943 ENTER_V8(isolate); |
3138 EXCEPTION_PREAMBLE(isolate); | 2944 EXCEPTION_PREAMBLE(isolate); |
3139 num = i::Execution::ToUint32(isolate, obj, &has_pending_exception); | 2945 num = i::Execution::ToUint32(isolate, obj, &has_pending_exception); |
3140 EXCEPTION_BAILOUT_CHECK(isolate, Local<Uint32>()); | 2946 EXCEPTION_BAILOUT_CHECK(isolate, Local<Uint32>()); |
3141 } | 2947 } |
3142 return ToApiHandle<Uint32>(num); | 2948 return ToApiHandle<Uint32>(num); |
3143 } | 2949 } |
3144 | 2950 |
3145 | 2951 |
3146 Local<Uint32> Value::ToArrayIndex() const { | 2952 Local<Uint32> Value::ToArrayIndex() const { |
3147 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2953 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
3148 if (obj->IsSmi()) { | 2954 if (obj->IsSmi()) { |
3149 if (i::Smi::cast(*obj)->value() >= 0) return Utils::Uint32ToLocal(obj); | 2955 if (i::Smi::cast(*obj)->value() >= 0) return Utils::Uint32ToLocal(obj); |
3150 return Local<Uint32>(); | 2956 return Local<Uint32>(); |
3151 } | 2957 } |
3152 i::Isolate* isolate = i::Isolate::Current(); | 2958 i::Isolate* isolate = i::Isolate::Current(); |
3153 if (IsDeadCheck(isolate, "v8::Value::ToArrayIndex()")) return Local<Uint32>(); | |
3154 LOG_API(isolate, "ToArrayIndex"); | 2959 LOG_API(isolate, "ToArrayIndex"); |
3155 ENTER_V8(isolate); | 2960 ENTER_V8(isolate); |
3156 EXCEPTION_PREAMBLE(isolate); | 2961 EXCEPTION_PREAMBLE(isolate); |
3157 i::Handle<i::Object> string_obj = | 2962 i::Handle<i::Object> string_obj = |
3158 i::Execution::ToString(isolate, obj, &has_pending_exception); | 2963 i::Execution::ToString(isolate, obj, &has_pending_exception); |
3159 EXCEPTION_BAILOUT_CHECK(isolate, Local<Uint32>()); | 2964 EXCEPTION_BAILOUT_CHECK(isolate, Local<Uint32>()); |
3160 i::Handle<i::String> str = i::Handle<i::String>::cast(string_obj); | 2965 i::Handle<i::String> str = i::Handle<i::String>::cast(string_obj); |
3161 uint32_t index; | 2966 uint32_t index; |
3162 if (str->AsArrayIndex(&index)) { | 2967 if (str->AsArrayIndex(&index)) { |
3163 i::Handle<i::Object> value; | 2968 i::Handle<i::Object> value; |
3164 if (index <= static_cast<uint32_t>(i::Smi::kMaxValue)) { | 2969 if (index <= static_cast<uint32_t>(i::Smi::kMaxValue)) { |
3165 value = i::Handle<i::Object>(i::Smi::FromInt(index), isolate); | 2970 value = i::Handle<i::Object>(i::Smi::FromInt(index), isolate); |
3166 } else { | 2971 } else { |
3167 value = isolate->factory()->NewNumber(index); | 2972 value = isolate->factory()->NewNumber(index); |
3168 } | 2973 } |
3169 return Utils::Uint32ToLocal(value); | 2974 return Utils::Uint32ToLocal(value); |
3170 } | 2975 } |
3171 return Local<Uint32>(); | 2976 return Local<Uint32>(); |
3172 } | 2977 } |
3173 | 2978 |
3174 | 2979 |
3175 int32_t Value::Int32Value() const { | 2980 int32_t Value::Int32Value() const { |
3176 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2981 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
3177 if (obj->IsSmi()) { | 2982 if (obj->IsSmi()) { |
3178 return i::Smi::cast(*obj)->value(); | 2983 return i::Smi::cast(*obj)->value(); |
3179 } else { | 2984 } else { |
3180 i::Isolate* isolate = i::Isolate::Current(); | 2985 i::Isolate* isolate = i::Isolate::Current(); |
3181 if (IsDeadCheck(isolate, "v8::Value::Int32Value()")) return 0; | |
3182 LOG_API(isolate, "Int32Value (slow)"); | 2986 LOG_API(isolate, "Int32Value (slow)"); |
3183 ENTER_V8(isolate); | 2987 ENTER_V8(isolate); |
3184 EXCEPTION_PREAMBLE(isolate); | 2988 EXCEPTION_PREAMBLE(isolate); |
3185 i::Handle<i::Object> num = | 2989 i::Handle<i::Object> num = |
3186 i::Execution::ToInt32(isolate, obj, &has_pending_exception); | 2990 i::Execution::ToInt32(isolate, obj, &has_pending_exception); |
3187 EXCEPTION_BAILOUT_CHECK(isolate, 0); | 2991 EXCEPTION_BAILOUT_CHECK(isolate, 0); |
3188 if (num->IsSmi()) { | 2992 if (num->IsSmi()) { |
3189 return i::Smi::cast(*num)->value(); | 2993 return i::Smi::cast(*num)->value(); |
3190 } else { | 2994 } else { |
3191 return static_cast<int32_t>(num->Number()); | 2995 return static_cast<int32_t>(num->Number()); |
3192 } | 2996 } |
3193 } | 2997 } |
3194 } | 2998 } |
3195 | 2999 |
3196 | 3000 |
3197 bool Value::Equals(Handle<Value> that) const { | 3001 bool Value::Equals(Handle<Value> that) const { |
3198 i::Isolate* isolate = i::Isolate::Current(); | 3002 i::Isolate* isolate = i::Isolate::Current(); |
3199 if (IsDeadCheck(isolate, "v8::Value::Equals()") | 3003 if (EmptyCheck("v8::Value::Equals()", this) || |
3200 || EmptyCheck("v8::Value::Equals()", this) | 3004 EmptyCheck("v8::Value::Equals()", that)) { |
3201 || EmptyCheck("v8::Value::Equals()", that)) { | |
3202 return false; | 3005 return false; |
3203 } | 3006 } |
3204 LOG_API(isolate, "Equals"); | 3007 LOG_API(isolate, "Equals"); |
3205 ENTER_V8(isolate); | 3008 ENTER_V8(isolate); |
3206 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 3009 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
3207 i::Handle<i::Object> other = Utils::OpenHandle(*that); | 3010 i::Handle<i::Object> other = Utils::OpenHandle(*that); |
3208 // If both obj and other are JSObjects, we'd better compare by identity | 3011 // If both obj and other are JSObjects, we'd better compare by identity |
3209 // immediately when going into JS builtin. The reason is Invoke | 3012 // immediately when going into JS builtin. The reason is Invoke |
3210 // would overwrite global object receiver with global proxy. | 3013 // would overwrite global object receiver with global proxy. |
3211 if (obj->IsJSObject() && other->IsJSObject()) { | 3014 if (obj->IsJSObject() && other->IsJSObject()) { |
3212 return *obj == *other; | 3015 return *obj == *other; |
3213 } | 3016 } |
3214 i::Handle<i::Object> args[] = { other }; | 3017 i::Handle<i::Object> args[] = { other }; |
3215 EXCEPTION_PREAMBLE(isolate); | 3018 EXCEPTION_PREAMBLE(isolate); |
3216 i::Handle<i::Object> result = | 3019 i::Handle<i::Object> result = |
3217 CallV8HeapFunction("EQUALS", obj, ARRAY_SIZE(args), args, | 3020 CallV8HeapFunction("EQUALS", obj, ARRAY_SIZE(args), args, |
3218 &has_pending_exception); | 3021 &has_pending_exception); |
3219 EXCEPTION_BAILOUT_CHECK(isolate, false); | 3022 EXCEPTION_BAILOUT_CHECK(isolate, false); |
3220 return *result == i::Smi::FromInt(i::EQUAL); | 3023 return *result == i::Smi::FromInt(i::EQUAL); |
3221 } | 3024 } |
3222 | 3025 |
3223 | 3026 |
3224 bool Value::StrictEquals(Handle<Value> that) const { | 3027 bool Value::StrictEquals(Handle<Value> that) const { |
3225 i::Isolate* isolate = i::Isolate::Current(); | 3028 i::Isolate* isolate = i::Isolate::Current(); |
3226 if (IsDeadCheck(isolate, "v8::Value::StrictEquals()") | 3029 if (EmptyCheck("v8::Value::StrictEquals()", this) || |
3227 || EmptyCheck("v8::Value::StrictEquals()", this) | 3030 EmptyCheck("v8::Value::StrictEquals()", that)) { |
3228 || EmptyCheck("v8::Value::StrictEquals()", that)) { | |
3229 return false; | 3031 return false; |
3230 } | 3032 } |
3231 LOG_API(isolate, "StrictEquals"); | 3033 LOG_API(isolate, "StrictEquals"); |
3232 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 3034 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
3233 i::Handle<i::Object> other = Utils::OpenHandle(*that); | 3035 i::Handle<i::Object> other = Utils::OpenHandle(*that); |
3234 // Must check HeapNumber first, since NaN !== NaN. | 3036 // Must check HeapNumber first, since NaN !== NaN. |
3235 if (obj->IsHeapNumber()) { | 3037 if (obj->IsHeapNumber()) { |
3236 if (!other->IsNumber()) return false; | 3038 if (!other->IsNumber()) return false; |
3237 double x = obj->Number(); | 3039 double x = obj->Number(); |
3238 double y = other->Number(); | 3040 double y = other->Number(); |
(...skipping 13 matching lines...) Expand all Loading... |
3252 } | 3054 } |
3253 } | 3055 } |
3254 | 3056 |
3255 | 3057 |
3256 uint32_t Value::Uint32Value() const { | 3058 uint32_t Value::Uint32Value() const { |
3257 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 3059 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
3258 if (obj->IsSmi()) { | 3060 if (obj->IsSmi()) { |
3259 return i::Smi::cast(*obj)->value(); | 3061 return i::Smi::cast(*obj)->value(); |
3260 } else { | 3062 } else { |
3261 i::Isolate* isolate = i::Isolate::Current(); | 3063 i::Isolate* isolate = i::Isolate::Current(); |
3262 if (IsDeadCheck(isolate, "v8::Value::Uint32Value()")) return 0; | |
3263 LOG_API(isolate, "Uint32Value"); | 3064 LOG_API(isolate, "Uint32Value"); |
3264 ENTER_V8(isolate); | 3065 ENTER_V8(isolate); |
3265 EXCEPTION_PREAMBLE(isolate); | 3066 EXCEPTION_PREAMBLE(isolate); |
3266 i::Handle<i::Object> num = | 3067 i::Handle<i::Object> num = |
3267 i::Execution::ToUint32(isolate, obj, &has_pending_exception); | 3068 i::Execution::ToUint32(isolate, obj, &has_pending_exception); |
3268 EXCEPTION_BAILOUT_CHECK(isolate, 0); | 3069 EXCEPTION_BAILOUT_CHECK(isolate, 0); |
3269 if (num->IsSmi()) { | 3070 if (num->IsSmi()) { |
3270 return i::Smi::cast(*num)->value(); | 3071 return i::Smi::cast(*num)->value(); |
3271 } else { | 3072 } else { |
3272 return static_cast<uint32_t>(num->Number()); | 3073 return static_cast<uint32_t>(num->Number()); |
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4318 int Function::ScriptId() const { | 4119 int Function::ScriptId() const { |
4319 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | 4120 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
4320 if (!func->shared()->script()->IsScript()) return v8::Script::kNoScriptId; | 4121 if (!func->shared()->script()->IsScript()) return v8::Script::kNoScriptId; |
4321 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); | 4122 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); |
4322 return script->id()->value(); | 4123 return script->id()->value(); |
4323 } | 4124 } |
4324 | 4125 |
4325 | 4126 |
4326 int String::Length() const { | 4127 int String::Length() const { |
4327 i::Handle<i::String> str = Utils::OpenHandle(this); | 4128 i::Handle<i::String> str = Utils::OpenHandle(this); |
4328 if (IsDeadCheck(str->GetIsolate(), "v8::String::Length()")) return 0; | |
4329 return str->length(); | 4129 return str->length(); |
4330 } | 4130 } |
4331 | 4131 |
4332 | 4132 |
4333 bool String::IsOneByte() const { | 4133 bool String::IsOneByte() const { |
4334 i::Handle<i::String> str = Utils::OpenHandle(this); | 4134 i::Handle<i::String> str = Utils::OpenHandle(this); |
4335 if (IsDeadCheck(str->GetIsolate(), "v8::String::IsOneByte()")) { | |
4336 return false; | |
4337 } | |
4338 return str->HasOnlyOneByteChars(); | 4135 return str->HasOnlyOneByteChars(); |
4339 } | 4136 } |
4340 | 4137 |
4341 | 4138 |
4342 // Helpers for ContainsOnlyOneByteHelper | 4139 // Helpers for ContainsOnlyOneByteHelper |
4343 template<size_t size> struct OneByteMask; | 4140 template<size_t size> struct OneByteMask; |
4344 template<> struct OneByteMask<4> { | 4141 template<> struct OneByteMask<4> { |
4345 static const uint32_t value = 0xFF00FF00; | 4142 static const uint32_t value = 0xFF00FF00; |
4346 }; | 4143 }; |
4347 template<> struct OneByteMask<8> { | 4144 template<> struct OneByteMask<8> { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4443 } | 4240 } |
4444 return is_one_byte_; | 4241 return is_one_byte_; |
4445 } | 4242 } |
4446 bool is_one_byte_; | 4243 bool is_one_byte_; |
4447 DISALLOW_COPY_AND_ASSIGN(ContainsOnlyOneByteHelper); | 4244 DISALLOW_COPY_AND_ASSIGN(ContainsOnlyOneByteHelper); |
4448 }; | 4245 }; |
4449 | 4246 |
4450 | 4247 |
4451 bool String::ContainsOnlyOneByte() const { | 4248 bool String::ContainsOnlyOneByte() const { |
4452 i::Handle<i::String> str = Utils::OpenHandle(this); | 4249 i::Handle<i::String> str = Utils::OpenHandle(this); |
4453 if (IsDeadCheck(str->GetIsolate(), | |
4454 "v8::String::ContainsOnlyOneByte()")) { | |
4455 return false; | |
4456 } | |
4457 if (str->HasOnlyOneByteChars()) return true; | 4250 if (str->HasOnlyOneByteChars()) return true; |
4458 ContainsOnlyOneByteHelper helper; | 4251 ContainsOnlyOneByteHelper helper; |
4459 return helper.Check(*str); | 4252 return helper.Check(*str); |
4460 } | 4253 } |
4461 | 4254 |
4462 | 4255 |
4463 class Utf8LengthHelper : public i::AllStatic { | 4256 class Utf8LengthHelper : public i::AllStatic { |
4464 public: | 4257 public: |
4465 enum State { | 4258 enum State { |
4466 kEndsWithLeadingSurrogate = 1 << 0, | 4259 kEndsWithLeadingSurrogate = 1 << 0, |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4650 i::ConsString* cons_string = | 4443 i::ConsString* cons_string = |
4651 Utf8LengthHelper::Visitor::VisitFlat(str, &length, &state); | 4444 Utf8LengthHelper::Visitor::VisitFlat(str, &length, &state); |
4652 if (cons_string == NULL) return length; | 4445 if (cons_string == NULL) return length; |
4653 return Utf8LengthHelper::Calculate(cons_string); | 4446 return Utf8LengthHelper::Calculate(cons_string); |
4654 } | 4447 } |
4655 | 4448 |
4656 | 4449 |
4657 int String::Utf8Length() const { | 4450 int String::Utf8Length() const { |
4658 i::Handle<i::String> str = Utils::OpenHandle(this); | 4451 i::Handle<i::String> str = Utils::OpenHandle(this); |
4659 i::Isolate* isolate = str->GetIsolate(); | 4452 i::Isolate* isolate = str->GetIsolate(); |
4660 if (IsDeadCheck(isolate, "v8::String::Utf8Length()")) return 0; | |
4661 return v8::Utf8Length(*str, isolate); | 4453 return v8::Utf8Length(*str, isolate); |
4662 } | 4454 } |
4663 | 4455 |
4664 | 4456 |
4665 class Utf8WriterVisitor { | 4457 class Utf8WriterVisitor { |
4666 public: | 4458 public: |
4667 Utf8WriterVisitor( | 4459 Utf8WriterVisitor( |
4668 char* buffer, int capacity, bool skip_capacity_check) | 4460 char* buffer, int capacity, bool skip_capacity_check) |
4669 : early_termination_(false), | 4461 : early_termination_(false), |
4670 last_character_(unibrow::Utf16::kNoPreviousCharacter), | 4462 last_character_(unibrow::Utf16::kNoPreviousCharacter), |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4836 } | 4628 } |
4837 return true; | 4629 return true; |
4838 } | 4630 } |
4839 | 4631 |
4840 | 4632 |
4841 int String::WriteUtf8(char* buffer, | 4633 int String::WriteUtf8(char* buffer, |
4842 int capacity, | 4634 int capacity, |
4843 int* nchars_ref, | 4635 int* nchars_ref, |
4844 int options) const { | 4636 int options) const { |
4845 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 4637 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
4846 if (IsDeadCheck(isolate, "v8::String::WriteUtf8()")) return 0; | |
4847 LOG_API(isolate, "String::WriteUtf8"); | 4638 LOG_API(isolate, "String::WriteUtf8"); |
4848 ENTER_V8(isolate); | 4639 ENTER_V8(isolate); |
4849 i::Handle<i::String> str = Utils::OpenHandle(this); | 4640 i::Handle<i::String> str = Utils::OpenHandle(this); |
4850 if (options & HINT_MANY_WRITES_EXPECTED) { | 4641 if (options & HINT_MANY_WRITES_EXPECTED) { |
4851 FlattenString(str); // Flatten the string for efficiency. | 4642 FlattenString(str); // Flatten the string for efficiency. |
4852 } | 4643 } |
4853 const int string_length = str->length(); | 4644 const int string_length = str->length(); |
4854 bool write_null = !(options & NO_NULL_TERMINATION); | 4645 bool write_null = !(options & NO_NULL_TERMINATION); |
4855 // First check if we can just write the string without checking capacity. | 4646 // First check if we can just write the string without checking capacity. |
4856 if (capacity == -1 || capacity / 3 >= string_length) { | 4647 if (capacity == -1 || capacity / 3 >= string_length) { |
(...skipping 29 matching lines...) Expand all Loading... |
4886 i::String::VisitFlat(&writer, *str); | 4677 i::String::VisitFlat(&writer, *str); |
4887 return writer.CompleteWrite(write_null, nchars_ref); | 4678 return writer.CompleteWrite(write_null, nchars_ref); |
4888 } | 4679 } |
4889 | 4680 |
4890 | 4681 |
4891 int String::WriteAscii(char* buffer, | 4682 int String::WriteAscii(char* buffer, |
4892 int start, | 4683 int start, |
4893 int length, | 4684 int length, |
4894 int options) const { | 4685 int options) const { |
4895 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 4686 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
4896 if (IsDeadCheck(isolate, "v8::String::WriteAscii()")) return 0; | |
4897 LOG_API(isolate, "String::WriteAscii"); | 4687 LOG_API(isolate, "String::WriteAscii"); |
4898 ENTER_V8(isolate); | 4688 ENTER_V8(isolate); |
4899 ASSERT(start >= 0 && length >= -1); | 4689 ASSERT(start >= 0 && length >= -1); |
4900 i::Handle<i::String> str = Utils::OpenHandle(this); | 4690 i::Handle<i::String> str = Utils::OpenHandle(this); |
4901 isolate->string_tracker()->RecordWrite(str); | 4691 isolate->string_tracker()->RecordWrite(str); |
4902 if (options & HINT_MANY_WRITES_EXPECTED) { | 4692 if (options & HINT_MANY_WRITES_EXPECTED) { |
4903 FlattenString(str); // Flatten the string for efficiency. | 4693 FlattenString(str); // Flatten the string for efficiency. |
4904 } | 4694 } |
4905 | 4695 |
4906 int end = length; | 4696 int end = length; |
(...skipping 15 matching lines...) Expand all Loading... |
4922 } | 4712 } |
4923 | 4713 |
4924 | 4714 |
4925 template<typename CharType> | 4715 template<typename CharType> |
4926 static inline int WriteHelper(const String* string, | 4716 static inline int WriteHelper(const String* string, |
4927 CharType* buffer, | 4717 CharType* buffer, |
4928 int start, | 4718 int start, |
4929 int length, | 4719 int length, |
4930 int options) { | 4720 int options) { |
4931 i::Isolate* isolate = Utils::OpenHandle(string)->GetIsolate(); | 4721 i::Isolate* isolate = Utils::OpenHandle(string)->GetIsolate(); |
4932 if (IsDeadCheck(isolate, "v8::String::Write()")) return 0; | |
4933 LOG_API(isolate, "String::Write"); | 4722 LOG_API(isolate, "String::Write"); |
4934 ENTER_V8(isolate); | 4723 ENTER_V8(isolate); |
4935 ASSERT(start >= 0 && length >= -1); | 4724 ASSERT(start >= 0 && length >= -1); |
4936 i::Handle<i::String> str = Utils::OpenHandle(string); | 4725 i::Handle<i::String> str = Utils::OpenHandle(string); |
4937 isolate->string_tracker()->RecordWrite(str); | 4726 isolate->string_tracker()->RecordWrite(str); |
4938 if (options & String::HINT_MANY_WRITES_EXPECTED) { | 4727 if (options & String::HINT_MANY_WRITES_EXPECTED) { |
4939 // Flatten the string for efficiency. This applies whether we are | 4728 // Flatten the string for efficiency. This applies whether we are |
4940 // using StringCharacterStream or Get(i) to access the characters. | 4729 // using StringCharacterStream or Get(i) to access the characters. |
4941 FlattenString(str); | 4730 FlattenString(str); |
4942 } | 4731 } |
(...skipping 21 matching lines...) Expand all Loading... |
4964 int String::Write(uint16_t* buffer, | 4753 int String::Write(uint16_t* buffer, |
4965 int start, | 4754 int start, |
4966 int length, | 4755 int length, |
4967 int options) const { | 4756 int options) const { |
4968 return WriteHelper(this, buffer, start, length, options); | 4757 return WriteHelper(this, buffer, start, length, options); |
4969 } | 4758 } |
4970 | 4759 |
4971 | 4760 |
4972 bool v8::String::IsExternal() const { | 4761 bool v8::String::IsExternal() const { |
4973 i::Handle<i::String> str = Utils::OpenHandle(this); | 4762 i::Handle<i::String> str = Utils::OpenHandle(this); |
4974 if (IsDeadCheck(str->GetIsolate(), "v8::String::IsExternal()")) { | |
4975 return false; | |
4976 } | |
4977 EnsureInitializedForIsolate(str->GetIsolate(), "v8::String::IsExternal()"); | 4763 EnsureInitializedForIsolate(str->GetIsolate(), "v8::String::IsExternal()"); |
4978 return i::StringShape(*str).IsExternalTwoByte(); | 4764 return i::StringShape(*str).IsExternalTwoByte(); |
4979 } | 4765 } |
4980 | 4766 |
4981 | 4767 |
4982 bool v8::String::IsExternalAscii() const { | 4768 bool v8::String::IsExternalAscii() const { |
4983 i::Handle<i::String> str = Utils::OpenHandle(this); | 4769 i::Handle<i::String> str = Utils::OpenHandle(this); |
4984 if (IsDeadCheck(str->GetIsolate(), "v8::String::IsExternalAscii()")) { | |
4985 return false; | |
4986 } | |
4987 return i::StringShape(*str).IsExternalAscii(); | 4770 return i::StringShape(*str).IsExternalAscii(); |
4988 } | 4771 } |
4989 | 4772 |
4990 | 4773 |
4991 void v8::String::VerifyExternalStringResource( | 4774 void v8::String::VerifyExternalStringResource( |
4992 v8::String::ExternalStringResource* value) const { | 4775 v8::String::ExternalStringResource* value) const { |
4993 i::Handle<i::String> str = Utils::OpenHandle(this); | 4776 i::Handle<i::String> str = Utils::OpenHandle(this); |
4994 const v8::String::ExternalStringResource* expected; | 4777 const v8::String::ExternalStringResource* expected; |
4995 if (i::StringShape(*str).IsExternalTwoByte()) { | 4778 if (i::StringShape(*str).IsExternalTwoByte()) { |
4996 const void* resource = | 4779 const void* resource = |
(...skipping 25 matching lines...) Expand all Loading... |
5022 expectedEncoding = str->IsOneByteRepresentation() ? ASCII_ENCODING | 4805 expectedEncoding = str->IsOneByteRepresentation() ? ASCII_ENCODING |
5023 : TWO_BYTE_ENCODING; | 4806 : TWO_BYTE_ENCODING; |
5024 } | 4807 } |
5025 CHECK_EQ(expected, value); | 4808 CHECK_EQ(expected, value); |
5026 CHECK_EQ(expectedEncoding, encoding); | 4809 CHECK_EQ(expectedEncoding, encoding); |
5027 } | 4810 } |
5028 | 4811 |
5029 const v8::String::ExternalAsciiStringResource* | 4812 const v8::String::ExternalAsciiStringResource* |
5030 v8::String::GetExternalAsciiStringResource() const { | 4813 v8::String::GetExternalAsciiStringResource() const { |
5031 i::Handle<i::String> str = Utils::OpenHandle(this); | 4814 i::Handle<i::String> str = Utils::OpenHandle(this); |
5032 if (IsDeadCheck(str->GetIsolate(), | |
5033 "v8::String::GetExternalAsciiStringResource()")) { | |
5034 return NULL; | |
5035 } | |
5036 if (i::StringShape(*str).IsExternalAscii()) { | 4815 if (i::StringShape(*str).IsExternalAscii()) { |
5037 const void* resource = | 4816 const void* resource = |
5038 i::Handle<i::ExternalAsciiString>::cast(str)->resource(); | 4817 i::Handle<i::ExternalAsciiString>::cast(str)->resource(); |
5039 return reinterpret_cast<const ExternalAsciiStringResource*>(resource); | 4818 return reinterpret_cast<const ExternalAsciiStringResource*>(resource); |
5040 } else { | 4819 } else { |
5041 return NULL; | 4820 return NULL; |
5042 } | 4821 } |
5043 } | 4822 } |
5044 | 4823 |
5045 | 4824 |
5046 Local<Value> Symbol::Name() const { | 4825 Local<Value> Symbol::Name() const { |
5047 if (IsDeadCheck(i::Isolate::Current(), "v8::Symbol::Name()")) | |
5048 return Local<Value>(); | |
5049 i::Handle<i::Symbol> sym = Utils::OpenHandle(this); | 4826 i::Handle<i::Symbol> sym = Utils::OpenHandle(this); |
5050 i::Handle<i::Object> name(sym->name(), sym->GetIsolate()); | 4827 i::Handle<i::Object> name(sym->name(), sym->GetIsolate()); |
5051 return Utils::ToLocal(name); | 4828 return Utils::ToLocal(name); |
5052 } | 4829 } |
5053 | 4830 |
5054 | 4831 |
5055 double Number::Value() const { | 4832 double Number::Value() const { |
5056 if (IsDeadCheck(i::Isolate::Current(), "v8::Number::Value()")) return 0; | |
5057 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 4833 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
5058 return obj->Number(); | 4834 return obj->Number(); |
5059 } | 4835 } |
5060 | 4836 |
5061 | 4837 |
5062 bool Boolean::Value() const { | 4838 bool Boolean::Value() const { |
5063 if (IsDeadCheck(i::Isolate::Current(), "v8::Boolean::Value()")) return false; | |
5064 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 4839 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
5065 return obj->IsTrue(); | 4840 return obj->IsTrue(); |
5066 } | 4841 } |
5067 | 4842 |
5068 | 4843 |
5069 int64_t Integer::Value() const { | 4844 int64_t Integer::Value() const { |
5070 if (IsDeadCheck(i::Isolate::Current(), "v8::Integer::Value()")) return 0; | |
5071 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 4845 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
5072 if (obj->IsSmi()) { | 4846 if (obj->IsSmi()) { |
5073 return i::Smi::cast(*obj)->value(); | 4847 return i::Smi::cast(*obj)->value(); |
5074 } else { | 4848 } else { |
5075 return static_cast<int64_t>(obj->Number()); | 4849 return static_cast<int64_t>(obj->Number()); |
5076 } | 4850 } |
5077 } | 4851 } |
5078 | 4852 |
5079 | 4853 |
5080 int32_t Int32::Value() const { | 4854 int32_t Int32::Value() const { |
5081 if (IsDeadCheck(i::Isolate::Current(), "v8::Int32::Value()")) return 0; | |
5082 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 4855 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
5083 if (obj->IsSmi()) { | 4856 if (obj->IsSmi()) { |
5084 return i::Smi::cast(*obj)->value(); | 4857 return i::Smi::cast(*obj)->value(); |
5085 } else { | 4858 } else { |
5086 return static_cast<int32_t>(obj->Number()); | 4859 return static_cast<int32_t>(obj->Number()); |
5087 } | 4860 } |
5088 } | 4861 } |
5089 | 4862 |
5090 | 4863 |
5091 uint32_t Uint32::Value() const { | 4864 uint32_t Uint32::Value() const { |
5092 if (IsDeadCheck(i::Isolate::Current(), "v8::Uint32::Value()")) return 0; | |
5093 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 4865 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
5094 if (obj->IsSmi()) { | 4866 if (obj->IsSmi()) { |
5095 return i::Smi::cast(*obj)->value(); | 4867 return i::Smi::cast(*obj)->value(); |
5096 } else { | 4868 } else { |
5097 return static_cast<uint32_t>(obj->Number()); | 4869 return static_cast<uint32_t>(obj->Number()); |
5098 } | 4870 } |
5099 } | 4871 } |
5100 | 4872 |
5101 | 4873 |
5102 int v8::Object::InternalFieldCount() { | 4874 int v8::Object::InternalFieldCount() { |
5103 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 4875 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
5104 if (IsDeadCheck(obj->GetIsolate(), "v8::Object::InternalFieldCount()")) { | |
5105 return 0; | |
5106 } | |
5107 return obj->GetInternalFieldCount(); | 4876 return obj->GetInternalFieldCount(); |
5108 } | 4877 } |
5109 | 4878 |
5110 | 4879 |
5111 static bool InternalFieldOK(i::Handle<i::JSObject> obj, | 4880 static bool InternalFieldOK(i::Handle<i::JSObject> obj, |
5112 int index, | 4881 int index, |
5113 const char* location) { | 4882 const char* location) { |
5114 return !IsDeadCheck(obj->GetIsolate(), location) && | 4883 return ApiCheck(index < obj->GetInternalFieldCount(), |
5115 ApiCheck(index < obj->GetInternalFieldCount(), | 4884 location, |
5116 location, | 4885 "Internal field out of bounds"); |
5117 "Internal field out of bounds"); | |
5118 } | 4886 } |
5119 | 4887 |
5120 | 4888 |
5121 Local<Value> v8::Object::SlowGetInternalField(int index) { | 4889 Local<Value> v8::Object::SlowGetInternalField(int index) { |
5122 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 4890 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
5123 const char* location = "v8::Object::GetInternalField()"; | 4891 const char* location = "v8::Object::GetInternalField()"; |
5124 if (!InternalFieldOK(obj, index, location)) return Local<Value>(); | 4892 if (!InternalFieldOK(obj, index, location)) return Local<Value>(); |
5125 i::Handle<i::Object> value(obj->GetInternalField(index), obj->GetIsolate()); | 4893 i::Handle<i::Object> value(obj->GetInternalField(index), obj->GetIsolate()); |
5126 return Utils::ToLocal(value); | 4894 return Utils::ToLocal(value); |
5127 } | 4895 } |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5261 heap_statistics->heap_size_limit_ = 0; | 5029 heap_statistics->heap_size_limit_ = 0; |
5262 return; | 5030 return; |
5263 } | 5031 } |
5264 Isolate* ext_isolate = reinterpret_cast<Isolate*>(isolate); | 5032 Isolate* ext_isolate = reinterpret_cast<Isolate*>(isolate); |
5265 return ext_isolate->GetHeapStatistics(heap_statistics); | 5033 return ext_isolate->GetHeapStatistics(heap_statistics); |
5266 } | 5034 } |
5267 | 5035 |
5268 | 5036 |
5269 void v8::V8::VisitExternalResources(ExternalResourceVisitor* visitor) { | 5037 void v8::V8::VisitExternalResources(ExternalResourceVisitor* visitor) { |
5270 i::Isolate* isolate = i::Isolate::Current(); | 5038 i::Isolate* isolate = i::Isolate::Current(); |
5271 IsDeadCheck(isolate, "v8::V8::VisitExternalResources"); | |
5272 isolate->heap()->VisitExternalResources(visitor); | 5039 isolate->heap()->VisitExternalResources(visitor); |
5273 } | 5040 } |
5274 | 5041 |
5275 | 5042 |
5276 class VisitorAdapter : public i::ObjectVisitor { | 5043 class VisitorAdapter : public i::ObjectVisitor { |
5277 public: | 5044 public: |
5278 explicit VisitorAdapter(PersistentHandleVisitor* visitor) | 5045 explicit VisitorAdapter(PersistentHandleVisitor* visitor) |
5279 : visitor_(visitor) {} | 5046 : visitor_(visitor) {} |
5280 virtual void VisitPointers(i::Object** start, i::Object** end) { | 5047 virtual void VisitPointers(i::Object** start, i::Object** end) { |
5281 UNREACHABLE(); | 5048 UNREACHABLE(); |
5282 } | 5049 } |
5283 virtual void VisitEmbedderReference(i::Object** p, uint16_t class_id) { | 5050 virtual void VisitEmbedderReference(i::Object** p, uint16_t class_id) { |
5284 Value* value = ToApi<Value>(i::Handle<i::Object>(p)); | 5051 Value* value = ToApi<Value>(i::Handle<i::Object>(p)); |
5285 visitor_->VisitPersistentHandle( | 5052 visitor_->VisitPersistentHandle( |
5286 reinterpret_cast<Persistent<Value>*>(&value), class_id); | 5053 reinterpret_cast<Persistent<Value>*>(&value), class_id); |
5287 } | 5054 } |
5288 private: | 5055 private: |
5289 PersistentHandleVisitor* visitor_; | 5056 PersistentHandleVisitor* visitor_; |
5290 }; | 5057 }; |
5291 | 5058 |
5292 | 5059 |
5293 void v8::V8::VisitHandlesWithClassIds(PersistentHandleVisitor* visitor) { | 5060 void v8::V8::VisitHandlesWithClassIds(PersistentHandleVisitor* visitor) { |
5294 i::Isolate* isolate = i::Isolate::Current(); | 5061 i::Isolate* isolate = i::Isolate::Current(); |
5295 IsDeadCheck(isolate, "v8::V8::VisitHandlesWithClassId"); | |
5296 | |
5297 i::DisallowHeapAllocation no_allocation; | 5062 i::DisallowHeapAllocation no_allocation; |
5298 | 5063 |
5299 VisitorAdapter visitor_adapter(visitor); | 5064 VisitorAdapter visitor_adapter(visitor); |
5300 isolate->global_handles()->IterateAllRootsWithClassIds(&visitor_adapter); | 5065 isolate->global_handles()->IterateAllRootsWithClassIds(&visitor_adapter); |
5301 } | 5066 } |
5302 | 5067 |
5303 | 5068 |
5304 void v8::V8::VisitHandlesForPartialDependence( | 5069 void v8::V8::VisitHandlesForPartialDependence( |
5305 Isolate* exported_isolate, PersistentHandleVisitor* visitor) { | 5070 Isolate* exported_isolate, PersistentHandleVisitor* visitor) { |
5306 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(exported_isolate); | 5071 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(exported_isolate); |
5307 ASSERT(isolate == i::Isolate::Current()); | 5072 ASSERT(isolate == i::Isolate::Current()); |
5308 IsDeadCheck(isolate, "v8::V8::VisitHandlesForPartialDependence"); | |
5309 | |
5310 i::DisallowHeapAllocation no_allocation; | 5073 i::DisallowHeapAllocation no_allocation; |
5311 | 5074 |
5312 VisitorAdapter visitor_adapter(visitor); | 5075 VisitorAdapter visitor_adapter(visitor); |
5313 isolate->global_handles()->IterateAllRootsInNewSpaceWithClassIds( | 5076 isolate->global_handles()->IterateAllRootsInNewSpaceWithClassIds( |
5314 &visitor_adapter); | 5077 &visitor_adapter); |
5315 } | 5078 } |
5316 | 5079 |
5317 | 5080 |
5318 bool v8::V8::IdleNotification(int hint) { | 5081 bool v8::V8::IdleNotification(int hint) { |
5319 // Returning true tells the caller that it need not | 5082 // Returning true tells the caller that it need not |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5424 i::HandleScope scope(isolate); | 5187 i::HandleScope scope(isolate); |
5425 i::Handle<i::Context> env = | 5188 i::Handle<i::Context> env = |
5426 CreateEnvironment(isolate, extensions, global_template, global_object); | 5189 CreateEnvironment(isolate, extensions, global_template, global_object); |
5427 if (env.is_null()) return Local<Context>(); | 5190 if (env.is_null()) return Local<Context>(); |
5428 return Utils::ToLocal(scope.CloseAndEscape(env)); | 5191 return Utils::ToLocal(scope.CloseAndEscape(env)); |
5429 } | 5192 } |
5430 | 5193 |
5431 | 5194 |
5432 void v8::Context::SetSecurityToken(Handle<Value> token) { | 5195 void v8::Context::SetSecurityToken(Handle<Value> token) { |
5433 i::Isolate* isolate = i::Isolate::Current(); | 5196 i::Isolate* isolate = i::Isolate::Current(); |
5434 if (IsDeadCheck(isolate, "v8::Context::SetSecurityToken()")) { | |
5435 return; | |
5436 } | |
5437 ENTER_V8(isolate); | 5197 ENTER_V8(isolate); |
5438 i::Handle<i::Context> env = Utils::OpenHandle(this); | 5198 i::Handle<i::Context> env = Utils::OpenHandle(this); |
5439 i::Handle<i::Object> token_handle = Utils::OpenHandle(*token); | 5199 i::Handle<i::Object> token_handle = Utils::OpenHandle(*token); |
5440 env->set_security_token(*token_handle); | 5200 env->set_security_token(*token_handle); |
5441 } | 5201 } |
5442 | 5202 |
5443 | 5203 |
5444 void v8::Context::UseDefaultSecurityToken() { | 5204 void v8::Context::UseDefaultSecurityToken() { |
5445 i::Isolate* isolate = i::Isolate::Current(); | 5205 i::Isolate* isolate = i::Isolate::Current(); |
5446 if (IsDeadCheck(isolate, | |
5447 "v8::Context::UseDefaultSecurityToken()")) { | |
5448 return; | |
5449 } | |
5450 ENTER_V8(isolate); | 5206 ENTER_V8(isolate); |
5451 i::Handle<i::Context> env = Utils::OpenHandle(this); | 5207 i::Handle<i::Context> env = Utils::OpenHandle(this); |
5452 env->set_security_token(env->global_object()); | 5208 env->set_security_token(env->global_object()); |
5453 } | 5209 } |
5454 | 5210 |
5455 | 5211 |
5456 Handle<Value> v8::Context::GetSecurityToken() { | 5212 Handle<Value> v8::Context::GetSecurityToken() { |
5457 i::Isolate* isolate = i::Isolate::Current(); | 5213 i::Isolate* isolate = i::Isolate::Current(); |
5458 if (IsDeadCheck(isolate, "v8::Context::GetSecurityToken()")) { | |
5459 return Handle<Value>(); | |
5460 } | |
5461 i::Handle<i::Context> env = Utils::OpenHandle(this); | 5214 i::Handle<i::Context> env = Utils::OpenHandle(this); |
5462 i::Object* security_token = env->security_token(); | 5215 i::Object* security_token = env->security_token(); |
5463 i::Handle<i::Object> token_handle(security_token, isolate); | 5216 i::Handle<i::Object> token_handle(security_token, isolate); |
5464 return Utils::ToLocal(token_handle); | 5217 return Utils::ToLocal(token_handle); |
5465 } | 5218 } |
5466 | 5219 |
5467 | 5220 |
5468 bool Context::HasOutOfMemoryException() { | 5221 bool Context::HasOutOfMemoryException() { |
5469 i::Handle<i::Context> env = Utils::OpenHandle(this); | 5222 i::Handle<i::Context> env = Utils::OpenHandle(this); |
5470 return env->has_out_of_memory(); | 5223 return env->has_out_of_memory(); |
(...skipping 15 matching lines...) Expand all Loading... |
5486 i::Isolate* isolate = i::Isolate::Current(); | 5239 i::Isolate* isolate = i::Isolate::Current(); |
5487 if (!EnsureInitializedForIsolate(isolate, "v8::Context::GetEntered()")) { | 5240 if (!EnsureInitializedForIsolate(isolate, "v8::Context::GetEntered()")) { |
5488 return Local<Context>(); | 5241 return Local<Context>(); |
5489 } | 5242 } |
5490 return reinterpret_cast<Isolate*>(isolate)->GetEnteredContext(); | 5243 return reinterpret_cast<Isolate*>(isolate)->GetEnteredContext(); |
5491 } | 5244 } |
5492 | 5245 |
5493 | 5246 |
5494 v8::Local<v8::Context> Context::GetCurrent() { | 5247 v8::Local<v8::Context> Context::GetCurrent() { |
5495 i::Isolate* isolate = i::Isolate::Current(); | 5248 i::Isolate* isolate = i::Isolate::Current(); |
5496 if (IsDeadCheck(isolate, "v8::Context::GetCurrent()")) { | |
5497 return Local<Context>(); | |
5498 } | |
5499 return reinterpret_cast<Isolate*>(isolate)->GetCurrentContext(); | 5249 return reinterpret_cast<Isolate*>(isolate)->GetCurrentContext(); |
5500 } | 5250 } |
5501 | 5251 |
5502 | 5252 |
5503 v8::Local<v8::Context> Context::GetCalling() { | 5253 v8::Local<v8::Context> Context::GetCalling() { |
5504 i::Isolate* isolate = i::Isolate::Current(); | 5254 i::Isolate* isolate = i::Isolate::Current(); |
5505 if (IsDeadCheck(isolate, "v8::Context::GetCalling()")) { | |
5506 return Local<Context>(); | |
5507 } | |
5508 return reinterpret_cast<Isolate*>(isolate)->GetCallingContext(); | 5255 return reinterpret_cast<Isolate*>(isolate)->GetCallingContext(); |
5509 } | 5256 } |
5510 | 5257 |
5511 | 5258 |
5512 v8::Local<v8::Object> Context::Global() { | 5259 v8::Local<v8::Object> Context::Global() { |
5513 i::Handle<i::Context> context = Utils::OpenHandle(this); | 5260 i::Handle<i::Context> context = Utils::OpenHandle(this); |
5514 i::Isolate* isolate = context->GetIsolate(); | 5261 i::Isolate* isolate = context->GetIsolate(); |
5515 i::Handle<i::Object> global(context->global_proxy(), isolate); | 5262 i::Handle<i::Object> global(context->global_proxy(), isolate); |
5516 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global)); | 5263 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global)); |
5517 } | 5264 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5601 i::Isolate* isolate = i::Isolate::Current(); | 5348 i::Isolate* isolate = i::Isolate::Current(); |
5602 EnsureInitializedForIsolate(isolate, "v8::External::New()"); | 5349 EnsureInitializedForIsolate(isolate, "v8::External::New()"); |
5603 LOG_API(isolate, "External::New"); | 5350 LOG_API(isolate, "External::New"); |
5604 ENTER_V8(isolate); | 5351 ENTER_V8(isolate); |
5605 i::Handle<i::JSObject> external = isolate->factory()->NewExternal(value); | 5352 i::Handle<i::JSObject> external = isolate->factory()->NewExternal(value); |
5606 return Utils::ExternalToLocal(external); | 5353 return Utils::ExternalToLocal(external); |
5607 } | 5354 } |
5608 | 5355 |
5609 | 5356 |
5610 void* External::Value() const { | 5357 void* External::Value() const { |
5611 if (IsDeadCheck(i::Isolate::Current(), "v8::External::Value()")) return NULL; | |
5612 return ExternalValue(*Utils::OpenHandle(this)); | 5358 return ExternalValue(*Utils::OpenHandle(this)); |
5613 } | 5359 } |
5614 | 5360 |
5615 | 5361 |
5616 Local<String> v8::String::Empty() { | 5362 Local<String> v8::String::Empty() { |
5617 i::Isolate* isolate = i::Isolate::Current(); | 5363 i::Isolate* isolate = i::Isolate::Current(); |
5618 if (!EnsureInitializedForIsolate(isolate, "v8::String::Empty()")) { | 5364 if (!EnsureInitializedForIsolate(isolate, "v8::String::Empty()")) { |
5619 return v8::Local<String>(); | 5365 return v8::Local<String>(); |
5620 } | 5366 } |
5621 LOG_API(isolate, "String::Empty()"); | 5367 LOG_API(isolate, "String::Empty()"); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5794 CHECK(resource && resource->data()); | 5540 CHECK(resource && resource->data()); |
5795 i::Handle<i::String> result = NewExternalStringHandle(isolate, resource); | 5541 i::Handle<i::String> result = NewExternalStringHandle(isolate, resource); |
5796 isolate->heap()->external_string_table()->AddString(*result); | 5542 isolate->heap()->external_string_table()->AddString(*result); |
5797 return Utils::ToLocal(result); | 5543 return Utils::ToLocal(result); |
5798 } | 5544 } |
5799 | 5545 |
5800 | 5546 |
5801 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { | 5547 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { |
5802 i::Handle<i::String> obj = Utils::OpenHandle(this); | 5548 i::Handle<i::String> obj = Utils::OpenHandle(this); |
5803 i::Isolate* isolate = obj->GetIsolate(); | 5549 i::Isolate* isolate = obj->GetIsolate(); |
5804 if (IsDeadCheck(isolate, "v8::String::MakeExternal()")) return false; | |
5805 if (i::StringShape(*obj).IsExternalTwoByte()) { | 5550 if (i::StringShape(*obj).IsExternalTwoByte()) { |
5806 return false; // Already an external string. | 5551 return false; // Already an external string. |
5807 } | 5552 } |
5808 ENTER_V8(isolate); | 5553 ENTER_V8(isolate); |
5809 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { | 5554 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { |
5810 return false; | 5555 return false; |
5811 } | 5556 } |
5812 if (isolate->heap()->IsInGCPostProcessing()) { | 5557 if (isolate->heap()->IsInGCPostProcessing()) { |
5813 return false; | 5558 return false; |
5814 } | 5559 } |
(...skipping 30 matching lines...) Expand all Loading... |
5845 i::Handle<i::String> result = NewExternalAsciiStringHandle(isolate, resource); | 5590 i::Handle<i::String> result = NewExternalAsciiStringHandle(isolate, resource); |
5846 isolate->heap()->external_string_table()->AddString(*result); | 5591 isolate->heap()->external_string_table()->AddString(*result); |
5847 return Utils::ToLocal(result); | 5592 return Utils::ToLocal(result); |
5848 } | 5593 } |
5849 | 5594 |
5850 | 5595 |
5851 bool v8::String::MakeExternal( | 5596 bool v8::String::MakeExternal( |
5852 v8::String::ExternalAsciiStringResource* resource) { | 5597 v8::String::ExternalAsciiStringResource* resource) { |
5853 i::Handle<i::String> obj = Utils::OpenHandle(this); | 5598 i::Handle<i::String> obj = Utils::OpenHandle(this); |
5854 i::Isolate* isolate = obj->GetIsolate(); | 5599 i::Isolate* isolate = obj->GetIsolate(); |
5855 if (IsDeadCheck(isolate, "v8::String::MakeExternal()")) return false; | |
5856 if (i::StringShape(*obj).IsExternalTwoByte()) { | 5600 if (i::StringShape(*obj).IsExternalTwoByte()) { |
5857 return false; // Already an external string. | 5601 return false; // Already an external string. |
5858 } | 5602 } |
5859 ENTER_V8(isolate); | 5603 ENTER_V8(isolate); |
5860 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { | 5604 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { |
5861 return false; | 5605 return false; |
5862 } | 5606 } |
5863 if (isolate->heap()->IsInGCPostProcessing()) { | 5607 if (isolate->heap()->IsInGCPostProcessing()) { |
5864 return false; | 5608 return false; |
5865 } | 5609 } |
(...skipping 17 matching lines...) Expand all Loading... |
5883 isolate->heap()->external_string_table()->AddString(*external); | 5627 isolate->heap()->external_string_table()->AddString(*external); |
5884 } | 5628 } |
5885 return result; | 5629 return result; |
5886 } | 5630 } |
5887 | 5631 |
5888 | 5632 |
5889 bool v8::String::CanMakeExternal() { | 5633 bool v8::String::CanMakeExternal() { |
5890 if (!internal::FLAG_clever_optimizations) return false; | 5634 if (!internal::FLAG_clever_optimizations) return false; |
5891 i::Handle<i::String> obj = Utils::OpenHandle(this); | 5635 i::Handle<i::String> obj = Utils::OpenHandle(this); |
5892 i::Isolate* isolate = obj->GetIsolate(); | 5636 i::Isolate* isolate = obj->GetIsolate(); |
5893 if (IsDeadCheck(isolate, "v8::String::CanMakeExternal()")) return false; | |
5894 if (isolate->string_tracker()->IsFreshUnusedString(obj)) return false; | 5637 if (isolate->string_tracker()->IsFreshUnusedString(obj)) return false; |
5895 int size = obj->Size(); // Byte size of the original string. | 5638 int size = obj->Size(); // Byte size of the original string. |
5896 if (size < i::ExternalString::kShortSize) return false; | 5639 if (size < i::ExternalString::kShortSize) return false; |
5897 i::StringShape shape(*obj); | 5640 i::StringShape shape(*obj); |
5898 return !shape.IsExternal(); | 5641 return !shape.IsExternal(); |
5899 } | 5642 } |
5900 | 5643 |
5901 | 5644 |
5902 Local<v8::Object> v8::Object::New() { | 5645 Local<v8::Object> v8::Object::New() { |
5903 i::Isolate* isolate = i::Isolate::Current(); | 5646 i::Isolate* isolate = i::Isolate::Current(); |
(...skipping 12 matching lines...) Expand all Loading... |
5916 LOG_API(isolate, "NumberObject::New"); | 5659 LOG_API(isolate, "NumberObject::New"); |
5917 ENTER_V8(isolate); | 5660 ENTER_V8(isolate); |
5918 i::Handle<i::Object> number = isolate->factory()->NewNumber(value); | 5661 i::Handle<i::Object> number = isolate->factory()->NewNumber(value); |
5919 i::Handle<i::Object> obj = isolate->factory()->ToObject(number); | 5662 i::Handle<i::Object> obj = isolate->factory()->ToObject(number); |
5920 return Utils::ToLocal(obj); | 5663 return Utils::ToLocal(obj); |
5921 } | 5664 } |
5922 | 5665 |
5923 | 5666 |
5924 double v8::NumberObject::ValueOf() const { | 5667 double v8::NumberObject::ValueOf() const { |
5925 i::Isolate* isolate = i::Isolate::Current(); | 5668 i::Isolate* isolate = i::Isolate::Current(); |
5926 if (IsDeadCheck(isolate, "v8::NumberObject::NumberValue()")) return 0; | |
5927 LOG_API(isolate, "NumberObject::NumberValue"); | 5669 LOG_API(isolate, "NumberObject::NumberValue"); |
5928 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 5670 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
5929 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 5671 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
5930 return jsvalue->value()->Number(); | 5672 return jsvalue->value()->Number(); |
5931 } | 5673 } |
5932 | 5674 |
5933 | 5675 |
5934 Local<v8::Value> v8::BooleanObject::New(bool value) { | 5676 Local<v8::Value> v8::BooleanObject::New(bool value) { |
5935 i::Isolate* isolate = i::Isolate::Current(); | 5677 i::Isolate* isolate = i::Isolate::Current(); |
5936 EnsureInitializedForIsolate(isolate, "v8::BooleanObject::New()"); | 5678 EnsureInitializedForIsolate(isolate, "v8::BooleanObject::New()"); |
5937 LOG_API(isolate, "BooleanObject::New"); | 5679 LOG_API(isolate, "BooleanObject::New"); |
5938 ENTER_V8(isolate); | 5680 ENTER_V8(isolate); |
5939 i::Handle<i::Object> boolean(value | 5681 i::Handle<i::Object> boolean(value |
5940 ? isolate->heap()->true_value() | 5682 ? isolate->heap()->true_value() |
5941 : isolate->heap()->false_value(), | 5683 : isolate->heap()->false_value(), |
5942 isolate); | 5684 isolate); |
5943 i::Handle<i::Object> obj = isolate->factory()->ToObject(boolean); | 5685 i::Handle<i::Object> obj = isolate->factory()->ToObject(boolean); |
5944 return Utils::ToLocal(obj); | 5686 return Utils::ToLocal(obj); |
5945 } | 5687 } |
5946 | 5688 |
5947 | 5689 |
5948 bool v8::BooleanObject::ValueOf() const { | 5690 bool v8::BooleanObject::ValueOf() const { |
5949 i::Isolate* isolate = i::Isolate::Current(); | 5691 i::Isolate* isolate = i::Isolate::Current(); |
5950 if (IsDeadCheck(isolate, "v8::BooleanObject::BooleanValue()")) return 0; | |
5951 LOG_API(isolate, "BooleanObject::BooleanValue"); | 5692 LOG_API(isolate, "BooleanObject::BooleanValue"); |
5952 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 5693 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
5953 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 5694 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
5954 return jsvalue->value()->IsTrue(); | 5695 return jsvalue->value()->IsTrue(); |
5955 } | 5696 } |
5956 | 5697 |
5957 | 5698 |
5958 Local<v8::Value> v8::StringObject::New(Handle<String> value) { | 5699 Local<v8::Value> v8::StringObject::New(Handle<String> value) { |
5959 i::Isolate* isolate = i::Isolate::Current(); | 5700 i::Isolate* isolate = i::Isolate::Current(); |
5960 EnsureInitializedForIsolate(isolate, "v8::StringObject::New()"); | 5701 EnsureInitializedForIsolate(isolate, "v8::StringObject::New()"); |
5961 LOG_API(isolate, "StringObject::New"); | 5702 LOG_API(isolate, "StringObject::New"); |
5962 ENTER_V8(isolate); | 5703 ENTER_V8(isolate); |
5963 i::Handle<i::Object> obj = | 5704 i::Handle<i::Object> obj = |
5964 isolate->factory()->ToObject(Utils::OpenHandle(*value)); | 5705 isolate->factory()->ToObject(Utils::OpenHandle(*value)); |
5965 return Utils::ToLocal(obj); | 5706 return Utils::ToLocal(obj); |
5966 } | 5707 } |
5967 | 5708 |
5968 | 5709 |
5969 Local<v8::String> v8::StringObject::ValueOf() const { | 5710 Local<v8::String> v8::StringObject::ValueOf() const { |
5970 i::Isolate* isolate = i::Isolate::Current(); | 5711 i::Isolate* isolate = i::Isolate::Current(); |
5971 if (IsDeadCheck(isolate, "v8::StringObject::StringValue()")) { | |
5972 return Local<v8::String>(); | |
5973 } | |
5974 LOG_API(isolate, "StringObject::StringValue"); | 5712 LOG_API(isolate, "StringObject::StringValue"); |
5975 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 5713 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
5976 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 5714 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
5977 return Utils::ToLocal( | 5715 return Utils::ToLocal( |
5978 i::Handle<i::String>(i::String::cast(jsvalue->value()))); | 5716 i::Handle<i::String>(i::String::cast(jsvalue->value()))); |
5979 } | 5717 } |
5980 | 5718 |
5981 | 5719 |
5982 Local<v8::Value> v8::SymbolObject::New(Isolate* isolate, Handle<Symbol> value) { | 5720 Local<v8::Value> v8::SymbolObject::New(Isolate* isolate, Handle<Symbol> value) { |
5983 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 5721 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
5984 EnsureInitializedForIsolate(i_isolate, "v8::SymbolObject::New()"); | 5722 EnsureInitializedForIsolate(i_isolate, "v8::SymbolObject::New()"); |
5985 LOG_API(i_isolate, "SymbolObject::New"); | 5723 LOG_API(i_isolate, "SymbolObject::New"); |
5986 ENTER_V8(i_isolate); | 5724 ENTER_V8(i_isolate); |
5987 i::Handle<i::Object> obj = | 5725 i::Handle<i::Object> obj = |
5988 i_isolate->factory()->ToObject(Utils::OpenHandle(*value)); | 5726 i_isolate->factory()->ToObject(Utils::OpenHandle(*value)); |
5989 return Utils::ToLocal(obj); | 5727 return Utils::ToLocal(obj); |
5990 } | 5728 } |
5991 | 5729 |
5992 | 5730 |
5993 Local<v8::Symbol> v8::SymbolObject::ValueOf() const { | 5731 Local<v8::Symbol> v8::SymbolObject::ValueOf() const { |
5994 i::Isolate* isolate = i::Isolate::Current(); | 5732 i::Isolate* isolate = i::Isolate::Current(); |
5995 if (IsDeadCheck(isolate, "v8::SymbolObject::SymbolValue()")) | |
5996 return Local<v8::Symbol>(); | |
5997 LOG_API(isolate, "SymbolObject::SymbolValue"); | 5733 LOG_API(isolate, "SymbolObject::SymbolValue"); |
5998 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 5734 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
5999 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 5735 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
6000 return Utils::ToLocal( | 5736 return Utils::ToLocal( |
6001 i::Handle<i::Symbol>(i::Symbol::cast(jsvalue->value()))); | 5737 i::Handle<i::Symbol>(i::Symbol::cast(jsvalue->value()))); |
6002 } | 5738 } |
6003 | 5739 |
6004 | 5740 |
6005 Local<v8::Value> v8::Date::New(double time) { | 5741 Local<v8::Value> v8::Date::New(double time) { |
6006 i::Isolate* isolate = i::Isolate::Current(); | 5742 i::Isolate* isolate = i::Isolate::Current(); |
6007 EnsureInitializedForIsolate(isolate, "v8::Date::New()"); | 5743 EnsureInitializedForIsolate(isolate, "v8::Date::New()"); |
6008 LOG_API(isolate, "Date::New"); | 5744 LOG_API(isolate, "Date::New"); |
6009 if (std::isnan(time)) { | 5745 if (std::isnan(time)) { |
6010 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. | 5746 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. |
6011 time = i::OS::nan_value(); | 5747 time = i::OS::nan_value(); |
6012 } | 5748 } |
6013 ENTER_V8(isolate); | 5749 ENTER_V8(isolate); |
6014 EXCEPTION_PREAMBLE(isolate); | 5750 EXCEPTION_PREAMBLE(isolate); |
6015 i::Handle<i::Object> obj = | 5751 i::Handle<i::Object> obj = |
6016 i::Execution::NewDate(isolate, time, &has_pending_exception); | 5752 i::Execution::NewDate(isolate, time, &has_pending_exception); |
6017 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Value>()); | 5753 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Value>()); |
6018 return Utils::ToLocal(obj); | 5754 return Utils::ToLocal(obj); |
6019 } | 5755 } |
6020 | 5756 |
6021 | 5757 |
6022 double v8::Date::ValueOf() const { | 5758 double v8::Date::ValueOf() const { |
6023 i::Isolate* isolate = i::Isolate::Current(); | 5759 i::Isolate* isolate = i::Isolate::Current(); |
6024 if (IsDeadCheck(isolate, "v8::Date::NumberValue()")) return 0; | |
6025 LOG_API(isolate, "Date::NumberValue"); | 5760 LOG_API(isolate, "Date::NumberValue"); |
6026 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 5761 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
6027 i::Handle<i::JSDate> jsdate = i::Handle<i::JSDate>::cast(obj); | 5762 i::Handle<i::JSDate> jsdate = i::Handle<i::JSDate>::cast(obj); |
6028 return jsdate->value()->Number(); | 5763 return jsdate->value()->Number(); |
6029 } | 5764 } |
6030 | 5765 |
6031 | 5766 |
6032 void v8::Date::DateTimeConfigurationChangeNotification() { | 5767 void v8::Date::DateTimeConfigurationChangeNotification() { |
6033 i::Isolate* isolate = i::Isolate::Current(); | 5768 i::Isolate* isolate = i::Isolate::Current(); |
6034 ON_BAILOUT(isolate, "v8::Date::DateTimeConfigurationChangeNotification()", | 5769 ON_BAILOUT(isolate, "v8::Date::DateTimeConfigurationChangeNotification()", |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6088 i::Handle<i::JSRegExp> obj = i::Execution::NewJSRegExp( | 5823 i::Handle<i::JSRegExp> obj = i::Execution::NewJSRegExp( |
6089 Utils::OpenHandle(*pattern), | 5824 Utils::OpenHandle(*pattern), |
6090 RegExpFlagsToString(flags), | 5825 RegExpFlagsToString(flags), |
6091 &has_pending_exception); | 5826 &has_pending_exception); |
6092 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::RegExp>()); | 5827 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::RegExp>()); |
6093 return Utils::ToLocal(i::Handle<i::JSRegExp>::cast(obj)); | 5828 return Utils::ToLocal(i::Handle<i::JSRegExp>::cast(obj)); |
6094 } | 5829 } |
6095 | 5830 |
6096 | 5831 |
6097 Local<v8::String> v8::RegExp::GetSource() const { | 5832 Local<v8::String> v8::RegExp::GetSource() const { |
6098 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | |
6099 if (IsDeadCheck(isolate, "v8::RegExp::GetSource()")) { | |
6100 return Local<v8::String>(); | |
6101 } | |
6102 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); | 5833 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); |
6103 return Utils::ToLocal(i::Handle<i::String>(obj->Pattern())); | 5834 return Utils::ToLocal(i::Handle<i::String>(obj->Pattern())); |
6104 } | 5835 } |
6105 | 5836 |
6106 | 5837 |
6107 // Assert that the static flags cast in GetFlags is valid. | 5838 // Assert that the static flags cast in GetFlags is valid. |
6108 #define REGEXP_FLAG_ASSERT_EQ(api_flag, internal_flag) \ | 5839 #define REGEXP_FLAG_ASSERT_EQ(api_flag, internal_flag) \ |
6109 STATIC_ASSERT(static_cast<int>(v8::RegExp::api_flag) == \ | 5840 STATIC_ASSERT(static_cast<int>(v8::RegExp::api_flag) == \ |
6110 static_cast<int>(i::JSRegExp::internal_flag)) | 5841 static_cast<int>(i::JSRegExp::internal_flag)) |
6111 REGEXP_FLAG_ASSERT_EQ(kNone, NONE); | 5842 REGEXP_FLAG_ASSERT_EQ(kNone, NONE); |
6112 REGEXP_FLAG_ASSERT_EQ(kGlobal, GLOBAL); | 5843 REGEXP_FLAG_ASSERT_EQ(kGlobal, GLOBAL); |
6113 REGEXP_FLAG_ASSERT_EQ(kIgnoreCase, IGNORE_CASE); | 5844 REGEXP_FLAG_ASSERT_EQ(kIgnoreCase, IGNORE_CASE); |
6114 REGEXP_FLAG_ASSERT_EQ(kMultiline, MULTILINE); | 5845 REGEXP_FLAG_ASSERT_EQ(kMultiline, MULTILINE); |
6115 #undef REGEXP_FLAG_ASSERT_EQ | 5846 #undef REGEXP_FLAG_ASSERT_EQ |
6116 | 5847 |
6117 v8::RegExp::Flags v8::RegExp::GetFlags() const { | 5848 v8::RegExp::Flags v8::RegExp::GetFlags() const { |
6118 if (IsDeadCheck(i::Isolate::Current(), "v8::RegExp::GetFlags()")) { | |
6119 return v8::RegExp::kNone; | |
6120 } | |
6121 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); | 5849 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); |
6122 return static_cast<RegExp::Flags>(obj->GetFlags().value()); | 5850 return static_cast<RegExp::Flags>(obj->GetFlags().value()); |
6123 } | 5851 } |
6124 | 5852 |
6125 | 5853 |
6126 Local<v8::Array> v8::Array::New(int length) { | 5854 Local<v8::Array> v8::Array::New(int length) { |
6127 i::Isolate* isolate = i::Isolate::Current(); | 5855 i::Isolate* isolate = i::Isolate::Current(); |
6128 EnsureInitializedForIsolate(isolate, "v8::Array::New()"); | 5856 EnsureInitializedForIsolate(isolate, "v8::Array::New()"); |
6129 LOG_API(isolate, "Array::New"); | 5857 LOG_API(isolate, "Array::New"); |
6130 ENTER_V8(isolate); | 5858 ENTER_V8(isolate); |
6131 int real_length = length > 0 ? length : 0; | 5859 int real_length = length > 0 ? length : 0; |
6132 i::Handle<i::JSArray> obj = isolate->factory()->NewJSArray(real_length); | 5860 i::Handle<i::JSArray> obj = isolate->factory()->NewJSArray(real_length); |
6133 i::Handle<i::Object> length_obj = | 5861 i::Handle<i::Object> length_obj = |
6134 isolate->factory()->NewNumberFromInt(real_length); | 5862 isolate->factory()->NewNumberFromInt(real_length); |
6135 obj->set_length(*length_obj); | 5863 obj->set_length(*length_obj); |
6136 return Utils::ToLocal(obj); | 5864 return Utils::ToLocal(obj); |
6137 } | 5865 } |
6138 | 5866 |
6139 | 5867 |
6140 uint32_t v8::Array::Length() const { | 5868 uint32_t v8::Array::Length() const { |
6141 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | |
6142 if (IsDeadCheck(isolate, "v8::Array::Length()")) return 0; | |
6143 i::Handle<i::JSArray> obj = Utils::OpenHandle(this); | 5869 i::Handle<i::JSArray> obj = Utils::OpenHandle(this); |
6144 i::Object* length = obj->length(); | 5870 i::Object* length = obj->length(); |
6145 if (length->IsSmi()) { | 5871 if (length->IsSmi()) { |
6146 return i::Smi::cast(length)->value(); | 5872 return i::Smi::cast(length)->value(); |
6147 } else { | 5873 } else { |
6148 return static_cast<uint32_t>(length->Number()); | 5874 return static_cast<uint32_t>(length->Number()); |
6149 } | 5875 } |
6150 } | 5876 } |
6151 | 5877 |
6152 | 5878 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6210 } else { | 5936 } else { |
6211 UNREACHABLE(); | 5937 UNREACHABLE(); |
6212 } | 5938 } |
6213 view_obj = i::handle(view->weak_next(), isolate); | 5939 view_obj = i::handle(view->weak_next(), isolate); |
6214 } | 5940 } |
6215 obj->Neuter(); | 5941 obj->Neuter(); |
6216 } | 5942 } |
6217 | 5943 |
6218 | 5944 |
6219 size_t v8::ArrayBuffer::ByteLength() const { | 5945 size_t v8::ArrayBuffer::ByteLength() const { |
6220 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | |
6221 if (IsDeadCheck(isolate, "v8::ArrayBuffer::ByteLength()")) return 0; | |
6222 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); | 5946 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); |
6223 return static_cast<size_t>(obj->byte_length()->Number()); | 5947 return static_cast<size_t>(obj->byte_length()->Number()); |
6224 } | 5948 } |
6225 | 5949 |
6226 | 5950 |
6227 Local<ArrayBuffer> v8::ArrayBuffer::New(size_t byte_length) { | 5951 Local<ArrayBuffer> v8::ArrayBuffer::New(size_t byte_length) { |
6228 i::Isolate* isolate = i::Isolate::Current(); | 5952 i::Isolate* isolate = i::Isolate::Current(); |
6229 EnsureInitializedForIsolate(isolate, "v8::ArrayBuffer::New(size_t)"); | 5953 EnsureInitializedForIsolate(isolate, "v8::ArrayBuffer::New(size_t)"); |
6230 LOG_API(isolate, "v8::ArrayBuffer::New(size_t)"); | 5954 LOG_API(isolate, "v8::ArrayBuffer::New(size_t)"); |
6231 ENTER_V8(isolate); | 5955 ENTER_V8(isolate); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6271 void* v8::ArrayBufferView::BaseAddress() { | 5995 void* v8::ArrayBufferView::BaseAddress() { |
6272 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); | 5996 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); |
6273 i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(obj->buffer())); | 5997 i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(obj->buffer())); |
6274 void* buffer_data = buffer->backing_store(); | 5998 void* buffer_data = buffer->backing_store(); |
6275 size_t byte_offset = static_cast<size_t>(obj->byte_offset()->Number()); | 5999 size_t byte_offset = static_cast<size_t>(obj->byte_offset()->Number()); |
6276 return static_cast<uint8_t*>(buffer_data) + byte_offset; | 6000 return static_cast<uint8_t*>(buffer_data) + byte_offset; |
6277 } | 6001 } |
6278 | 6002 |
6279 | 6003 |
6280 size_t v8::TypedArray::Length() { | 6004 size_t v8::TypedArray::Length() { |
6281 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | |
6282 if (IsDeadCheck(isolate, "v8::TypedArray::Length()")) return 0; | |
6283 i::Handle<i::JSTypedArray> obj = Utils::OpenHandle(this); | 6005 i::Handle<i::JSTypedArray> obj = Utils::OpenHandle(this); |
6284 return static_cast<size_t>(obj->length()->Number()); | 6006 return static_cast<size_t>(obj->length()->Number()); |
6285 } | 6007 } |
6286 | 6008 |
6287 | 6009 |
6288 static inline void SetupArrayBufferView( | 6010 static inline void SetupArrayBufferView( |
6289 i::Isolate* isolate, | 6011 i::Isolate* isolate, |
6290 i::Handle<i::JSArrayBufferView> obj, | 6012 i::Handle<i::JSArrayBufferView> obj, |
6291 i::Handle<i::JSArrayBuffer> buffer, | 6013 i::Handle<i::JSArrayBuffer> buffer, |
6292 size_t byte_offset, | 6014 size_t byte_offset, |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6530 StackTrace::StackTraceOptions options) { | 6252 StackTrace::StackTraceOptions options) { |
6531 i::Isolate::Current()->SetCaptureStackTraceForUncaughtExceptions( | 6253 i::Isolate::Current()->SetCaptureStackTraceForUncaughtExceptions( |
6532 capture, | 6254 capture, |
6533 frame_limit, | 6255 frame_limit, |
6534 options); | 6256 options); |
6535 } | 6257 } |
6536 | 6258 |
6537 | 6259 |
6538 void V8::SetCounterFunction(CounterLookupCallback callback) { | 6260 void V8::SetCounterFunction(CounterLookupCallback callback) { |
6539 i::Isolate* isolate = EnterIsolateIfNeeded(); | 6261 i::Isolate* isolate = EnterIsolateIfNeeded(); |
6540 if (IsDeadCheck(isolate, "v8::V8::SetCounterFunction()")) return; | |
6541 isolate->stats_table()->SetCounterFunction(callback); | 6262 isolate->stats_table()->SetCounterFunction(callback); |
6542 } | 6263 } |
6543 | 6264 |
6544 | 6265 |
6545 void V8::SetCreateHistogramFunction(CreateHistogramCallback callback) { | 6266 void V8::SetCreateHistogramFunction(CreateHistogramCallback callback) { |
6546 i::Isolate* isolate = EnterIsolateIfNeeded(); | 6267 i::Isolate* isolate = EnterIsolateIfNeeded(); |
6547 if (IsDeadCheck(isolate, "v8::V8::SetCreateHistogramFunction()")) return; | |
6548 isolate->stats_table()->SetCreateHistogramFunction(callback); | 6268 isolate->stats_table()->SetCreateHistogramFunction(callback); |
6549 isolate->InitializeLoggingAndCounters(); | 6269 isolate->InitializeLoggingAndCounters(); |
6550 isolate->counters()->ResetHistograms(); | 6270 isolate->counters()->ResetHistograms(); |
6551 } | 6271 } |
6552 | 6272 |
6553 | 6273 |
6554 void V8::SetAddHistogramSampleFunction(AddHistogramSampleCallback callback) { | 6274 void V8::SetAddHistogramSampleFunction(AddHistogramSampleCallback callback) { |
6555 i::Isolate* isolate = EnterIsolateIfNeeded(); | 6275 i::Isolate* isolate = EnterIsolateIfNeeded(); |
6556 if (IsDeadCheck(isolate, "v8::V8::SetAddHistogramSampleFunction()")) return; | |
6557 isolate->stats_table()-> | 6276 isolate->stats_table()-> |
6558 SetAddHistogramSampleFunction(callback); | 6277 SetAddHistogramSampleFunction(callback); |
6559 } | 6278 } |
6560 | 6279 |
6561 void V8::SetFailedAccessCheckCallbackFunction( | 6280 void V8::SetFailedAccessCheckCallbackFunction( |
6562 FailedAccessCheckCallback callback) { | 6281 FailedAccessCheckCallback callback) { |
6563 i::Isolate* isolate = i::Isolate::Current(); | 6282 i::Isolate* isolate = i::Isolate::Current(); |
6564 if (IsDeadCheck(isolate, "v8::V8::SetFailedAccessCheckCallbackFunction()")) { | |
6565 return; | |
6566 } | |
6567 isolate->SetFailedAccessCheckCallback(callback); | 6283 isolate->SetFailedAccessCheckCallback(callback); |
6568 } | 6284 } |
6569 | 6285 |
6570 | 6286 |
6571 intptr_t Isolate::AdjustAmountOfExternalAllocatedMemory( | 6287 intptr_t Isolate::AdjustAmountOfExternalAllocatedMemory( |
6572 intptr_t change_in_bytes) { | 6288 intptr_t change_in_bytes) { |
6573 i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap(); | 6289 i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap(); |
6574 return heap->AdjustAmountOfExternalAllocatedMemory(change_in_bytes); | 6290 return heap->AdjustAmountOfExternalAllocatedMemory(change_in_bytes); |
6575 } | 6291 } |
6576 | 6292 |
6577 | 6293 |
6578 intptr_t V8::AdjustAmountOfExternalAllocatedMemory(intptr_t change_in_bytes) { | 6294 intptr_t V8::AdjustAmountOfExternalAllocatedMemory(intptr_t change_in_bytes) { |
6579 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); | 6295 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); |
6580 if (isolate == NULL || !isolate->IsInitialized() || | 6296 if (isolate == NULL || !isolate->IsInitialized()) { |
6581 IsDeadCheck(isolate, "v8::V8::AdjustAmountOfExternalAllocatedMemory()")) { | |
6582 return 0; | 6297 return 0; |
6583 } | 6298 } |
6584 Isolate* isolate_ext = reinterpret_cast<Isolate*>(isolate); | 6299 Isolate* isolate_ext = reinterpret_cast<Isolate*>(isolate); |
6585 return isolate_ext->AdjustAmountOfExternalAllocatedMemory(change_in_bytes); | 6300 return isolate_ext->AdjustAmountOfExternalAllocatedMemory(change_in_bytes); |
6586 } | 6301 } |
6587 | 6302 |
6588 | 6303 |
6589 HeapProfiler* Isolate::GetHeapProfiler() { | 6304 HeapProfiler* Isolate::GetHeapProfiler() { |
6590 i::HeapProfiler* heap_profiler = | 6305 i::HeapProfiler* heap_profiler = |
6591 reinterpret_cast<i::Isolate*>(this)->heap_profiler(); | 6306 reinterpret_cast<i::Isolate*>(this)->heap_profiler(); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6682 | 6397 |
6683 | 6398 |
6684 void Isolate::RemoveGCEpilogueCallback(GCEpilogueCallback callback) { | 6399 void Isolate::RemoveGCEpilogueCallback(GCEpilogueCallback callback) { |
6685 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 6400 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
6686 isolate->heap()->RemoveGCEpilogueCallback(callback); | 6401 isolate->heap()->RemoveGCEpilogueCallback(callback); |
6687 } | 6402 } |
6688 | 6403 |
6689 | 6404 |
6690 void V8::AddGCPrologueCallback(GCPrologueCallback callback, GCType gc_type) { | 6405 void V8::AddGCPrologueCallback(GCPrologueCallback callback, GCType gc_type) { |
6691 i::Isolate* isolate = i::Isolate::Current(); | 6406 i::Isolate* isolate = i::Isolate::Current(); |
6692 if (IsDeadCheck(isolate, "v8::V8::AddGCPrologueCallback()")) return; | |
6693 isolate->heap()->AddGCPrologueCallback( | 6407 isolate->heap()->AddGCPrologueCallback( |
6694 reinterpret_cast<v8::Isolate::GCPrologueCallback>(callback), | 6408 reinterpret_cast<v8::Isolate::GCPrologueCallback>(callback), |
6695 gc_type, | 6409 gc_type, |
6696 false); | 6410 false); |
6697 } | 6411 } |
6698 | 6412 |
6699 | 6413 |
6700 void V8::RemoveGCPrologueCallback(GCPrologueCallback callback) { | 6414 void V8::RemoveGCPrologueCallback(GCPrologueCallback callback) { |
6701 i::Isolate* isolate = i::Isolate::Current(); | 6415 i::Isolate* isolate = i::Isolate::Current(); |
6702 if (IsDeadCheck(isolate, "v8::V8::RemoveGCPrologueCallback()")) return; | |
6703 isolate->heap()->RemoveGCPrologueCallback( | 6416 isolate->heap()->RemoveGCPrologueCallback( |
6704 reinterpret_cast<v8::Isolate::GCPrologueCallback>(callback)); | 6417 reinterpret_cast<v8::Isolate::GCPrologueCallback>(callback)); |
6705 } | 6418 } |
6706 | 6419 |
6707 | 6420 |
6708 void V8::AddGCEpilogueCallback(GCEpilogueCallback callback, GCType gc_type) { | 6421 void V8::AddGCEpilogueCallback(GCEpilogueCallback callback, GCType gc_type) { |
6709 i::Isolate* isolate = i::Isolate::Current(); | 6422 i::Isolate* isolate = i::Isolate::Current(); |
6710 if (IsDeadCheck(isolate, "v8::V8::AddGCEpilogueCallback()")) return; | |
6711 isolate->heap()->AddGCEpilogueCallback( | 6423 isolate->heap()->AddGCEpilogueCallback( |
6712 reinterpret_cast<v8::Isolate::GCEpilogueCallback>(callback), | 6424 reinterpret_cast<v8::Isolate::GCEpilogueCallback>(callback), |
6713 gc_type, | 6425 gc_type, |
6714 false); | 6426 false); |
6715 } | 6427 } |
6716 | 6428 |
6717 | 6429 |
6718 void V8::RemoveGCEpilogueCallback(GCEpilogueCallback callback) { | 6430 void V8::RemoveGCEpilogueCallback(GCEpilogueCallback callback) { |
6719 i::Isolate* isolate = i::Isolate::Current(); | 6431 i::Isolate* isolate = i::Isolate::Current(); |
6720 if (IsDeadCheck(isolate, "v8::V8::RemoveGCEpilogueCallback()")) return; | |
6721 isolate->heap()->RemoveGCEpilogueCallback( | 6432 isolate->heap()->RemoveGCEpilogueCallback( |
6722 reinterpret_cast<v8::Isolate::GCEpilogueCallback>(callback)); | 6433 reinterpret_cast<v8::Isolate::GCEpilogueCallback>(callback)); |
6723 } | 6434 } |
6724 | 6435 |
6725 | 6436 |
6726 void V8::AddMemoryAllocationCallback(MemoryAllocationCallback callback, | 6437 void V8::AddMemoryAllocationCallback(MemoryAllocationCallback callback, |
6727 ObjectSpace space, | 6438 ObjectSpace space, |
6728 AllocationAction action) { | 6439 AllocationAction action) { |
6729 i::Isolate* isolate = i::Isolate::Current(); | 6440 i::Isolate* isolate = i::Isolate::Current(); |
6730 if (IsDeadCheck(isolate, "v8::V8::AddMemoryAllocationCallback()")) return; | |
6731 isolate->memory_allocator()->AddMemoryAllocationCallback( | 6441 isolate->memory_allocator()->AddMemoryAllocationCallback( |
6732 callback, space, action); | 6442 callback, space, action); |
6733 } | 6443 } |
6734 | 6444 |
6735 | 6445 |
6736 void V8::RemoveMemoryAllocationCallback(MemoryAllocationCallback callback) { | 6446 void V8::RemoveMemoryAllocationCallback(MemoryAllocationCallback callback) { |
6737 i::Isolate* isolate = i::Isolate::Current(); | 6447 i::Isolate* isolate = i::Isolate::Current(); |
6738 if (IsDeadCheck(isolate, "v8::V8::RemoveMemoryAllocationCallback()")) return; | |
6739 isolate->memory_allocator()->RemoveMemoryAllocationCallback( | 6448 isolate->memory_allocator()->RemoveMemoryAllocationCallback( |
6740 callback); | 6449 callback); |
6741 } | 6450 } |
6742 | 6451 |
6743 | 6452 |
6744 void V8::AddCallCompletedCallback(CallCompletedCallback callback) { | 6453 void V8::AddCallCompletedCallback(CallCompletedCallback callback) { |
6745 if (callback == NULL) return; | 6454 if (callback == NULL) return; |
6746 i::Isolate* isolate = i::Isolate::Current(); | |
6747 if (IsDeadCheck(isolate, "v8::V8::AddLeaveScriptCallback()")) return; | |
6748 i::V8::AddCallCompletedCallback(callback); | 6455 i::V8::AddCallCompletedCallback(callback); |
6749 } | 6456 } |
6750 | 6457 |
6751 | 6458 |
6752 void V8::RemoveCallCompletedCallback(CallCompletedCallback callback) { | 6459 void V8::RemoveCallCompletedCallback(CallCompletedCallback callback) { |
6753 i::Isolate* isolate = i::Isolate::Current(); | |
6754 if (IsDeadCheck(isolate, "v8::V8::RemoveLeaveScriptCallback()")) return; | |
6755 i::V8::RemoveCallCompletedCallback(callback); | 6460 i::V8::RemoveCallCompletedCallback(callback); |
6756 } | 6461 } |
6757 | 6462 |
6758 | 6463 |
6759 void V8::TerminateExecution(Isolate* isolate) { | 6464 void V8::TerminateExecution(Isolate* isolate) { |
6760 // If no isolate is supplied, use the default isolate. | 6465 // If no isolate is supplied, use the default isolate. |
6761 if (isolate != NULL) { | 6466 if (isolate != NULL) { |
6762 reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->TerminateExecution(); | 6467 reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->TerminateExecution(); |
6763 } else { | 6468 } else { |
6764 i::Isolate::GetDefaultIsolateStackGuard()->TerminateExecution(); | 6469 i::Isolate::GetDefaultIsolateStackGuard()->TerminateExecution(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6830 heap->CommittedMemoryExecutable(); | 6535 heap->CommittedMemoryExecutable(); |
6831 heap_statistics->total_physical_size_ = heap->CommittedPhysicalMemory(); | 6536 heap_statistics->total_physical_size_ = heap->CommittedPhysicalMemory(); |
6832 heap_statistics->used_heap_size_ = heap->SizeOfObjects(); | 6537 heap_statistics->used_heap_size_ = heap->SizeOfObjects(); |
6833 heap_statistics->heap_size_limit_ = heap->MaxReserved(); | 6538 heap_statistics->heap_size_limit_ = heap->MaxReserved(); |
6834 } | 6539 } |
6835 | 6540 |
6836 | 6541 |
6837 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) | 6542 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) |
6838 : str_(NULL), length_(0) { | 6543 : str_(NULL), length_(0) { |
6839 i::Isolate* isolate = i::Isolate::Current(); | 6544 i::Isolate* isolate = i::Isolate::Current(); |
6840 if (IsDeadCheck(isolate, "v8::String::Utf8Value::Utf8Value()")) return; | |
6841 if (obj.IsEmpty()) return; | 6545 if (obj.IsEmpty()) return; |
6842 ENTER_V8(isolate); | 6546 ENTER_V8(isolate); |
6843 i::HandleScope scope(isolate); | 6547 i::HandleScope scope(isolate); |
6844 TryCatch try_catch; | 6548 TryCatch try_catch; |
6845 Handle<String> str = obj->ToString(); | 6549 Handle<String> str = obj->ToString(); |
6846 if (str.IsEmpty()) return; | 6550 if (str.IsEmpty()) return; |
6847 i::Handle<i::String> i_str = Utils::OpenHandle(*str); | 6551 i::Handle<i::String> i_str = Utils::OpenHandle(*str); |
6848 length_ = v8::Utf8Length(*i_str, isolate); | 6552 length_ = v8::Utf8Length(*i_str, isolate); |
6849 str_ = i::NewArray<char>(length_ + 1); | 6553 str_ = i::NewArray<char>(length_ + 1); |
6850 str->WriteUtf8(str_); | 6554 str->WriteUtf8(str_); |
6851 } | 6555 } |
6852 | 6556 |
6853 | 6557 |
6854 String::Utf8Value::~Utf8Value() { | 6558 String::Utf8Value::~Utf8Value() { |
6855 i::DeleteArray(str_); | 6559 i::DeleteArray(str_); |
6856 } | 6560 } |
6857 | 6561 |
6858 | 6562 |
6859 String::AsciiValue::AsciiValue(v8::Handle<v8::Value> obj) | 6563 String::AsciiValue::AsciiValue(v8::Handle<v8::Value> obj) |
6860 : str_(NULL), length_(0) { | 6564 : str_(NULL), length_(0) { |
6861 i::Isolate* isolate = i::Isolate::Current(); | 6565 i::Isolate* isolate = i::Isolate::Current(); |
6862 if (IsDeadCheck(isolate, "v8::String::AsciiValue::AsciiValue()")) return; | |
6863 if (obj.IsEmpty()) return; | 6566 if (obj.IsEmpty()) return; |
6864 ENTER_V8(isolate); | 6567 ENTER_V8(isolate); |
6865 i::HandleScope scope(isolate); | 6568 i::HandleScope scope(isolate); |
6866 TryCatch try_catch; | 6569 TryCatch try_catch; |
6867 Handle<String> str = obj->ToString(); | 6570 Handle<String> str = obj->ToString(); |
6868 if (str.IsEmpty()) return; | 6571 if (str.IsEmpty()) return; |
6869 length_ = str->Utf8Length(); | 6572 length_ = str->Utf8Length(); |
6870 str_ = i::NewArray<char>(length_ + 1); | 6573 str_ = i::NewArray<char>(length_ + 1); |
6871 str->WriteUtf8(str_); | 6574 str->WriteUtf8(str_); |
6872 ASSERT(i::String::NonAsciiStart(str_, length_) >= length_); | 6575 ASSERT(i::String::NonAsciiStart(str_, length_) >= length_); |
6873 } | 6576 } |
6874 | 6577 |
6875 | 6578 |
6876 String::AsciiValue::~AsciiValue() { | 6579 String::AsciiValue::~AsciiValue() { |
6877 i::DeleteArray(str_); | 6580 i::DeleteArray(str_); |
6878 } | 6581 } |
6879 | 6582 |
6880 | 6583 |
6881 String::Value::Value(v8::Handle<v8::Value> obj) | 6584 String::Value::Value(v8::Handle<v8::Value> obj) |
6882 : str_(NULL), length_(0) { | 6585 : str_(NULL), length_(0) { |
6883 i::Isolate* isolate = i::Isolate::Current(); | 6586 i::Isolate* isolate = i::Isolate::Current(); |
6884 if (IsDeadCheck(isolate, "v8::String::Value::Value()")) return; | |
6885 if (obj.IsEmpty()) return; | 6587 if (obj.IsEmpty()) return; |
6886 ENTER_V8(isolate); | 6588 ENTER_V8(isolate); |
6887 i::HandleScope scope(isolate); | 6589 i::HandleScope scope(isolate); |
6888 TryCatch try_catch; | 6590 TryCatch try_catch; |
6889 Handle<String> str = obj->ToString(); | 6591 Handle<String> str = obj->ToString(); |
6890 if (str.IsEmpty()) return; | 6592 if (str.IsEmpty()) return; |
6891 length_ = str->Length(); | 6593 length_ = str->Length(); |
6892 str_ = i::NewArray<uint16_t>(length_ + 1); | 6594 str_ = i::NewArray<uint16_t>(length_ + 1); |
6893 str->Write(str_); | 6595 str->Write(str_); |
6894 } | 6596 } |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7184 } | 6886 } |
7185 debugger->set_live_edit_enabled(enable); | 6887 debugger->set_live_edit_enabled(enable); |
7186 } | 6888 } |
7187 | 6889 |
7188 | 6890 |
7189 #endif // ENABLE_DEBUGGER_SUPPORT | 6891 #endif // ENABLE_DEBUGGER_SUPPORT |
7190 | 6892 |
7191 | 6893 |
7192 Handle<String> CpuProfileNode::GetFunctionName() const { | 6894 Handle<String> CpuProfileNode::GetFunctionName() const { |
7193 i::Isolate* isolate = i::Isolate::Current(); | 6895 i::Isolate* isolate = i::Isolate::Current(); |
7194 IsDeadCheck(isolate, "v8::CpuProfileNode::GetFunctionName"); | |
7195 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | 6896 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
7196 const i::CodeEntry* entry = node->entry(); | 6897 const i::CodeEntry* entry = node->entry(); |
7197 if (!entry->has_name_prefix()) { | 6898 if (!entry->has_name_prefix()) { |
7198 return ToApiHandle<String>( | 6899 return ToApiHandle<String>( |
7199 isolate->factory()->InternalizeUtf8String(entry->name())); | 6900 isolate->factory()->InternalizeUtf8String(entry->name())); |
7200 } else { | 6901 } else { |
7201 return ToApiHandle<String>(isolate->factory()->NewConsString( | 6902 return ToApiHandle<String>(isolate->factory()->NewConsString( |
7202 isolate->factory()->InternalizeUtf8String(entry->name_prefix()), | 6903 isolate->factory()->InternalizeUtf8String(entry->name_prefix()), |
7203 isolate->factory()->InternalizeUtf8String(entry->name()))); | 6904 isolate->factory()->InternalizeUtf8String(entry->name()))); |
7204 } | 6905 } |
7205 } | 6906 } |
7206 | 6907 |
7207 | 6908 |
7208 int CpuProfileNode::GetScriptId() const { | 6909 int CpuProfileNode::GetScriptId() const { |
7209 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | 6910 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
7210 const i::CodeEntry* entry = node->entry(); | 6911 const i::CodeEntry* entry = node->entry(); |
7211 return entry->script_id(); | 6912 return entry->script_id(); |
7212 } | 6913 } |
7213 | 6914 |
7214 | 6915 |
7215 Handle<String> CpuProfileNode::GetScriptResourceName() const { | 6916 Handle<String> CpuProfileNode::GetScriptResourceName() const { |
7216 i::Isolate* isolate = i::Isolate::Current(); | 6917 i::Isolate* isolate = i::Isolate::Current(); |
7217 IsDeadCheck(isolate, "v8::CpuProfileNode::GetScriptResourceName"); | |
7218 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | 6918 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
7219 return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String( | 6919 return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String( |
7220 node->entry()->resource_name())); | 6920 node->entry()->resource_name())); |
7221 } | 6921 } |
7222 | 6922 |
7223 | 6923 |
7224 int CpuProfileNode::GetLineNumber() const { | 6924 int CpuProfileNode::GetLineNumber() const { |
7225 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->line_number(); | 6925 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->line_number(); |
7226 } | 6926 } |
7227 | 6927 |
7228 | 6928 |
7229 const char* CpuProfileNode::GetBailoutReason() const { | 6929 const char* CpuProfileNode::GetBailoutReason() const { |
7230 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | 6930 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
7231 return node->entry()->bailout_reason(); | 6931 return node->entry()->bailout_reason(); |
7232 } | 6932 } |
7233 | 6933 |
7234 | 6934 |
7235 double CpuProfileNode::GetSelfSamplesCount() const { | 6935 double CpuProfileNode::GetSelfSamplesCount() const { |
7236 i::Isolate* isolate = i::Isolate::Current(); | |
7237 IsDeadCheck(isolate, "v8::CpuProfileNode::GetSelfSamplesCount"); | |
7238 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks(); | 6936 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks(); |
7239 } | 6937 } |
7240 | 6938 |
7241 | 6939 |
7242 unsigned CpuProfileNode::GetHitCount() const { | 6940 unsigned CpuProfileNode::GetHitCount() const { |
7243 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks(); | 6941 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks(); |
7244 } | 6942 } |
7245 | 6943 |
7246 | 6944 |
7247 unsigned CpuProfileNode::GetCallUid() const { | 6945 unsigned CpuProfileNode::GetCallUid() const { |
(...skipping 13 matching lines...) Expand all Loading... |
7261 | 6959 |
7262 const CpuProfileNode* CpuProfileNode::GetChild(int index) const { | 6960 const CpuProfileNode* CpuProfileNode::GetChild(int index) const { |
7263 const i::ProfileNode* child = | 6961 const i::ProfileNode* child = |
7264 reinterpret_cast<const i::ProfileNode*>(this)->children()->at(index); | 6962 reinterpret_cast<const i::ProfileNode*>(this)->children()->at(index); |
7265 return reinterpret_cast<const CpuProfileNode*>(child); | 6963 return reinterpret_cast<const CpuProfileNode*>(child); |
7266 } | 6964 } |
7267 | 6965 |
7268 | 6966 |
7269 void CpuProfile::Delete() { | 6967 void CpuProfile::Delete() { |
7270 i::Isolate* isolate = i::Isolate::Current(); | 6968 i::Isolate* isolate = i::Isolate::Current(); |
7271 IsDeadCheck(isolate, "v8::CpuProfile::Delete"); | |
7272 i::CpuProfiler* profiler = isolate->cpu_profiler(); | 6969 i::CpuProfiler* profiler = isolate->cpu_profiler(); |
7273 ASSERT(profiler != NULL); | 6970 ASSERT(profiler != NULL); |
7274 profiler->DeleteProfile(reinterpret_cast<i::CpuProfile*>(this)); | 6971 profiler->DeleteProfile(reinterpret_cast<i::CpuProfile*>(this)); |
7275 if (profiler->GetProfilesCount() == 0) { | 6972 if (profiler->GetProfilesCount() == 0) { |
7276 // If this was the last profile, clean up all accessory data as well. | 6973 // If this was the last profile, clean up all accessory data as well. |
7277 profiler->DeleteAllProfiles(); | 6974 profiler->DeleteAllProfiles(); |
7278 } | 6975 } |
7279 } | 6976 } |
7280 | 6977 |
7281 | 6978 |
7282 unsigned CpuProfile::GetUid() const { | 6979 unsigned CpuProfile::GetUid() const { |
7283 return reinterpret_cast<const i::CpuProfile*>(this)->uid(); | 6980 return reinterpret_cast<const i::CpuProfile*>(this)->uid(); |
7284 } | 6981 } |
7285 | 6982 |
7286 | 6983 |
7287 Handle<String> CpuProfile::GetTitle() const { | 6984 Handle<String> CpuProfile::GetTitle() const { |
7288 i::Isolate* isolate = i::Isolate::Current(); | 6985 i::Isolate* isolate = i::Isolate::Current(); |
7289 IsDeadCheck(isolate, "v8::CpuProfile::GetTitle"); | |
7290 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); | 6986 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); |
7291 return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String( | 6987 return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String( |
7292 profile->title())); | 6988 profile->title())); |
7293 } | 6989 } |
7294 | 6990 |
7295 | 6991 |
7296 const CpuProfileNode* CpuProfile::GetTopDownRoot() const { | 6992 const CpuProfileNode* CpuProfile::GetTopDownRoot() const { |
7297 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); | 6993 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); |
7298 return reinterpret_cast<const CpuProfileNode*>(profile->top_down()->root()); | 6994 return reinterpret_cast<const CpuProfileNode*>(profile->top_down()->root()); |
7299 } | 6995 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7371 } | 7067 } |
7372 | 7068 |
7373 | 7069 |
7374 static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) { | 7070 static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) { |
7375 return const_cast<i::HeapGraphEdge*>( | 7071 return const_cast<i::HeapGraphEdge*>( |
7376 reinterpret_cast<const i::HeapGraphEdge*>(edge)); | 7072 reinterpret_cast<const i::HeapGraphEdge*>(edge)); |
7377 } | 7073 } |
7378 | 7074 |
7379 | 7075 |
7380 HeapGraphEdge::Type HeapGraphEdge::GetType() const { | 7076 HeapGraphEdge::Type HeapGraphEdge::GetType() const { |
7381 i::Isolate* isolate = i::Isolate::Current(); | |
7382 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetType"); | |
7383 return static_cast<HeapGraphEdge::Type>(ToInternal(this)->type()); | 7077 return static_cast<HeapGraphEdge::Type>(ToInternal(this)->type()); |
7384 } | 7078 } |
7385 | 7079 |
7386 | 7080 |
7387 Handle<Value> HeapGraphEdge::GetName() const { | 7081 Handle<Value> HeapGraphEdge::GetName() const { |
7388 i::Isolate* isolate = i::Isolate::Current(); | 7082 i::Isolate* isolate = i::Isolate::Current(); |
7389 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetName"); | |
7390 i::HeapGraphEdge* edge = ToInternal(this); | 7083 i::HeapGraphEdge* edge = ToInternal(this); |
7391 switch (edge->type()) { | 7084 switch (edge->type()) { |
7392 case i::HeapGraphEdge::kContextVariable: | 7085 case i::HeapGraphEdge::kContextVariable: |
7393 case i::HeapGraphEdge::kInternal: | 7086 case i::HeapGraphEdge::kInternal: |
7394 case i::HeapGraphEdge::kProperty: | 7087 case i::HeapGraphEdge::kProperty: |
7395 case i::HeapGraphEdge::kShortcut: | 7088 case i::HeapGraphEdge::kShortcut: |
7396 return ToApiHandle<String>( | 7089 return ToApiHandle<String>( |
7397 isolate->factory()->InternalizeUtf8String(edge->name())); | 7090 isolate->factory()->InternalizeUtf8String(edge->name())); |
7398 case i::HeapGraphEdge::kElement: | 7091 case i::HeapGraphEdge::kElement: |
7399 case i::HeapGraphEdge::kHidden: | 7092 case i::HeapGraphEdge::kHidden: |
7400 case i::HeapGraphEdge::kWeak: | 7093 case i::HeapGraphEdge::kWeak: |
7401 return ToApiHandle<Number>( | 7094 return ToApiHandle<Number>( |
7402 isolate->factory()->NewNumberFromInt(edge->index())); | 7095 isolate->factory()->NewNumberFromInt(edge->index())); |
7403 default: UNREACHABLE(); | 7096 default: UNREACHABLE(); |
7404 } | 7097 } |
7405 return v8::Undefined(); | 7098 return v8::Undefined(); |
7406 } | 7099 } |
7407 | 7100 |
7408 | 7101 |
7409 const HeapGraphNode* HeapGraphEdge::GetFromNode() const { | 7102 const HeapGraphNode* HeapGraphEdge::GetFromNode() const { |
7410 i::Isolate* isolate = i::Isolate::Current(); | |
7411 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetFromNode"); | |
7412 const i::HeapEntry* from = ToInternal(this)->from(); | 7103 const i::HeapEntry* from = ToInternal(this)->from(); |
7413 return reinterpret_cast<const HeapGraphNode*>(from); | 7104 return reinterpret_cast<const HeapGraphNode*>(from); |
7414 } | 7105 } |
7415 | 7106 |
7416 | 7107 |
7417 const HeapGraphNode* HeapGraphEdge::GetToNode() const { | 7108 const HeapGraphNode* HeapGraphEdge::GetToNode() const { |
7418 i::Isolate* isolate = i::Isolate::Current(); | |
7419 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetToNode"); | |
7420 const i::HeapEntry* to = ToInternal(this)->to(); | 7109 const i::HeapEntry* to = ToInternal(this)->to(); |
7421 return reinterpret_cast<const HeapGraphNode*>(to); | 7110 return reinterpret_cast<const HeapGraphNode*>(to); |
7422 } | 7111 } |
7423 | 7112 |
7424 | 7113 |
7425 static i::HeapEntry* ToInternal(const HeapGraphNode* entry) { | 7114 static i::HeapEntry* ToInternal(const HeapGraphNode* entry) { |
7426 return const_cast<i::HeapEntry*>( | 7115 return const_cast<i::HeapEntry*>( |
7427 reinterpret_cast<const i::HeapEntry*>(entry)); | 7116 reinterpret_cast<const i::HeapEntry*>(entry)); |
7428 } | 7117 } |
7429 | 7118 |
7430 | 7119 |
7431 HeapGraphNode::Type HeapGraphNode::GetType() const { | 7120 HeapGraphNode::Type HeapGraphNode::GetType() const { |
7432 i::Isolate* isolate = i::Isolate::Current(); | |
7433 IsDeadCheck(isolate, "v8::HeapGraphNode::GetType"); | |
7434 return static_cast<HeapGraphNode::Type>(ToInternal(this)->type()); | 7121 return static_cast<HeapGraphNode::Type>(ToInternal(this)->type()); |
7435 } | 7122 } |
7436 | 7123 |
7437 | 7124 |
7438 Handle<String> HeapGraphNode::GetName() const { | 7125 Handle<String> HeapGraphNode::GetName() const { |
7439 i::Isolate* isolate = i::Isolate::Current(); | 7126 i::Isolate* isolate = i::Isolate::Current(); |
7440 IsDeadCheck(isolate, "v8::HeapGraphNode::GetName"); | |
7441 return ToApiHandle<String>( | 7127 return ToApiHandle<String>( |
7442 isolate->factory()->InternalizeUtf8String(ToInternal(this)->name())); | 7128 isolate->factory()->InternalizeUtf8String(ToInternal(this)->name())); |
7443 } | 7129 } |
7444 | 7130 |
7445 | 7131 |
7446 SnapshotObjectId HeapGraphNode::GetId() const { | 7132 SnapshotObjectId HeapGraphNode::GetId() const { |
7447 i::Isolate* isolate = i::Isolate::Current(); | |
7448 IsDeadCheck(isolate, "v8::HeapGraphNode::GetId"); | |
7449 return ToInternal(this)->id(); | 7133 return ToInternal(this)->id(); |
7450 } | 7134 } |
7451 | 7135 |
7452 | 7136 |
7453 int HeapGraphNode::GetSelfSize() const { | 7137 int HeapGraphNode::GetSelfSize() const { |
7454 i::Isolate* isolate = i::Isolate::Current(); | |
7455 IsDeadCheck(isolate, "v8::HeapGraphNode::GetSelfSize"); | |
7456 return ToInternal(this)->self_size(); | 7138 return ToInternal(this)->self_size(); |
7457 } | 7139 } |
7458 | 7140 |
7459 | 7141 |
7460 int HeapGraphNode::GetChildrenCount() const { | 7142 int HeapGraphNode::GetChildrenCount() const { |
7461 i::Isolate* isolate = i::Isolate::Current(); | |
7462 IsDeadCheck(isolate, "v8::HeapSnapshot::GetChildrenCount"); | |
7463 return ToInternal(this)->children().length(); | 7143 return ToInternal(this)->children().length(); |
7464 } | 7144 } |
7465 | 7145 |
7466 | 7146 |
7467 const HeapGraphEdge* HeapGraphNode::GetChild(int index) const { | 7147 const HeapGraphEdge* HeapGraphNode::GetChild(int index) const { |
7468 i::Isolate* isolate = i::Isolate::Current(); | |
7469 IsDeadCheck(isolate, "v8::HeapSnapshot::GetChild"); | |
7470 return reinterpret_cast<const HeapGraphEdge*>( | 7148 return reinterpret_cast<const HeapGraphEdge*>( |
7471 ToInternal(this)->children()[index]); | 7149 ToInternal(this)->children()[index]); |
7472 } | 7150 } |
7473 | 7151 |
7474 | 7152 |
7475 v8::Handle<v8::Value> HeapGraphNode::GetHeapValue() const { | 7153 v8::Handle<v8::Value> HeapGraphNode::GetHeapValue() const { |
7476 i::Isolate* isolate = i::Isolate::Current(); | 7154 i::Isolate* isolate = i::Isolate::Current(); |
7477 IsDeadCheck(isolate, "v8::HeapGraphNode::GetHeapValue"); | |
7478 i::Handle<i::HeapObject> object = ToInternal(this)->GetHeapObject(); | 7155 i::Handle<i::HeapObject> object = ToInternal(this)->GetHeapObject(); |
7479 return !object.is_null() ? | 7156 return !object.is_null() ? |
7480 ToApiHandle<Value>(object) : | 7157 ToApiHandle<Value>(object) : |
7481 ToApiHandle<Value>(isolate->factory()->undefined_value()); | 7158 ToApiHandle<Value>(isolate->factory()->undefined_value()); |
7482 } | 7159 } |
7483 | 7160 |
7484 | 7161 |
7485 static i::HeapSnapshot* ToInternal(const HeapSnapshot* snapshot) { | 7162 static i::HeapSnapshot* ToInternal(const HeapSnapshot* snapshot) { |
7486 return const_cast<i::HeapSnapshot*>( | 7163 return const_cast<i::HeapSnapshot*>( |
7487 reinterpret_cast<const i::HeapSnapshot*>(snapshot)); | 7164 reinterpret_cast<const i::HeapSnapshot*>(snapshot)); |
7488 } | 7165 } |
7489 | 7166 |
7490 | 7167 |
7491 void HeapSnapshot::Delete() { | 7168 void HeapSnapshot::Delete() { |
7492 i::Isolate* isolate = i::Isolate::Current(); | 7169 i::Isolate* isolate = i::Isolate::Current(); |
7493 IsDeadCheck(isolate, "v8::HeapSnapshot::Delete"); | |
7494 if (isolate->heap_profiler()->GetSnapshotsCount() > 1) { | 7170 if (isolate->heap_profiler()->GetSnapshotsCount() > 1) { |
7495 ToInternal(this)->Delete(); | 7171 ToInternal(this)->Delete(); |
7496 } else { | 7172 } else { |
7497 // If this is the last snapshot, clean up all accessory data as well. | 7173 // If this is the last snapshot, clean up all accessory data as well. |
7498 isolate->heap_profiler()->DeleteAllSnapshots(); | 7174 isolate->heap_profiler()->DeleteAllSnapshots(); |
7499 } | 7175 } |
7500 } | 7176 } |
7501 | 7177 |
7502 | 7178 |
7503 unsigned HeapSnapshot::GetUid() const { | 7179 unsigned HeapSnapshot::GetUid() const { |
7504 i::Isolate* isolate = i::Isolate::Current(); | |
7505 IsDeadCheck(isolate, "v8::HeapSnapshot::GetUid"); | |
7506 return ToInternal(this)->uid(); | 7180 return ToInternal(this)->uid(); |
7507 } | 7181 } |
7508 | 7182 |
7509 | 7183 |
7510 Handle<String> HeapSnapshot::GetTitle() const { | 7184 Handle<String> HeapSnapshot::GetTitle() const { |
7511 i::Isolate* isolate = i::Isolate::Current(); | 7185 i::Isolate* isolate = i::Isolate::Current(); |
7512 IsDeadCheck(isolate, "v8::HeapSnapshot::GetTitle"); | |
7513 return ToApiHandle<String>( | 7186 return ToApiHandle<String>( |
7514 isolate->factory()->InternalizeUtf8String(ToInternal(this)->title())); | 7187 isolate->factory()->InternalizeUtf8String(ToInternal(this)->title())); |
7515 } | 7188 } |
7516 | 7189 |
7517 | 7190 |
7518 const HeapGraphNode* HeapSnapshot::GetRoot() const { | 7191 const HeapGraphNode* HeapSnapshot::GetRoot() const { |
7519 i::Isolate* isolate = i::Isolate::Current(); | |
7520 IsDeadCheck(isolate, "v8::HeapSnapshot::GetHead"); | |
7521 return reinterpret_cast<const HeapGraphNode*>(ToInternal(this)->root()); | 7192 return reinterpret_cast<const HeapGraphNode*>(ToInternal(this)->root()); |
7522 } | 7193 } |
7523 | 7194 |
7524 | 7195 |
7525 const HeapGraphNode* HeapSnapshot::GetNodeById(SnapshotObjectId id) const { | 7196 const HeapGraphNode* HeapSnapshot::GetNodeById(SnapshotObjectId id) const { |
7526 i::Isolate* isolate = i::Isolate::Current(); | |
7527 IsDeadCheck(isolate, "v8::HeapSnapshot::GetNodeById"); | |
7528 return reinterpret_cast<const HeapGraphNode*>( | 7197 return reinterpret_cast<const HeapGraphNode*>( |
7529 ToInternal(this)->GetEntryById(id)); | 7198 ToInternal(this)->GetEntryById(id)); |
7530 } | 7199 } |
7531 | 7200 |
7532 | 7201 |
7533 int HeapSnapshot::GetNodesCount() const { | 7202 int HeapSnapshot::GetNodesCount() const { |
7534 i::Isolate* isolate = i::Isolate::Current(); | |
7535 IsDeadCheck(isolate, "v8::HeapSnapshot::GetNodesCount"); | |
7536 return ToInternal(this)->entries().length(); | 7203 return ToInternal(this)->entries().length(); |
7537 } | 7204 } |
7538 | 7205 |
7539 | 7206 |
7540 const HeapGraphNode* HeapSnapshot::GetNode(int index) const { | 7207 const HeapGraphNode* HeapSnapshot::GetNode(int index) const { |
7541 i::Isolate* isolate = i::Isolate::Current(); | |
7542 IsDeadCheck(isolate, "v8::HeapSnapshot::GetNode"); | |
7543 return reinterpret_cast<const HeapGraphNode*>( | 7208 return reinterpret_cast<const HeapGraphNode*>( |
7544 &ToInternal(this)->entries().at(index)); | 7209 &ToInternal(this)->entries().at(index)); |
7545 } | 7210 } |
7546 | 7211 |
7547 | 7212 |
7548 SnapshotObjectId HeapSnapshot::GetMaxSnapshotJSObjectId() const { | 7213 SnapshotObjectId HeapSnapshot::GetMaxSnapshotJSObjectId() const { |
7549 i::Isolate* isolate = i::Isolate::Current(); | |
7550 IsDeadCheck(isolate, "v8::HeapSnapshot::GetMaxSnapshotJSObjectId"); | |
7551 return ToInternal(this)->max_snapshot_js_object_id(); | 7214 return ToInternal(this)->max_snapshot_js_object_id(); |
7552 } | 7215 } |
7553 | 7216 |
7554 | 7217 |
7555 void HeapSnapshot::Serialize(OutputStream* stream, | 7218 void HeapSnapshot::Serialize(OutputStream* stream, |
7556 HeapSnapshot::SerializationFormat format) const { | 7219 HeapSnapshot::SerializationFormat format) const { |
7557 i::Isolate* isolate = i::Isolate::Current(); | |
7558 IsDeadCheck(isolate, "v8::HeapSnapshot::Serialize"); | |
7559 ApiCheck(format == kJSON, | 7220 ApiCheck(format == kJSON, |
7560 "v8::HeapSnapshot::Serialize", | 7221 "v8::HeapSnapshot::Serialize", |
7561 "Unknown serialization format"); | 7222 "Unknown serialization format"); |
7562 ApiCheck(stream->GetOutputEncoding() == OutputStream::kAscii, | 7223 ApiCheck(stream->GetOutputEncoding() == OutputStream::kAscii, |
7563 "v8::HeapSnapshot::Serialize", | 7224 "v8::HeapSnapshot::Serialize", |
7564 "Unsupported output encoding"); | 7225 "Unsupported output encoding"); |
7565 ApiCheck(stream->GetChunkSize() > 0, | 7226 ApiCheck(stream->GetChunkSize() > 0, |
7566 "v8::HeapSnapshot::Serialize", | 7227 "v8::HeapSnapshot::Serialize", |
7567 "Invalid stream chunk size"); | 7228 "Invalid stream chunk size"); |
7568 i::HeapSnapshotJSONSerializer serializer(ToInternal(this)); | 7229 i::HeapSnapshotJSONSerializer serializer(ToInternal(this)); |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7868 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7529 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7869 Address callback_address = | 7530 Address callback_address = |
7870 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7531 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7871 VMState<EXTERNAL> state(isolate); | 7532 VMState<EXTERNAL> state(isolate); |
7872 ExternalCallbackScope call_scope(isolate, callback_address); | 7533 ExternalCallbackScope call_scope(isolate, callback_address); |
7873 callback(info); | 7534 callback(info); |
7874 } | 7535 } |
7875 | 7536 |
7876 | 7537 |
7877 } } // namespace v8::internal | 7538 } } // namespace v8::internal |
OLD | NEW |