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

Side by Side Diff: src/api.cc

Issue 142693005: A64: Synchronize with r16918. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/api.h ('k') | src/arm/assembler-arm.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // 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
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
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
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
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
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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 i::Object** HandleScope::CreateHandle(i::HeapObject* value) { 712 i::Object** HandleScope::CreateHandle(i::HeapObject* value) {
744 ASSERT(value->IsHeapObject()); 713 ASSERT(value->IsHeapObject());
745 return reinterpret_cast<i::Object**>( 714 return reinterpret_cast<i::Object**>(
746 i::HandleScope::CreateHandle(value->GetIsolate(), value)); 715 i::HandleScope::CreateHandle(value->GetIsolate(), value));
747 } 716 }
748 717
749 718
750 void Context::Enter() { 719 void Context::Enter() {
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 if (IsDeadCheck(isolate, "v8::Context::Enter()")) return;
754 ENTER_V8(isolate); 722 ENTER_V8(isolate);
755
756 isolate->handle_scope_implementer()->EnterContext(env); 723 isolate->handle_scope_implementer()->EnterContext(env);
757
758 isolate->handle_scope_implementer()->SaveContext(isolate->context()); 724 isolate->handle_scope_implementer()->SaveContext(isolate->context());
759 isolate->set_context(*env); 725 isolate->set_context(*env);
760 } 726 }
761 727
762 728
763 void Context::Exit() { 729 void Context::Exit() {
764 // Exit is essentially a static function and doesn't use the 730 // TODO(dcarney): fix this once chrome is fixed.
765 // receiver, so we have to get the current isolate from the thread
766 // local.
767 i::Isolate* isolate = i::Isolate::Current(); 731 i::Isolate* isolate = i::Isolate::Current();
768 if (!isolate->IsInitialized()) return; 732 i::Handle<i::Context> context = i::Handle<i::Context>::null();
769 733 ENTER_V8(isolate);
770 if (!ApiCheck(isolate->handle_scope_implementer()->LeaveLastContext(), 734 if (!ApiCheck(isolate->handle_scope_implementer()->LeaveContext(context),
771 "v8::Context::Exit()", 735 "v8::Context::Exit()",
772 "Cannot exit non-entered context")) { 736 "Cannot exit non-entered context")) {
773 return; 737 return;
774 } 738 }
775
776 // Content of 'last_context' could be NULL. 739 // Content of 'last_context' could be NULL.
777 i::Context* last_context = 740 i::Context* last_context =
778 isolate->handle_scope_implementer()->RestoreContext(); 741 isolate->handle_scope_implementer()->RestoreContext();
779 isolate->set_context(last_context); 742 isolate->set_context(last_context);
780 } 743 }
781 744
782 745
783 static void* DecodeSmiToAligned(i::Object* value, const char* location) { 746 static void* DecodeSmiToAligned(i::Object* value, const char* location) {
784 ApiCheck(value->IsSmi(), location, "Not a Smi"); 747 ApiCheck(value->IsSmi(), location, "Not a Smi");
785 return reinterpret_cast<void*>(value); 748 return reinterpret_cast<void*>(value);
786 } 749 }
787 750
788 751
789 static i::Smi* EncodeAlignedAsSmi(void* value, const char* location) { 752 static i::Smi* EncodeAlignedAsSmi(void* value, const char* location) {
790 i::Smi* smi = reinterpret_cast<i::Smi*>(value); 753 i::Smi* smi = reinterpret_cast<i::Smi*>(value);
791 ApiCheck(smi->IsSmi(), location, "Pointer is not aligned"); 754 ApiCheck(smi->IsSmi(), location, "Pointer is not aligned");
792 return smi; 755 return smi;
793 } 756 }
794 757
795 758
796 static i::Handle<i::FixedArray> EmbedderDataFor(Context* context, 759 static i::Handle<i::FixedArray> EmbedderDataFor(Context* context,
797 int index, 760 int index,
798 bool can_grow, 761 bool can_grow,
799 const char* location) { 762 const char* location) {
800 i::Handle<i::Context> env = Utils::OpenHandle(context); 763 i::Handle<i::Context> env = Utils::OpenHandle(context);
801 bool ok = !IsDeadCheck(env->GetIsolate(), location) && 764 bool ok =
802 ApiCheck(env->IsNativeContext(), location, "Not a native context") && 765 ApiCheck(env->IsNativeContext(), location, "Not a native context") &&
803 ApiCheck(index >= 0, location, "Negative index"); 766 ApiCheck(index >= 0, location, "Negative index");
804 if (!ok) return i::Handle<i::FixedArray>(); 767 if (!ok) return i::Handle<i::FixedArray>();
805 i::Handle<i::FixedArray> data(env->embedder_data()); 768 i::Handle<i::FixedArray> data(env->embedder_data());
806 if (index < data->length()) return data; 769 if (index < data->length()) return data;
807 if (!can_grow) { 770 if (!can_grow) {
808 Utils::ReportApiFailure(location, "Index too large"); 771 Utils::ReportApiFailure(location, "Index too large");
809 return i::Handle<i::FixedArray>(); 772 return i::Handle<i::FixedArray>();
810 } 773 }
811 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
968 Utils::OpenHandle(*data[i]); 931 Utils::OpenHandle(*data[i]);
969 array.add(value); 932 array.add(value);
970 } 933 }
971 } 934 }
972 935
973 936
974 void Template::Set(v8::Handle<String> name, 937 void Template::Set(v8::Handle<String> name,
975 v8::Handle<Data> value, 938 v8::Handle<Data> value,
976 v8::PropertyAttribute attribute) { 939 v8::PropertyAttribute attribute) {
977 i::Isolate* isolate = i::Isolate::Current(); 940 i::Isolate* isolate = i::Isolate::Current();
978 if (IsDeadCheck(isolate, "v8::Template::Set()")) return;
979 ENTER_V8(isolate); 941 ENTER_V8(isolate);
980 i::HandleScope scope(isolate); 942 i::HandleScope scope(isolate);
981 const int kSize = 3; 943 const int kSize = 3;
982 v8::Handle<v8::Data> data[kSize] = { 944 v8::Handle<v8::Data> data[kSize] = {
983 name, 945 name,
984 value, 946 value,
985 v8::Integer::New(attribute)}; 947 v8::Integer::New(attribute)};
986 TemplateSet(isolate, this, kSize, data); 948 TemplateSet(isolate, this, kSize, data);
987 } 949 }
988 950
989 951
990 void Template::SetAccessorProperty( 952 void Template::SetAccessorProperty(
991 v8::Local<v8::String> name, 953 v8::Local<v8::String> name,
992 v8::Local<FunctionTemplate> getter, 954 v8::Local<FunctionTemplate> getter,
993 v8::Local<FunctionTemplate> setter, 955 v8::Local<FunctionTemplate> setter,
994 v8::PropertyAttribute attribute, 956 v8::PropertyAttribute attribute,
995 v8::AccessControl access_control) { 957 v8::AccessControl access_control) {
996 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 958 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
997 if (IsDeadCheck(isolate, "v8::Template::SetAccessor()")) return;
998 ENTER_V8(isolate); 959 ENTER_V8(isolate);
999 ASSERT(!name.IsEmpty()); 960 ASSERT(!name.IsEmpty());
1000 ASSERT(!getter.IsEmpty() || !setter.IsEmpty()); 961 ASSERT(!getter.IsEmpty() || !setter.IsEmpty());
1001 i::HandleScope scope(isolate); 962 i::HandleScope scope(isolate);
1002 const int kSize = 5; 963 const int kSize = 5;
1003 v8::Handle<v8::Data> data[kSize] = { 964 v8::Handle<v8::Data> data[kSize] = {
1004 name, 965 name,
1005 getter, 966 getter,
1006 setter, 967 setter,
1007 v8::Integer::New(attribute), 968 v8::Integer::New(attribute),
1008 v8::Integer::New(access_control)}; 969 v8::Integer::New(access_control)};
1009 TemplateSet(isolate, this, kSize, data); 970 TemplateSet(isolate, this, kSize, data);
1010 } 971 }
1011 972
1012 973
1013 // --- 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 ---
1014 static void InitializeFunctionTemplate( 975 static void InitializeFunctionTemplate(
1015 i::Handle<i::FunctionTemplateInfo> info) { 976 i::Handle<i::FunctionTemplateInfo> info) {
1016 info->set_tag(i::Smi::FromInt(Consts::FUNCTION_TEMPLATE)); 977 info->set_tag(i::Smi::FromInt(Consts::FUNCTION_TEMPLATE));
1017 info->set_flag(0); 978 info->set_flag(0);
1018 } 979 }
1019 980
1020 981
1021 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() { 982 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() {
1022 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 983 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1023 if (IsDeadCheck(isolate, "v8::FunctionTemplate::PrototypeTemplate()")) {
1024 return Local<ObjectTemplate>();
1025 }
1026 ENTER_V8(isolate); 984 ENTER_V8(isolate);
1027 i::Handle<i::Object> result(Utils::OpenHandle(this)->prototype_template(), 985 i::Handle<i::Object> result(Utils::OpenHandle(this)->prototype_template(),
1028 isolate); 986 isolate);
1029 if (result->IsUndefined()) { 987 if (result->IsUndefined()) {
1030 result = Utils::OpenHandle(*ObjectTemplate::New()); 988 result = Utils::OpenHandle(*ObjectTemplate::New());
1031 Utils::OpenHandle(this)->set_prototype_template(*result); 989 Utils::OpenHandle(this)->set_prototype_template(*result);
1032 } 990 }
1033 return ToApiHandle<ObjectTemplate>(result); 991 return ToApiHandle<ObjectTemplate>(result);
1034 } 992 }
1035 993
1036 994
1037 void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) { 995 void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) {
1038 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 996 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1039 if (IsDeadCheck(isolate, "v8::FunctionTemplate::Inherit()")) return;
1040 ENTER_V8(isolate); 997 ENTER_V8(isolate);
1041 Utils::OpenHandle(this)->set_parent_template(*Utils::OpenHandle(*value)); 998 Utils::OpenHandle(this)->set_parent_template(*Utils::OpenHandle(*value));
1042 } 999 }
1043 1000
1044 1001
1045 static Local<FunctionTemplate> FunctionTemplateNew( 1002 static Local<FunctionTemplate> FunctionTemplateNew(
1046 i::Isolate* isolate, 1003 i::Isolate* isolate,
1047 FunctionCallback callback, 1004 FunctionCallback callback,
1048 v8::Handle<Value> data, 1005 v8::Handle<Value> data,
1049 v8::Handle<Signature> signature, 1006 v8::Handle<Signature> signature,
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 1229
1273 #define SET_FIELD_WRAPPED(obj, setter, cdata) do { \ 1230 #define SET_FIELD_WRAPPED(obj, setter, cdata) do { \
1274 i::Handle<i::Object> foreign = FromCData(obj->GetIsolate(), cdata); \ 1231 i::Handle<i::Object> foreign = FromCData(obj->GetIsolate(), cdata); \
1275 (obj)->setter(*foreign); \ 1232 (obj)->setter(*foreign); \
1276 } while (false) 1233 } while (false)
1277 1234
1278 1235
1279 void FunctionTemplate::SetCallHandler(FunctionCallback callback, 1236 void FunctionTemplate::SetCallHandler(FunctionCallback callback,
1280 v8::Handle<Value> data) { 1237 v8::Handle<Value> data) {
1281 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1238 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1282 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetCallHandler()")) return;
1283 ENTER_V8(isolate); 1239 ENTER_V8(isolate);
1284 i::HandleScope scope(isolate); 1240 i::HandleScope scope(isolate);
1285 i::Handle<i::Struct> struct_obj = 1241 i::Handle<i::Struct> struct_obj =
1286 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); 1242 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE);
1287 i::Handle<i::CallHandlerInfo> obj = 1243 i::Handle<i::CallHandlerInfo> obj =
1288 i::Handle<i::CallHandlerInfo>::cast(struct_obj); 1244 i::Handle<i::CallHandlerInfo>::cast(struct_obj);
1289 SET_FIELD_WRAPPED(obj, set_callback, callback); 1245 SET_FIELD_WRAPPED(obj, set_callback, callback);
1290 if (data.IsEmpty()) data = v8::Undefined(); 1246 if (data.IsEmpty()) data = v8::Undefined();
1291 obj->set_data(*Utils::OpenHandle(*data)); 1247 obj->set_data(*Utils::OpenHandle(*data));
1292 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
1343 if (descriptor.IsEmpty()) return i::Handle<i::DeclaredAccessorInfo>(); 1299 if (descriptor.IsEmpty()) return i::Handle<i::DeclaredAccessorInfo>();
1344 i::Handle<i::DeclaredAccessorInfo> obj = 1300 i::Handle<i::DeclaredAccessorInfo> obj =
1345 isolate->factory()->NewDeclaredAccessorInfo(); 1301 isolate->factory()->NewDeclaredAccessorInfo();
1346 obj->set_descriptor(*Utils::OpenHandle(*descriptor)); 1302 obj->set_descriptor(*Utils::OpenHandle(*descriptor));
1347 return SetAccessorInfoProperties(obj, name, settings, attributes, signature); 1303 return SetAccessorInfoProperties(obj, name, settings, attributes, signature);
1348 } 1304 }
1349 1305
1350 1306
1351 Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() { 1307 Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() {
1352 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1308 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1353 if (IsDeadCheck(isolate, "v8::FunctionTemplate::InstanceTemplate()") 1309 if (EmptyCheck("v8::FunctionTemplate::InstanceTemplate()", this))
1354 || EmptyCheck("v8::FunctionTemplate::InstanceTemplate()", this))
1355 return Local<ObjectTemplate>(); 1310 return Local<ObjectTemplate>();
1356 ENTER_V8(isolate); 1311 ENTER_V8(isolate);
1357 i::Handle<i::FunctionTemplateInfo> handle = Utils::OpenHandle(this); 1312 i::Handle<i::FunctionTemplateInfo> handle = Utils::OpenHandle(this);
1358 if (handle->instance_template()->IsUndefined()) { 1313 if (handle->instance_template()->IsUndefined()) {
1359 Local<ObjectTemplate> templ = 1314 Local<ObjectTemplate> templ =
1360 ObjectTemplate::New(ToApiHandle<FunctionTemplate>(handle)); 1315 ObjectTemplate::New(ToApiHandle<FunctionTemplate>(handle));
1361 handle->set_instance_template(*Utils::OpenHandle(*templ)); 1316 handle->set_instance_template(*Utils::OpenHandle(*templ));
1362 } 1317 }
1363 i::Handle<i::ObjectTemplateInfo> result( 1318 i::Handle<i::ObjectTemplateInfo> result(
1364 i::ObjectTemplateInfo::cast(handle->instance_template())); 1319 i::ObjectTemplateInfo::cast(handle->instance_template()));
1365 return Utils::ToLocal(result); 1320 return Utils::ToLocal(result);
1366 } 1321 }
1367 1322
1368 1323
1369 void FunctionTemplate::SetLength(int length) { 1324 void FunctionTemplate::SetLength(int length) {
1370 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1325 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1371 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetLength()")) return;
1372 ENTER_V8(isolate); 1326 ENTER_V8(isolate);
1373 Utils::OpenHandle(this)->set_length(length); 1327 Utils::OpenHandle(this)->set_length(length);
1374 } 1328 }
1375 1329
1376 1330
1377 void FunctionTemplate::SetClassName(Handle<String> name) { 1331 void FunctionTemplate::SetClassName(Handle<String> name) {
1378 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1332 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1379 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetClassName()")) return;
1380 ENTER_V8(isolate); 1333 ENTER_V8(isolate);
1381 Utils::OpenHandle(this)->set_class_name(*Utils::OpenHandle(*name)); 1334 Utils::OpenHandle(this)->set_class_name(*Utils::OpenHandle(*name));
1382 } 1335 }
1383 1336
1384 1337
1385 void FunctionTemplate::SetHiddenPrototype(bool value) { 1338 void FunctionTemplate::SetHiddenPrototype(bool value) {
1386 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1339 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1387 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetHiddenPrototype()")) {
1388 return;
1389 }
1390 ENTER_V8(isolate); 1340 ENTER_V8(isolate);
1391 Utils::OpenHandle(this)->set_hidden_prototype(value); 1341 Utils::OpenHandle(this)->set_hidden_prototype(value);
1392 } 1342 }
1393 1343
1394 1344
1395 void FunctionTemplate::ReadOnlyPrototype() { 1345 void FunctionTemplate::ReadOnlyPrototype() {
1396 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1346 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1397 if (IsDeadCheck(isolate, "v8::FunctionTemplate::ReadOnlyPrototype()")) {
1398 return;
1399 }
1400 ENTER_V8(isolate); 1347 ENTER_V8(isolate);
1401 Utils::OpenHandle(this)->set_read_only_prototype(true); 1348 Utils::OpenHandle(this)->set_read_only_prototype(true);
1402 } 1349 }
1403 1350
1404 1351
1405 void FunctionTemplate::RemovePrototype() { 1352 void FunctionTemplate::RemovePrototype() {
1406 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1353 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1407 if (IsDeadCheck(isolate, "v8::FunctionTemplate::RemovePrototype()")) {
1408 return;
1409 }
1410 ENTER_V8(isolate); 1354 ENTER_V8(isolate);
1411 Utils::OpenHandle(this)->set_remove_prototype(true); 1355 Utils::OpenHandle(this)->set_remove_prototype(true);
1412 } 1356 }
1413 1357
1414 1358
1415 // --- 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 ---
1416 1360
1417 1361
1418 Local<ObjectTemplate> ObjectTemplate::New() { 1362 Local<ObjectTemplate> ObjectTemplate::New() {
1419 return New(Local<FunctionTemplate>()); 1363 return New(Local<FunctionTemplate>());
1420 } 1364 }
1421 1365
1422 1366
1423 Local<ObjectTemplate> ObjectTemplate::New( 1367 Local<ObjectTemplate> ObjectTemplate::New(
1424 v8::Handle<FunctionTemplate> constructor) { 1368 v8::Handle<FunctionTemplate> constructor) {
1425 i::Isolate* isolate = i::Isolate::Current(); 1369 i::Isolate* isolate = i::Isolate::Current();
1426 if (IsDeadCheck(isolate, "v8::ObjectTemplate::New()")) {
1427 return Local<ObjectTemplate>();
1428 }
1429 EnsureInitializedForIsolate(isolate, "v8::ObjectTemplate::New()"); 1370 EnsureInitializedForIsolate(isolate, "v8::ObjectTemplate::New()");
1430 LOG_API(isolate, "ObjectTemplate::New"); 1371 LOG_API(isolate, "ObjectTemplate::New");
1431 ENTER_V8(isolate); 1372 ENTER_V8(isolate);
1432 i::Handle<i::Struct> struct_obj = 1373 i::Handle<i::Struct> struct_obj =
1433 isolate->factory()->NewStruct(i::OBJECT_TEMPLATE_INFO_TYPE); 1374 isolate->factory()->NewStruct(i::OBJECT_TEMPLATE_INFO_TYPE);
1434 i::Handle<i::ObjectTemplateInfo> obj = 1375 i::Handle<i::ObjectTemplateInfo> obj =
1435 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj); 1376 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj);
1436 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE); 1377 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE);
1437 if (!constructor.IsEmpty()) 1378 if (!constructor.IsEmpty())
1438 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
1489 static bool TemplateSetAccessor( 1430 static bool TemplateSetAccessor(
1490 Template* template_obj, 1431 Template* template_obj,
1491 v8::Local<String> name, 1432 v8::Local<String> name,
1492 Getter getter, 1433 Getter getter,
1493 Setter setter, 1434 Setter setter,
1494 Data data, 1435 Data data,
1495 AccessControl settings, 1436 AccessControl settings,
1496 PropertyAttribute attribute, 1437 PropertyAttribute attribute,
1497 v8::Local<AccessorSignature> signature) { 1438 v8::Local<AccessorSignature> signature) {
1498 i::Isolate* isolate = Utils::OpenHandle(template_obj)->GetIsolate(); 1439 i::Isolate* isolate = Utils::OpenHandle(template_obj)->GetIsolate();
1499 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetAccessor()")) return false;
1500 ENTER_V8(isolate); 1440 ENTER_V8(isolate);
1501 i::HandleScope scope(isolate); 1441 i::HandleScope scope(isolate);
1502 i::Handle<i::AccessorInfo> obj = MakeAccessorInfo( 1442 i::Handle<i::AccessorInfo> obj = MakeAccessorInfo(
1503 name, getter, setter, data, settings, attribute, signature); 1443 name, getter, setter, data, settings, attribute, signature);
1504 if (obj.is_null()) return false; 1444 if (obj.is_null()) return false;
1505 i::Handle<i::TemplateInfo> info = GetTemplateInfo(template_obj); 1445 i::Handle<i::TemplateInfo> info = GetTemplateInfo(template_obj);
1506 AddPropertyToTemplate(info, obj); 1446 AddPropertyToTemplate(info, obj);
1507 return true; 1447 return true;
1508 } 1448 }
1509 1449
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 1485
1546 1486
1547 void ObjectTemplate::SetNamedPropertyHandler( 1487 void ObjectTemplate::SetNamedPropertyHandler(
1548 NamedPropertyGetterCallback getter, 1488 NamedPropertyGetterCallback getter,
1549 NamedPropertySetterCallback setter, 1489 NamedPropertySetterCallback setter,
1550 NamedPropertyQueryCallback query, 1490 NamedPropertyQueryCallback query,
1551 NamedPropertyDeleterCallback remover, 1491 NamedPropertyDeleterCallback remover,
1552 NamedPropertyEnumeratorCallback enumerator, 1492 NamedPropertyEnumeratorCallback enumerator,
1553 Handle<Value> data) { 1493 Handle<Value> data) {
1554 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1494 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1555 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetNamedPropertyHandler()")) {
1556 return;
1557 }
1558 ENTER_V8(isolate); 1495 ENTER_V8(isolate);
1559 i::HandleScope scope(isolate); 1496 i::HandleScope scope(isolate);
1560 EnsureConstructor(this); 1497 EnsureConstructor(this);
1561 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( 1498 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast(
1562 Utils::OpenHandle(this)->constructor()); 1499 Utils::OpenHandle(this)->constructor());
1563 i::Handle<i::FunctionTemplateInfo> cons(constructor); 1500 i::Handle<i::FunctionTemplateInfo> cons(constructor);
1564 i::Handle<i::Struct> struct_obj = 1501 i::Handle<i::Struct> struct_obj =
1565 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); 1502 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE);
1566 i::Handle<i::InterceptorInfo> obj = 1503 i::Handle<i::InterceptorInfo> obj =
1567 i::Handle<i::InterceptorInfo>::cast(struct_obj); 1504 i::Handle<i::InterceptorInfo>::cast(struct_obj);
1568 1505
1569 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); 1506 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter);
1570 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); 1507 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter);
1571 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); 1508 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query);
1572 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); 1509 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover);
1573 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); 1510 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator);
1574 1511
1575 if (data.IsEmpty()) data = v8::Undefined(); 1512 if (data.IsEmpty()) data = v8::Undefined();
1576 obj->set_data(*Utils::OpenHandle(*data)); 1513 obj->set_data(*Utils::OpenHandle(*data));
1577 cons->set_named_property_handler(*obj); 1514 cons->set_named_property_handler(*obj);
1578 } 1515 }
1579 1516
1580 1517
1581 void ObjectTemplate::MarkAsUndetectable() { 1518 void ObjectTemplate::MarkAsUndetectable() {
1582 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1519 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1583 if (IsDeadCheck(isolate, "v8::ObjectTemplate::MarkAsUndetectable()")) return;
1584 ENTER_V8(isolate); 1520 ENTER_V8(isolate);
1585 i::HandleScope scope(isolate); 1521 i::HandleScope scope(isolate);
1586 EnsureConstructor(this); 1522 EnsureConstructor(this);
1587 i::FunctionTemplateInfo* constructor = 1523 i::FunctionTemplateInfo* constructor =
1588 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); 1524 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());
1589 i::Handle<i::FunctionTemplateInfo> cons(constructor); 1525 i::Handle<i::FunctionTemplateInfo> cons(constructor);
1590 cons->set_undetectable(true); 1526 cons->set_undetectable(true);
1591 } 1527 }
1592 1528
1593 1529
1594 void ObjectTemplate::SetAccessCheckCallbacks( 1530 void ObjectTemplate::SetAccessCheckCallbacks(
1595 NamedSecurityCallback named_callback, 1531 NamedSecurityCallback named_callback,
1596 IndexedSecurityCallback indexed_callback, 1532 IndexedSecurityCallback indexed_callback,
1597 Handle<Value> data, 1533 Handle<Value> data,
1598 bool turned_on_by_default) { 1534 bool turned_on_by_default) {
1599 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1535 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1600 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetAccessCheckCallbacks()")) {
1601 return;
1602 }
1603 ENTER_V8(isolate); 1536 ENTER_V8(isolate);
1604 i::HandleScope scope(isolate); 1537 i::HandleScope scope(isolate);
1605 EnsureConstructor(this); 1538 EnsureConstructor(this);
1606 1539
1607 i::Handle<i::Struct> struct_info = 1540 i::Handle<i::Struct> struct_info =
1608 isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE); 1541 isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE);
1609 i::Handle<i::AccessCheckInfo> info = 1542 i::Handle<i::AccessCheckInfo> info =
1610 i::Handle<i::AccessCheckInfo>::cast(struct_info); 1543 i::Handle<i::AccessCheckInfo>::cast(struct_info);
1611 1544
1612 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
1624 1557
1625 1558
1626 void ObjectTemplate::SetIndexedPropertyHandler( 1559 void ObjectTemplate::SetIndexedPropertyHandler(
1627 IndexedPropertyGetterCallback getter, 1560 IndexedPropertyGetterCallback getter,
1628 IndexedPropertySetterCallback setter, 1561 IndexedPropertySetterCallback setter,
1629 IndexedPropertyQueryCallback query, 1562 IndexedPropertyQueryCallback query,
1630 IndexedPropertyDeleterCallback remover, 1563 IndexedPropertyDeleterCallback remover,
1631 IndexedPropertyEnumeratorCallback enumerator, 1564 IndexedPropertyEnumeratorCallback enumerator,
1632 Handle<Value> data) { 1565 Handle<Value> data) {
1633 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1566 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1634 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetIndexedPropertyHandler()")) {
1635 return;
1636 }
1637 ENTER_V8(isolate); 1567 ENTER_V8(isolate);
1638 i::HandleScope scope(isolate); 1568 i::HandleScope scope(isolate);
1639 EnsureConstructor(this); 1569 EnsureConstructor(this);
1640 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( 1570 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast(
1641 Utils::OpenHandle(this)->constructor()); 1571 Utils::OpenHandle(this)->constructor());
1642 i::Handle<i::FunctionTemplateInfo> cons(constructor); 1572 i::Handle<i::FunctionTemplateInfo> cons(constructor);
1643 i::Handle<i::Struct> struct_obj = 1573 i::Handle<i::Struct> struct_obj =
1644 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); 1574 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE);
1645 i::Handle<i::InterceptorInfo> obj = 1575 i::Handle<i::InterceptorInfo> obj =
1646 i::Handle<i::InterceptorInfo>::cast(struct_obj); 1576 i::Handle<i::InterceptorInfo>::cast(struct_obj);
1647 1577
1648 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); 1578 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter);
1649 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); 1579 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter);
1650 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); 1580 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query);
1651 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); 1581 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover);
1652 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); 1582 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator);
1653 1583
1654 if (data.IsEmpty()) data = v8::Undefined(); 1584 if (data.IsEmpty()) data = v8::Undefined();
1655 obj->set_data(*Utils::OpenHandle(*data)); 1585 obj->set_data(*Utils::OpenHandle(*data));
1656 cons->set_indexed_property_handler(*obj); 1586 cons->set_indexed_property_handler(*obj);
1657 } 1587 }
1658 1588
1659 1589
1660 void ObjectTemplate::SetCallAsFunctionHandler(FunctionCallback callback, 1590 void ObjectTemplate::SetCallAsFunctionHandler(FunctionCallback callback,
1661 Handle<Value> data) { 1591 Handle<Value> data) {
1662 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1592 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1663 if (IsDeadCheck(isolate,
1664 "v8::ObjectTemplate::SetCallAsFunctionHandler()")) {
1665 return;
1666 }
1667 ENTER_V8(isolate); 1593 ENTER_V8(isolate);
1668 i::HandleScope scope(isolate); 1594 i::HandleScope scope(isolate);
1669 EnsureConstructor(this); 1595 EnsureConstructor(this);
1670 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( 1596 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast(
1671 Utils::OpenHandle(this)->constructor()); 1597 Utils::OpenHandle(this)->constructor());
1672 i::Handle<i::FunctionTemplateInfo> cons(constructor); 1598 i::Handle<i::FunctionTemplateInfo> cons(constructor);
1673 i::Handle<i::Struct> struct_obj = 1599 i::Handle<i::Struct> struct_obj =
1674 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); 1600 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE);
1675 i::Handle<i::CallHandlerInfo> obj = 1601 i::Handle<i::CallHandlerInfo> obj =
1676 i::Handle<i::CallHandlerInfo>::cast(struct_obj); 1602 i::Handle<i::CallHandlerInfo>::cast(struct_obj);
1677 SET_FIELD_WRAPPED(obj, set_callback, callback); 1603 SET_FIELD_WRAPPED(obj, set_callback, callback);
1678 if (data.IsEmpty()) data = v8::Undefined(); 1604 if (data.IsEmpty()) data = v8::Undefined();
1679 obj->set_data(*Utils::OpenHandle(*data)); 1605 obj->set_data(*Utils::OpenHandle(*data));
1680 cons->set_instance_call_handler(*obj); 1606 cons->set_instance_call_handler(*obj);
1681 } 1607 }
1682 1608
1683 1609
1684 int ObjectTemplate::InternalFieldCount() { 1610 int ObjectTemplate::InternalFieldCount() {
1685 if (IsDeadCheck(Utils::OpenHandle(this)->GetIsolate(),
1686 "v8::ObjectTemplate::InternalFieldCount()")) {
1687 return 0;
1688 }
1689 return i::Smi::cast(Utils::OpenHandle(this)->internal_field_count())->value(); 1611 return i::Smi::cast(Utils::OpenHandle(this)->internal_field_count())->value();
1690 } 1612 }
1691 1613
1692 1614
1693 void ObjectTemplate::SetInternalFieldCount(int value) { 1615 void ObjectTemplate::SetInternalFieldCount(int value) {
1694 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1616 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1695 if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetInternalFieldCount()")) {
1696 return;
1697 }
1698 if (!ApiCheck(i::Smi::IsValid(value), 1617 if (!ApiCheck(i::Smi::IsValid(value),
1699 "v8::ObjectTemplate::SetInternalFieldCount()", 1618 "v8::ObjectTemplate::SetInternalFieldCount()",
1700 "Invalid internal field count")) { 1619 "Invalid internal field count")) {
1701 return; 1620 return;
1702 } 1621 }
1703 ENTER_V8(isolate); 1622 ENTER_V8(isolate);
1704 if (value > 0) { 1623 if (value > 0) {
1705 // The internal field count is set by the constructor function's 1624 // The internal field count is set by the constructor function's
1706 // construct code, so we ensure that there is a constructor 1625 // construct code, so we ensure that there is a constructor
1707 // function to do the setting. 1626 // function to do the setting.
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
2110 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); 2029 HandleScope scope(reinterpret_cast<Isolate*>(isolate));
2111 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2030 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2112 i::Handle<i::String> raw_result = i::MessageHandler::GetMessage(isolate, obj); 2031 i::Handle<i::String> raw_result = i::MessageHandler::GetMessage(isolate, obj);
2113 Local<String> result = Utils::ToLocal(raw_result); 2032 Local<String> result = Utils::ToLocal(raw_result);
2114 return scope.Close(result); 2033 return scope.Close(result);
2115 } 2034 }
2116 2035
2117 2036
2118 v8::Handle<Value> Message::GetScriptResourceName() const { 2037 v8::Handle<Value> Message::GetScriptResourceName() const {
2119 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2038 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2120 if (IsDeadCheck(isolate, "v8::Message::GetScriptResourceName()")) {
2121 return Local<String>();
2122 }
2123 ENTER_V8(isolate); 2039 ENTER_V8(isolate);
2124 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); 2040 HandleScope scope(reinterpret_cast<Isolate*>(isolate));
2125 i::Handle<i::JSMessageObject> message = 2041 i::Handle<i::JSMessageObject> message =
2126 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); 2042 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
2127 // Return this.script.name. 2043 // Return this.script.name.
2128 i::Handle<i::JSValue> script = 2044 i::Handle<i::JSValue> script =
2129 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(), 2045 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(),
2130 isolate)); 2046 isolate));
2131 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(),
2132 isolate); 2048 isolate);
2133 return scope.Close(Utils::ToLocal(resource_name)); 2049 return scope.Close(Utils::ToLocal(resource_name));
2134 } 2050 }
2135 2051
2136 2052
2137 v8::Handle<Value> Message::GetScriptData() const { 2053 v8::Handle<Value> Message::GetScriptData() const {
2138 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2054 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2139 if (IsDeadCheck(isolate, "v8::Message::GetScriptResourceData()")) {
2140 return Local<Value>();
2141 }
2142 ENTER_V8(isolate); 2055 ENTER_V8(isolate);
2143 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); 2056 HandleScope scope(reinterpret_cast<Isolate*>(isolate));
2144 i::Handle<i::JSMessageObject> message = 2057 i::Handle<i::JSMessageObject> message =
2145 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); 2058 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
2146 // Return this.script.data. 2059 // Return this.script.data.
2147 i::Handle<i::JSValue> script = 2060 i::Handle<i::JSValue> script =
2148 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(), 2061 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(),
2149 isolate)); 2062 isolate));
2150 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);
2151 return scope.Close(Utils::ToLocal(data)); 2064 return scope.Close(Utils::ToLocal(data));
2152 } 2065 }
2153 2066
2154 2067
2155 v8::Handle<v8::StackTrace> Message::GetStackTrace() const { 2068 v8::Handle<v8::StackTrace> Message::GetStackTrace() const {
2156 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2069 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2157 if (IsDeadCheck(isolate, "v8::Message::GetStackTrace()")) {
2158 return Local<v8::StackTrace>();
2159 }
2160 ENTER_V8(isolate); 2070 ENTER_V8(isolate);
2161 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); 2071 HandleScope scope(reinterpret_cast<Isolate*>(isolate));
2162 i::Handle<i::JSMessageObject> message = 2072 i::Handle<i::JSMessageObject> message =
2163 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); 2073 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
2164 i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate); 2074 i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate);
2165 if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>(); 2075 if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>();
2166 i::Handle<i::JSArray> stackTrace = 2076 i::Handle<i::JSArray> stackTrace =
2167 i::Handle<i::JSArray>::cast(stackFramesObj); 2077 i::Handle<i::JSArray>::cast(stackFramesObj);
2168 return scope.Close(Utils::StackTraceToLocal(stackTrace)); 2078 return scope.Close(Utils::StackTraceToLocal(stackTrace));
2169 } 2079 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2209 i::Handle<i::Object> result = CallV8HeapFunction("GetLineNumber", 2119 i::Handle<i::Object> result = CallV8HeapFunction("GetLineNumber",
2210 Utils::OpenHandle(this), 2120 Utils::OpenHandle(this),
2211 &has_pending_exception); 2121 &has_pending_exception);
2212 EXCEPTION_BAILOUT_CHECK(isolate, 0); 2122 EXCEPTION_BAILOUT_CHECK(isolate, 0);
2213 return static_cast<int>(result->Number()); 2123 return static_cast<int>(result->Number());
2214 } 2124 }
2215 2125
2216 2126
2217 int Message::GetStartPosition() const { 2127 int Message::GetStartPosition() const {
2218 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2128 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2219 if (IsDeadCheck(isolate, "v8::Message::GetStartPosition()")) return 0;
2220 ENTER_V8(isolate); 2129 ENTER_V8(isolate);
2221 i::HandleScope scope(isolate); 2130 i::HandleScope scope(isolate);
2222 i::Handle<i::JSMessageObject> message = 2131 i::Handle<i::JSMessageObject> message =
2223 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); 2132 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
2224 return message->start_position(); 2133 return message->start_position();
2225 } 2134 }
2226 2135
2227 2136
2228 int Message::GetEndPosition() const { 2137 int Message::GetEndPosition() const {
2229 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2138 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2230 if (IsDeadCheck(isolate, "v8::Message::GetEndPosition()")) return 0;
2231 ENTER_V8(isolate); 2139 ENTER_V8(isolate);
2232 i::HandleScope scope(isolate); 2140 i::HandleScope scope(isolate);
2233 i::Handle<i::JSMessageObject> message = 2141 i::Handle<i::JSMessageObject> message =
2234 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); 2142 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
2235 return message->end_position(); 2143 return message->end_position();
2236 } 2144 }
2237 2145
2238 2146
2239 int Message::GetStartColumn() const { 2147 int Message::GetStartColumn() const {
2240 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2148 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2241 if (IsDeadCheck(isolate, "v8::Message::GetStartColumn()")) {
2242 return kNoColumnInfo;
2243 }
2244 ENTER_V8(isolate); 2149 ENTER_V8(isolate);
2245 i::HandleScope scope(isolate); 2150 i::HandleScope scope(isolate);
2246 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); 2151 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
2247 EXCEPTION_PREAMBLE(isolate); 2152 EXCEPTION_PREAMBLE(isolate);
2248 i::Handle<i::Object> start_col_obj = CallV8HeapFunction( 2153 i::Handle<i::Object> start_col_obj = CallV8HeapFunction(
2249 "GetPositionInLine", 2154 "GetPositionInLine",
2250 data_obj, 2155 data_obj,
2251 &has_pending_exception); 2156 &has_pending_exception);
2252 EXCEPTION_BAILOUT_CHECK(isolate, 0); 2157 EXCEPTION_BAILOUT_CHECK(isolate, 0);
2253 return static_cast<int>(start_col_obj->Number()); 2158 return static_cast<int>(start_col_obj->Number());
2254 } 2159 }
2255 2160
2256 2161
2257 int Message::GetEndColumn() const { 2162 int Message::GetEndColumn() const {
2258 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2163 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2259 if (IsDeadCheck(isolate, "v8::Message::GetEndColumn()")) return kNoColumnInfo;
2260 ENTER_V8(isolate); 2164 ENTER_V8(isolate);
2261 i::HandleScope scope(isolate); 2165 i::HandleScope scope(isolate);
2262 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this); 2166 i::Handle<i::JSObject> data_obj = Utils::OpenHandle(this);
2263 EXCEPTION_PREAMBLE(isolate); 2167 EXCEPTION_PREAMBLE(isolate);
2264 i::Handle<i::Object> start_col_obj = CallV8HeapFunction( 2168 i::Handle<i::Object> start_col_obj = CallV8HeapFunction(
2265 "GetPositionInLine", 2169 "GetPositionInLine",
2266 data_obj, 2170 data_obj,
2267 &has_pending_exception); 2171 &has_pending_exception);
2268 EXCEPTION_BAILOUT_CHECK(isolate, 0); 2172 EXCEPTION_BAILOUT_CHECK(isolate, 0);
2269 i::Handle<i::JSMessageObject> message = 2173 i::Handle<i::JSMessageObject> message =
2270 i::Handle<i::JSMessageObject>::cast(data_obj); 2174 i::Handle<i::JSMessageObject>::cast(data_obj);
2271 int start = message->start_position(); 2175 int start = message->start_position();
2272 int end = message->end_position(); 2176 int end = message->end_position();
2273 return static_cast<int>(start_col_obj->Number()) + (end - start); 2177 return static_cast<int>(start_col_obj->Number()) + (end - start);
2274 } 2178 }
2275 2179
2276 2180
2277 bool Message::IsSharedCrossOrigin() const { 2181 bool Message::IsSharedCrossOrigin() const {
2278 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2182 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2279 if (IsDeadCheck(isolate, "v8::Message::IsSharedCrossOrigin()")) return 0;
2280 ENTER_V8(isolate); 2183 ENTER_V8(isolate);
2281 i::HandleScope scope(isolate); 2184 i::HandleScope scope(isolate);
2282 i::Handle<i::JSMessageObject> message = 2185 i::Handle<i::JSMessageObject> message =
2283 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); 2186 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
2284 i::Handle<i::JSValue> script = 2187 i::Handle<i::JSValue> script =
2285 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(), 2188 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(),
2286 isolate)); 2189 isolate));
2287 return i::Script::cast(script->value())->is_shared_cross_origin(); 2190 return i::Script::cast(script->value())->is_shared_cross_origin();
2288 } 2191 }
2289 2192
(...skipping 11 matching lines...) Expand all
2301 if (result->IsString()) { 2204 if (result->IsString()) {
2302 return scope.Close(Utils::ToLocal(i::Handle<i::String>::cast(result))); 2205 return scope.Close(Utils::ToLocal(i::Handle<i::String>::cast(result)));
2303 } else { 2206 } else {
2304 return Local<String>(); 2207 return Local<String>();
2305 } 2208 }
2306 } 2209 }
2307 2210
2308 2211
2309 void Message::PrintCurrentStackTrace(FILE* out) { 2212 void Message::PrintCurrentStackTrace(FILE* out) {
2310 i::Isolate* isolate = i::Isolate::Current(); 2213 i::Isolate* isolate = i::Isolate::Current();
2311 if (IsDeadCheck(isolate, "v8::Message::PrintCurrentStackTrace()")) return;
2312 ENTER_V8(isolate); 2214 ENTER_V8(isolate);
2313 isolate->PrintCurrentStackTrace(out); 2215 isolate->PrintCurrentStackTrace(out);
2314 } 2216 }
2315 2217
2316 2218
2317 // --- S t a c k T r a c e --- 2219 // --- S t a c k T r a c e ---
2318 2220
2319 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const { 2221 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const {
2320 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2222 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2321 if (IsDeadCheck(isolate, "v8::StackTrace::GetFrame()")) {
2322 return Local<StackFrame>();
2323 }
2324 ENTER_V8(isolate); 2223 ENTER_V8(isolate);
2325 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); 2224 HandleScope scope(reinterpret_cast<Isolate*>(isolate));
2326 i::Handle<i::JSArray> self = Utils::OpenHandle(this); 2225 i::Handle<i::JSArray> self = Utils::OpenHandle(this);
2327 i::Object* raw_object = self->GetElementNoExceptionThrown(isolate, index); 2226 i::Object* raw_object = self->GetElementNoExceptionThrown(isolate, index);
2328 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_object)); 2227 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_object));
2329 return scope.Close(Utils::StackFrameToLocal(obj)); 2228 return scope.Close(Utils::StackFrameToLocal(obj));
2330 } 2229 }
2331 2230
2332 2231
2333 int StackTrace::GetFrameCount() const { 2232 int StackTrace::GetFrameCount() const {
2334 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2233 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2335 if (IsDeadCheck(isolate, "v8::StackTrace::GetFrameCount()")) return -1;
2336 ENTER_V8(isolate); 2234 ENTER_V8(isolate);
2337 return i::Smi::cast(Utils::OpenHandle(this)->length())->value(); 2235 return i::Smi::cast(Utils::OpenHandle(this)->length())->value();
2338 } 2236 }
2339 2237
2340 2238
2341 Local<Array> StackTrace::AsArray() { 2239 Local<Array> StackTrace::AsArray() {
2342 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2240 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2343 if (IsDeadCheck(isolate, "v8::StackTrace::AsArray()")) Local<Array>();
2344 ENTER_V8(isolate); 2241 ENTER_V8(isolate);
2345 return Utils::ToLocal(Utils::OpenHandle(this)); 2242 return Utils::ToLocal(Utils::OpenHandle(this));
2346 } 2243 }
2347 2244
2348 2245
2349 Local<StackTrace> StackTrace::CurrentStackTrace(int frame_limit, 2246 Local<StackTrace> StackTrace::CurrentStackTrace(int frame_limit,
2350 StackTraceOptions options) { 2247 StackTraceOptions options) {
2351 i::Isolate* isolate = i::Isolate::Current(); 2248 i::Isolate* isolate = i::Isolate::Current();
2352 if (IsDeadCheck(isolate, "v8::StackTrace::CurrentStackTrace()")) {
2353 Local<StackTrace>();
2354 }
2355 ENTER_V8(isolate); 2249 ENTER_V8(isolate);
2356 i::Handle<i::JSArray> stackTrace = 2250 i::Handle<i::JSArray> stackTrace =
2357 isolate->CaptureCurrentStackTrace(frame_limit, options); 2251 isolate->CaptureCurrentStackTrace(frame_limit, options);
2358 return Utils::StackTraceToLocal(stackTrace); 2252 return Utils::StackTraceToLocal(stackTrace);
2359 } 2253 }
2360 2254
2361 2255
2362 // --- S t a c k F r a m e --- 2256 // --- S t a c k F r a m e ---
2363 2257
2364 int StackFrame::GetLineNumber() const { 2258 int StackFrame::GetLineNumber() const {
2365 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2259 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2366 if (IsDeadCheck(isolate, "v8::StackFrame::GetLineNumber()")) {
2367 return Message::kNoLineNumberInfo;
2368 }
2369 ENTER_V8(isolate); 2260 ENTER_V8(isolate);
2370 i::HandleScope scope(isolate); 2261 i::HandleScope scope(isolate);
2371 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2262 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2372 i::Handle<i::Object> line = GetProperty(self, "lineNumber"); 2263 i::Handle<i::Object> line = GetProperty(self, "lineNumber");
2373 if (!line->IsSmi()) { 2264 if (!line->IsSmi()) {
2374 return Message::kNoLineNumberInfo; 2265 return Message::kNoLineNumberInfo;
2375 } 2266 }
2376 return i::Smi::cast(*line)->value(); 2267 return i::Smi::cast(*line)->value();
2377 } 2268 }
2378 2269
2379 2270
2380 int StackFrame::GetColumn() const { 2271 int StackFrame::GetColumn() const {
2381 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2272 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2382 if (IsDeadCheck(isolate, "v8::StackFrame::GetColumn()")) {
2383 return Message::kNoColumnInfo;
2384 }
2385 ENTER_V8(isolate); 2273 ENTER_V8(isolate);
2386 i::HandleScope scope(isolate); 2274 i::HandleScope scope(isolate);
2387 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2275 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2388 i::Handle<i::Object> column = GetProperty(self, "column"); 2276 i::Handle<i::Object> column = GetProperty(self, "column");
2389 if (!column->IsSmi()) { 2277 if (!column->IsSmi()) {
2390 return Message::kNoColumnInfo; 2278 return Message::kNoColumnInfo;
2391 } 2279 }
2392 return i::Smi::cast(*column)->value(); 2280 return i::Smi::cast(*column)->value();
2393 } 2281 }
2394 2282
2395 2283
2396 int StackFrame::GetScriptId() const { 2284 int StackFrame::GetScriptId() const {
2397 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2285 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2398 if (IsDeadCheck(isolate, "v8::StackFrame::GetScriptId()")) {
2399 return Message::kNoScriptIdInfo;
2400 }
2401 ENTER_V8(isolate); 2286 ENTER_V8(isolate);
2402 i::HandleScope scope(isolate); 2287 i::HandleScope scope(isolate);
2403 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2288 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2404 i::Handle<i::Object> scriptId = GetProperty(self, "scriptId"); 2289 i::Handle<i::Object> scriptId = GetProperty(self, "scriptId");
2405 if (!scriptId->IsSmi()) { 2290 if (!scriptId->IsSmi()) {
2406 return Message::kNoScriptIdInfo; 2291 return Message::kNoScriptIdInfo;
2407 } 2292 }
2408 return i::Smi::cast(*scriptId)->value(); 2293 return i::Smi::cast(*scriptId)->value();
2409 } 2294 }
2410 2295
2411 2296
2412 Local<String> StackFrame::GetScriptName() const { 2297 Local<String> StackFrame::GetScriptName() const {
2413 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2298 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2414 if (IsDeadCheck(isolate, "v8::StackFrame::GetScriptName()")) {
2415 return Local<String>();
2416 }
2417 ENTER_V8(isolate); 2299 ENTER_V8(isolate);
2418 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); 2300 HandleScope scope(reinterpret_cast<Isolate*>(isolate));
2419 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2301 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2420 i::Handle<i::Object> name = GetProperty(self, "scriptName"); 2302 i::Handle<i::Object> name = GetProperty(self, "scriptName");
2421 if (!name->IsString()) { 2303 if (!name->IsString()) {
2422 return Local<String>(); 2304 return Local<String>();
2423 } 2305 }
2424 return scope.Close(Local<String>::Cast(Utils::ToLocal(name))); 2306 return scope.Close(Local<String>::Cast(Utils::ToLocal(name)));
2425 } 2307 }
2426 2308
2427 2309
2428 Local<String> StackFrame::GetScriptNameOrSourceURL() const { 2310 Local<String> StackFrame::GetScriptNameOrSourceURL() const {
2429 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2311 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2430 if (IsDeadCheck(isolate, "v8::StackFrame::GetScriptNameOrSourceURL()")) {
2431 return Local<String>();
2432 }
2433 ENTER_V8(isolate); 2312 ENTER_V8(isolate);
2434 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); 2313 HandleScope scope(reinterpret_cast<Isolate*>(isolate));
2435 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2314 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2436 i::Handle<i::Object> name = GetProperty(self, "scriptNameOrSourceURL"); 2315 i::Handle<i::Object> name = GetProperty(self, "scriptNameOrSourceURL");
2437 if (!name->IsString()) { 2316 if (!name->IsString()) {
2438 return Local<String>(); 2317 return Local<String>();
2439 } 2318 }
2440 return scope.Close(Local<String>::Cast(Utils::ToLocal(name))); 2319 return scope.Close(Local<String>::Cast(Utils::ToLocal(name)));
2441 } 2320 }
2442 2321
2443 2322
2444 Local<String> StackFrame::GetFunctionName() const { 2323 Local<String> StackFrame::GetFunctionName() const {
2445 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2324 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2446 if (IsDeadCheck(isolate, "v8::StackFrame::GetFunctionName()")) {
2447 return Local<String>();
2448 }
2449 ENTER_V8(isolate); 2325 ENTER_V8(isolate);
2450 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); 2326 HandleScope scope(reinterpret_cast<Isolate*>(isolate));
2451 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2327 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2452 i::Handle<i::Object> name = GetProperty(self, "functionName"); 2328 i::Handle<i::Object> name = GetProperty(self, "functionName");
2453 if (!name->IsString()) { 2329 if (!name->IsString()) {
2454 return Local<String>(); 2330 return Local<String>();
2455 } 2331 }
2456 return scope.Close(Local<String>::Cast(Utils::ToLocal(name))); 2332 return scope.Close(Local<String>::Cast(Utils::ToLocal(name)));
2457 } 2333 }
2458 2334
2459 2335
2460 bool StackFrame::IsEval() const { 2336 bool StackFrame::IsEval() const {
2461 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2337 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2462 if (IsDeadCheck(isolate, "v8::StackFrame::IsEval()")) return false;
2463 ENTER_V8(isolate); 2338 ENTER_V8(isolate);
2464 i::HandleScope scope(isolate); 2339 i::HandleScope scope(isolate);
2465 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2340 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2466 i::Handle<i::Object> is_eval = GetProperty(self, "isEval"); 2341 i::Handle<i::Object> is_eval = GetProperty(self, "isEval");
2467 return is_eval->IsTrue(); 2342 return is_eval->IsTrue();
2468 } 2343 }
2469 2344
2470 2345
2471 bool StackFrame::IsConstructor() const { 2346 bool StackFrame::IsConstructor() const {
2472 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2347 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2473 if (IsDeadCheck(isolate, "v8::StackFrame::IsConstructor()")) return false;
2474 ENTER_V8(isolate); 2348 ENTER_V8(isolate);
2475 i::HandleScope scope(isolate); 2349 i::HandleScope scope(isolate);
2476 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2350 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2477 i::Handle<i::Object> is_constructor = GetProperty(self, "isConstructor"); 2351 i::Handle<i::Object> is_constructor = GetProperty(self, "isConstructor");
2478 return is_constructor->IsTrue(); 2352 return is_constructor->IsTrue();
2479 } 2353 }
2480 2354
2481 2355
2482 // --- J S O N --- 2356 // --- J S O N ---
2483 2357
(...skipping 14 matching lines...) Expand all
2498 has_pending_exception = result.is_null(); 2372 has_pending_exception = result.is_null();
2499 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>()); 2373 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>());
2500 return Utils::ToLocal( 2374 return Utils::ToLocal(
2501 i::Handle<i::Object>::cast(scope.CloseAndEscape(result))); 2375 i::Handle<i::Object>::cast(scope.CloseAndEscape(result)));
2502 } 2376 }
2503 2377
2504 2378
2505 // --- D a t a --- 2379 // --- D a t a ---
2506 2380
2507 bool Value::FullIsUndefined() const { 2381 bool Value::FullIsUndefined() const {
2508 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsUndefined()")) {
2509 return false;
2510 }
2511 bool result = Utils::OpenHandle(this)->IsUndefined(); 2382 bool result = Utils::OpenHandle(this)->IsUndefined();
2512 ASSERT_EQ(result, QuickIsUndefined()); 2383 ASSERT_EQ(result, QuickIsUndefined());
2513 return result; 2384 return result;
2514 } 2385 }
2515 2386
2516 2387
2517 bool Value::FullIsNull() const { 2388 bool Value::FullIsNull() const {
2518 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsNull()")) return false;
2519 bool result = Utils::OpenHandle(this)->IsNull(); 2389 bool result = Utils::OpenHandle(this)->IsNull();
2520 ASSERT_EQ(result, QuickIsNull()); 2390 ASSERT_EQ(result, QuickIsNull());
2521 return result; 2391 return result;
2522 } 2392 }
2523 2393
2524 2394
2525 bool Value::IsTrue() const { 2395 bool Value::IsTrue() const {
2526 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsTrue()")) return false;
2527 return Utils::OpenHandle(this)->IsTrue(); 2396 return Utils::OpenHandle(this)->IsTrue();
2528 } 2397 }
2529 2398
2530 2399
2531 bool Value::IsFalse() const { 2400 bool Value::IsFalse() const {
2532 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsFalse()")) return false;
2533 return Utils::OpenHandle(this)->IsFalse(); 2401 return Utils::OpenHandle(this)->IsFalse();
2534 } 2402 }
2535 2403
2536 2404
2537 bool Value::IsFunction() const { 2405 bool Value::IsFunction() const {
2538 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsFunction()")) {
2539 return false;
2540 }
2541 return Utils::OpenHandle(this)->IsJSFunction(); 2406 return Utils::OpenHandle(this)->IsJSFunction();
2542 } 2407 }
2543 2408
2544 2409
2545 bool Value::FullIsString() const { 2410 bool Value::FullIsString() const {
2546 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsString()")) return false;
2547 bool result = Utils::OpenHandle(this)->IsString(); 2411 bool result = Utils::OpenHandle(this)->IsString();
2548 ASSERT_EQ(result, QuickIsString()); 2412 ASSERT_EQ(result, QuickIsString());
2549 return result; 2413 return result;
2550 } 2414 }
2551 2415
2552 2416
2553 bool Value::IsSymbol() const { 2417 bool Value::IsSymbol() const {
2554 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsSymbol()")) return false;
2555 return Utils::OpenHandle(this)->IsSymbol(); 2418 return Utils::OpenHandle(this)->IsSymbol();
2556 } 2419 }
2557 2420
2558 2421
2559 bool Value::IsArray() const { 2422 bool Value::IsArray() const {
2560 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsArray()")) return false;
2561 return Utils::OpenHandle(this)->IsJSArray(); 2423 return Utils::OpenHandle(this)->IsJSArray();
2562 } 2424 }
2563 2425
2564 2426
2565 bool Value::IsArrayBuffer() const { 2427 bool Value::IsArrayBuffer() const {
2566 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsArrayBuffer()"))
2567 return false;
2568 return Utils::OpenHandle(this)->IsJSArrayBuffer(); 2428 return Utils::OpenHandle(this)->IsJSArrayBuffer();
2569 } 2429 }
2570 2430
2571 2431
2572 bool Value::IsArrayBufferView() const { 2432 bool Value::IsArrayBufferView() const {
2573 return Utils::OpenHandle(this)->IsJSArrayBufferView(); 2433 return Utils::OpenHandle(this)->IsJSArrayBufferView();
2574 } 2434 }
2575 2435
2576 2436
2577 bool Value::IsTypedArray() const { 2437 bool Value::IsTypedArray() const {
2578 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsArrayBuffer()"))
2579 return false;
2580 return Utils::OpenHandle(this)->IsJSTypedArray(); 2438 return Utils::OpenHandle(this)->IsJSTypedArray();
2581 } 2439 }
2582 2440
2583 2441
2584 #define TYPED_ARRAY_LIST(F) \ 2442 #define TYPED_ARRAY_LIST(F) \
2585 F(Uint8Array, kExternalUnsignedByteArray) \ 2443 F(Uint8Array, kExternalUnsignedByteArray) \
2586 F(Int8Array, kExternalByteArray) \ 2444 F(Int8Array, kExternalByteArray) \
2587 F(Uint16Array, kExternalUnsignedShortArray) \ 2445 F(Uint16Array, kExternalUnsignedShortArray) \
2588 F(Int16Array, kExternalShortArray) \ 2446 F(Int16Array, kExternalShortArray) \
2589 F(Uint32Array, kExternalUnsignedIntArray) \ 2447 F(Uint32Array, kExternalUnsignedIntArray) \
2590 F(Int32Array, kExternalIntArray) \ 2448 F(Int32Array, kExternalIntArray) \
2591 F(Float32Array, kExternalFloatArray) \ 2449 F(Float32Array, kExternalFloatArray) \
2592 F(Float64Array, kExternalDoubleArray) \ 2450 F(Float64Array, kExternalDoubleArray) \
2593 F(Uint8ClampedArray, kExternalPixelArray) 2451 F(Uint8ClampedArray, kExternalPixelArray)
2594 2452
2595 2453
2596 #define VALUE_IS_TYPED_ARRAY(TypedArray, type_const) \ 2454 #define VALUE_IS_TYPED_ARRAY(TypedArray, type_const) \
2597 bool Value::Is##TypedArray() const { \ 2455 bool Value::Is##TypedArray() const { \
2598 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::Is" #TypedArray "()")) \
2599 return false; \
2600 i::Handle<i::Object> obj = Utils::OpenHandle(this); \ 2456 i::Handle<i::Object> obj = Utils::OpenHandle(this); \
2601 if (!obj->IsJSTypedArray()) return false; \ 2457 if (!obj->IsJSTypedArray()) return false; \
2602 return i::JSTypedArray::cast(*obj)->type() == type_const; \ 2458 return i::JSTypedArray::cast(*obj)->type() == type_const; \
2603 } 2459 }
2604 2460
2605 TYPED_ARRAY_LIST(VALUE_IS_TYPED_ARRAY) 2461 TYPED_ARRAY_LIST(VALUE_IS_TYPED_ARRAY)
2606 2462
2607 #undef VALUE_IS_TYPED_ARRAY 2463 #undef VALUE_IS_TYPED_ARRAY
2608 2464
2609 2465
2610 bool Value::IsDataView() const { 2466 bool Value::IsDataView() const {
2611 return Utils::OpenHandle(this)->IsJSDataView(); 2467 return Utils::OpenHandle(this)->IsJSDataView();
2612 } 2468 }
2613 2469
2614 2470
2615 bool Value::IsObject() const { 2471 bool Value::IsObject() const {
2616 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsObject()")) return false;
2617 return Utils::OpenHandle(this)->IsJSObject(); 2472 return Utils::OpenHandle(this)->IsJSObject();
2618 } 2473 }
2619 2474
2620 2475
2621 bool Value::IsNumber() const { 2476 bool Value::IsNumber() const {
2622 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsNumber()")) return false;
2623 return Utils::OpenHandle(this)->IsNumber(); 2477 return Utils::OpenHandle(this)->IsNumber();
2624 } 2478 }
2625 2479
2626 2480
2627 bool Value::IsBoolean() const { 2481 bool Value::IsBoolean() const {
2628 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsBoolean()")) {
2629 return false;
2630 }
2631 return Utils::OpenHandle(this)->IsBoolean(); 2482 return Utils::OpenHandle(this)->IsBoolean();
2632 } 2483 }
2633 2484
2634 2485
2635 bool Value::IsExternal() const { 2486 bool Value::IsExternal() const {
2636 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsExternal()")) {
2637 return false;
2638 }
2639 return Utils::OpenHandle(this)->IsExternal(); 2487 return Utils::OpenHandle(this)->IsExternal();
2640 } 2488 }
2641 2489
2642 2490
2643 bool Value::IsInt32() const { 2491 bool Value::IsInt32() const {
2644 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsInt32()")) return false;
2645 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2492 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2646 if (obj->IsSmi()) return true; 2493 if (obj->IsSmi()) return true;
2647 if (obj->IsNumber()) { 2494 if (obj->IsNumber()) {
2648 double value = obj->Number(); 2495 double value = obj->Number();
2649 static const i::DoubleRepresentation minus_zero(-0.0); 2496 static const i::DoubleRepresentation minus_zero(-0.0);
2650 i::DoubleRepresentation rep(value); 2497 i::DoubleRepresentation rep(value);
2651 if (rep.bits == minus_zero.bits) { 2498 if (rep.bits == minus_zero.bits) {
2652 return false; 2499 return false;
2653 } 2500 }
2654 return i::FastI2D(i::FastD2I(value)) == value; 2501 return i::FastI2D(i::FastD2I(value)) == value;
2655 } 2502 }
2656 return false; 2503 return false;
2657 } 2504 }
2658 2505
2659 2506
2660 bool Value::IsUint32() const { 2507 bool Value::IsUint32() const {
2661 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsUint32()")) return false;
2662 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2508 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2663 if (obj->IsSmi()) return i::Smi::cast(*obj)->value() >= 0; 2509 if (obj->IsSmi()) return i::Smi::cast(*obj)->value() >= 0;
2664 if (obj->IsNumber()) { 2510 if (obj->IsNumber()) {
2665 double value = obj->Number(); 2511 double value = obj->Number();
2666 static const i::DoubleRepresentation minus_zero(-0.0); 2512 static const i::DoubleRepresentation minus_zero(-0.0);
2667 i::DoubleRepresentation rep(value); 2513 i::DoubleRepresentation rep(value);
2668 if (rep.bits == minus_zero.bits) { 2514 if (rep.bits == minus_zero.bits) {
2669 return false; 2515 return false;
2670 } 2516 }
2671 return i::FastUI2D(i::FastD2UI(value)) == value; 2517 return i::FastUI2D(i::FastD2UI(value)) == value;
2672 } 2518 }
2673 return false; 2519 return false;
2674 } 2520 }
2675 2521
2676 2522
2677 bool Value::IsDate() const { 2523 bool Value::IsDate() const {
2678 i::Isolate* isolate = i::Isolate::Current(); 2524 i::Isolate* isolate = i::Isolate::Current();
2679 if (IsDeadCheck(isolate, "v8::Value::IsDate()")) return false;
2680 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2525 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2681 return obj->HasSpecificClassOf(isolate->heap()->Date_string()); 2526 return obj->HasSpecificClassOf(isolate->heap()->Date_string());
2682 } 2527 }
2683 2528
2684 2529
2685 bool Value::IsStringObject() const { 2530 bool Value::IsStringObject() const {
2686 i::Isolate* isolate = i::Isolate::Current(); 2531 i::Isolate* isolate = i::Isolate::Current();
2687 if (IsDeadCheck(isolate, "v8::Value::IsStringObject()")) return false;
2688 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2532 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2689 return obj->HasSpecificClassOf(isolate->heap()->String_string()); 2533 return obj->HasSpecificClassOf(isolate->heap()->String_string());
2690 } 2534 }
2691 2535
2692 2536
2693 bool Value::IsSymbolObject() const { 2537 bool Value::IsSymbolObject() const {
2694 // TODO(svenpanne): these and other test functions should be written such 2538 // TODO(svenpanne): these and other test functions should be written such
2695 // that they do not use Isolate::Current(). 2539 // that they do not use Isolate::Current().
2696 i::Isolate* isolate = i::Isolate::Current(); 2540 i::Isolate* isolate = i::Isolate::Current();
2697 if (IsDeadCheck(isolate, "v8::Value::IsSymbolObject()")) return false;
2698 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2541 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2699 return obj->HasSpecificClassOf(isolate->heap()->Symbol_string()); 2542 return obj->HasSpecificClassOf(isolate->heap()->Symbol_string());
2700 } 2543 }
2701 2544
2702 2545
2703 bool Value::IsNumberObject() const { 2546 bool Value::IsNumberObject() const {
2704 i::Isolate* isolate = i::Isolate::Current(); 2547 i::Isolate* isolate = i::Isolate::Current();
2705 if (IsDeadCheck(isolate, "v8::Value::IsNumberObject()")) return false;
2706 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2548 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2707 return obj->HasSpecificClassOf(isolate->heap()->Number_string()); 2549 return obj->HasSpecificClassOf(isolate->heap()->Number_string());
2708 } 2550 }
2709 2551
2710 2552
2711 static i::Object* LookupBuiltin(i::Isolate* isolate, 2553 static i::Object* LookupBuiltin(i::Isolate* isolate,
2712 const char* builtin_name) { 2554 const char* builtin_name) {
2713 i::Handle<i::String> string = 2555 i::Handle<i::String> string =
2714 isolate->factory()->InternalizeUtf8String(builtin_name); 2556 isolate->factory()->InternalizeUtf8String(builtin_name);
2715 i::Handle<i::JSBuiltinsObject> builtins = isolate->js_builtins_object(); 2557 i::Handle<i::JSBuiltinsObject> builtins = isolate->js_builtins_object();
2716 return builtins->GetPropertyNoExceptionThrown(*string); 2558 return builtins->GetPropertyNoExceptionThrown(*string);
2717 } 2559 }
2718 2560
2719 2561
2720 static bool CheckConstructor(i::Isolate* isolate, 2562 static bool CheckConstructor(i::Isolate* isolate,
2721 i::Handle<i::JSObject> obj, 2563 i::Handle<i::JSObject> obj,
2722 const char* class_name) { 2564 const char* class_name) {
2723 i::Object* constr = obj->map()->constructor(); 2565 i::Object* constr = obj->map()->constructor();
2724 if (!constr->IsJSFunction()) return false; 2566 if (!constr->IsJSFunction()) return false;
2725 i::JSFunction* func = i::JSFunction::cast(constr); 2567 i::JSFunction* func = i::JSFunction::cast(constr);
2726 return func->shared()->native() && 2568 return func->shared()->native() &&
2727 constr == LookupBuiltin(isolate, class_name); 2569 constr == LookupBuiltin(isolate, class_name);
2728 } 2570 }
2729 2571
2730 2572
2731 bool Value::IsNativeError() const { 2573 bool Value::IsNativeError() const {
2732 i::Isolate* isolate = i::Isolate::Current(); 2574 i::Isolate* isolate = i::Isolate::Current();
2733 if (IsDeadCheck(isolate, "v8::Value::IsNativeError()")) return false;
2734 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2575 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2735 if (obj->IsJSObject()) { 2576 if (obj->IsJSObject()) {
2736 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*obj)); 2577 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*obj));
2737 return CheckConstructor(isolate, js_obj, "$Error") || 2578 return CheckConstructor(isolate, js_obj, "$Error") ||
2738 CheckConstructor(isolate, js_obj, "$EvalError") || 2579 CheckConstructor(isolate, js_obj, "$EvalError") ||
2739 CheckConstructor(isolate, js_obj, "$RangeError") || 2580 CheckConstructor(isolate, js_obj, "$RangeError") ||
2740 CheckConstructor(isolate, js_obj, "$ReferenceError") || 2581 CheckConstructor(isolate, js_obj, "$ReferenceError") ||
2741 CheckConstructor(isolate, js_obj, "$SyntaxError") || 2582 CheckConstructor(isolate, js_obj, "$SyntaxError") ||
2742 CheckConstructor(isolate, js_obj, "$TypeError") || 2583 CheckConstructor(isolate, js_obj, "$TypeError") ||
2743 CheckConstructor(isolate, js_obj, "$URIError"); 2584 CheckConstructor(isolate, js_obj, "$URIError");
2744 } else { 2585 } else {
2745 return false; 2586 return false;
2746 } 2587 }
2747 } 2588 }
2748 2589
2749 2590
2750 bool Value::IsBooleanObject() const { 2591 bool Value::IsBooleanObject() const {
2751 i::Isolate* isolate = i::Isolate::Current(); 2592 i::Isolate* isolate = i::Isolate::Current();
2752 if (IsDeadCheck(isolate, "v8::Value::IsBooleanObject()")) return false;
2753 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2593 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2754 return obj->HasSpecificClassOf(isolate->heap()->Boolean_string()); 2594 return obj->HasSpecificClassOf(isolate->heap()->Boolean_string());
2755 } 2595 }
2756 2596
2757 2597
2758 bool Value::IsRegExp() const { 2598 bool Value::IsRegExp() const {
2759 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsRegExp()")) return false;
2760 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2599 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2761 return obj->IsJSRegExp(); 2600 return obj->IsJSRegExp();
2762 } 2601 }
2763 2602
2764 2603
2765 Local<String> Value::ToString() const { 2604 Local<String> Value::ToString() const {
2766 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2605 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2767 i::Handle<i::Object> str; 2606 i::Handle<i::Object> str;
2768 if (obj->IsString()) { 2607 if (obj->IsString()) {
2769 str = obj; 2608 str = obj;
2770 } else { 2609 } else {
2771 i::Isolate* isolate = i::Isolate::Current(); 2610 i::Isolate* isolate = i::Isolate::Current();
2772 if (IsDeadCheck(isolate, "v8::Value::ToString()")) {
2773 return Local<String>();
2774 }
2775 LOG_API(isolate, "ToString"); 2611 LOG_API(isolate, "ToString");
2776 ENTER_V8(isolate); 2612 ENTER_V8(isolate);
2777 EXCEPTION_PREAMBLE(isolate); 2613 EXCEPTION_PREAMBLE(isolate);
2778 str = i::Execution::ToString(isolate, obj, &has_pending_exception); 2614 str = i::Execution::ToString(isolate, obj, &has_pending_exception);
2779 EXCEPTION_BAILOUT_CHECK(isolate, Local<String>()); 2615 EXCEPTION_BAILOUT_CHECK(isolate, Local<String>());
2780 } 2616 }
2781 return ToApiHandle<String>(str); 2617 return ToApiHandle<String>(str);
2782 } 2618 }
2783 2619
2784 2620
2785 Local<String> Value::ToDetailString() const { 2621 Local<String> Value::ToDetailString() const {
2786 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2622 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2787 i::Handle<i::Object> str; 2623 i::Handle<i::Object> str;
2788 if (obj->IsString()) { 2624 if (obj->IsString()) {
2789 str = obj; 2625 str = obj;
2790 } else { 2626 } else {
2791 i::Isolate* isolate = i::Isolate::Current(); 2627 i::Isolate* isolate = i::Isolate::Current();
2792 if (IsDeadCheck(isolate, "v8::Value::ToDetailString()")) {
2793 return Local<String>();
2794 }
2795 LOG_API(isolate, "ToDetailString"); 2628 LOG_API(isolate, "ToDetailString");
2796 ENTER_V8(isolate); 2629 ENTER_V8(isolate);
2797 EXCEPTION_PREAMBLE(isolate); 2630 EXCEPTION_PREAMBLE(isolate);
2798 str = i::Execution::ToDetailString(isolate, obj, &has_pending_exception); 2631 str = i::Execution::ToDetailString(isolate, obj, &has_pending_exception);
2799 EXCEPTION_BAILOUT_CHECK(isolate, Local<String>()); 2632 EXCEPTION_BAILOUT_CHECK(isolate, Local<String>());
2800 } 2633 }
2801 return ToApiHandle<String>(str); 2634 return ToApiHandle<String>(str);
2802 } 2635 }
2803 2636
2804 2637
2805 Local<v8::Object> Value::ToObject() const { 2638 Local<v8::Object> Value::ToObject() const {
2806 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2639 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2807 i::Handle<i::Object> val; 2640 i::Handle<i::Object> val;
2808 if (obj->IsJSObject()) { 2641 if (obj->IsJSObject()) {
2809 val = obj; 2642 val = obj;
2810 } else { 2643 } else {
2811 i::Isolate* isolate = i::Isolate::Current(); 2644 i::Isolate* isolate = i::Isolate::Current();
2812 if (IsDeadCheck(isolate, "v8::Value::ToObject()")) {
2813 return Local<v8::Object>();
2814 }
2815 LOG_API(isolate, "ToObject"); 2645 LOG_API(isolate, "ToObject");
2816 ENTER_V8(isolate); 2646 ENTER_V8(isolate);
2817 EXCEPTION_PREAMBLE(isolate); 2647 EXCEPTION_PREAMBLE(isolate);
2818 val = i::Execution::ToObject(isolate, obj, &has_pending_exception); 2648 val = i::Execution::ToObject(isolate, obj, &has_pending_exception);
2819 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>()); 2649 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>());
2820 } 2650 }
2821 return ToApiHandle<Object>(val); 2651 return ToApiHandle<Object>(val);
2822 } 2652 }
2823 2653
2824 2654
2825 Local<Boolean> Value::ToBoolean() const { 2655 Local<Boolean> Value::ToBoolean() const {
2826 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2656 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2827 if (obj->IsBoolean()) { 2657 if (obj->IsBoolean()) {
2828 return ToApiHandle<Boolean>(obj); 2658 return ToApiHandle<Boolean>(obj);
2829 } else { 2659 } else {
2830 i::Isolate* isolate = i::Isolate::Current(); 2660 i::Isolate* isolate = i::Isolate::Current();
2831 if (IsDeadCheck(isolate, "v8::Value::ToBoolean()")) {
2832 return Local<Boolean>();
2833 }
2834 LOG_API(isolate, "ToBoolean"); 2661 LOG_API(isolate, "ToBoolean");
2835 ENTER_V8(isolate); 2662 ENTER_V8(isolate);
2836 i::Handle<i::Object> val = 2663 i::Handle<i::Object> val =
2837 isolate->factory()->ToBoolean(obj->BooleanValue()); 2664 isolate->factory()->ToBoolean(obj->BooleanValue());
2838 return ToApiHandle<Boolean>(val); 2665 return ToApiHandle<Boolean>(val);
2839 } 2666 }
2840 } 2667 }
2841 2668
2842 2669
2843 Local<Number> Value::ToNumber() const { 2670 Local<Number> Value::ToNumber() const {
2844 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2671 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2845 i::Handle<i::Object> num; 2672 i::Handle<i::Object> num;
2846 if (obj->IsNumber()) { 2673 if (obj->IsNumber()) {
2847 num = obj; 2674 num = obj;
2848 } else { 2675 } else {
2849 i::Isolate* isolate = i::Isolate::Current(); 2676 i::Isolate* isolate = i::Isolate::Current();
2850 if (IsDeadCheck(isolate, "v8::Value::ToNumber()")) {
2851 return Local<Number>();
2852 }
2853 LOG_API(isolate, "ToNumber"); 2677 LOG_API(isolate, "ToNumber");
2854 ENTER_V8(isolate); 2678 ENTER_V8(isolate);
2855 EXCEPTION_PREAMBLE(isolate); 2679 EXCEPTION_PREAMBLE(isolate);
2856 num = i::Execution::ToNumber(isolate, obj, &has_pending_exception); 2680 num = i::Execution::ToNumber(isolate, obj, &has_pending_exception);
2857 EXCEPTION_BAILOUT_CHECK(isolate, Local<Number>()); 2681 EXCEPTION_BAILOUT_CHECK(isolate, Local<Number>());
2858 } 2682 }
2859 return ToApiHandle<Number>(num); 2683 return ToApiHandle<Number>(num);
2860 } 2684 }
2861 2685
2862 2686
2863 Local<Integer> Value::ToInteger() const { 2687 Local<Integer> Value::ToInteger() const {
2864 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2688 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2865 i::Handle<i::Object> num; 2689 i::Handle<i::Object> num;
2866 if (obj->IsSmi()) { 2690 if (obj->IsSmi()) {
2867 num = obj; 2691 num = obj;
2868 } else { 2692 } else {
2869 i::Isolate* isolate = i::Isolate::Current(); 2693 i::Isolate* isolate = i::Isolate::Current();
2870 if (IsDeadCheck(isolate, "v8::Value::ToInteger()")) return Local<Integer>();
2871 LOG_API(isolate, "ToInteger"); 2694 LOG_API(isolate, "ToInteger");
2872 ENTER_V8(isolate); 2695 ENTER_V8(isolate);
2873 EXCEPTION_PREAMBLE(isolate); 2696 EXCEPTION_PREAMBLE(isolate);
2874 num = i::Execution::ToInteger(isolate, obj, &has_pending_exception); 2697 num = i::Execution::ToInteger(isolate, obj, &has_pending_exception);
2875 EXCEPTION_BAILOUT_CHECK(isolate, Local<Integer>()); 2698 EXCEPTION_BAILOUT_CHECK(isolate, Local<Integer>());
2876 } 2699 }
2877 return ToApiHandle<Integer>(num); 2700 return ToApiHandle<Integer>(num);
2878 } 2701 }
2879 2702
2880 2703
2881 void i::Internals::CheckInitializedImpl(v8::Isolate* external_isolate) { 2704 void i::Internals::CheckInitializedImpl(v8::Isolate* external_isolate) {
2882 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate); 2705 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate);
2883 ApiCheck(isolate != NULL && isolate->IsInitialized() && !isolate->IsDead(), 2706 ApiCheck(isolate != NULL && isolate->IsInitialized() && !isolate->IsDead(),
2884 "v8::internal::Internals::CheckInitialized()", 2707 "v8::internal::Internals::CheckInitialized()",
2885 "Isolate is not initialized or V8 has died"); 2708 "Isolate is not initialized or V8 has died");
2886 } 2709 }
2887 2710
2888 2711
2889 void External::CheckCast(v8::Value* that) { 2712 void External::CheckCast(v8::Value* that) {
2890 if (IsDeadCheck(i::Isolate::Current(), "v8::External::Cast()")) return;
2891 ApiCheck(Utils::OpenHandle(that)->IsExternal(), 2713 ApiCheck(Utils::OpenHandle(that)->IsExternal(),
2892 "v8::External::Cast()", 2714 "v8::External::Cast()",
2893 "Could not convert to external"); 2715 "Could not convert to external");
2894 } 2716 }
2895 2717
2896 2718
2897 void v8::Object::CheckCast(Value* that) { 2719 void v8::Object::CheckCast(Value* that) {
2898 if (IsDeadCheck(i::Isolate::Current(), "v8::Object::Cast()")) return;
2899 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2720 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2900 ApiCheck(obj->IsJSObject(), 2721 ApiCheck(obj->IsJSObject(),
2901 "v8::Object::Cast()", 2722 "v8::Object::Cast()",
2902 "Could not convert to object"); 2723 "Could not convert to object");
2903 } 2724 }
2904 2725
2905 2726
2906 void v8::Function::CheckCast(Value* that) { 2727 void v8::Function::CheckCast(Value* that) {
2907 if (IsDeadCheck(i::Isolate::Current(), "v8::Function::Cast()")) return;
2908 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2728 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2909 ApiCheck(obj->IsJSFunction(), 2729 ApiCheck(obj->IsJSFunction(),
2910 "v8::Function::Cast()", 2730 "v8::Function::Cast()",
2911 "Could not convert to function"); 2731 "Could not convert to function");
2912 } 2732 }
2913 2733
2914 2734
2915 void v8::String::CheckCast(v8::Value* that) { 2735 void v8::String::CheckCast(v8::Value* that) {
2916 if (IsDeadCheck(i::Isolate::Current(), "v8::String::Cast()")) return;
2917 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2736 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2918 ApiCheck(obj->IsString(), 2737 ApiCheck(obj->IsString(),
2919 "v8::String::Cast()", 2738 "v8::String::Cast()",
2920 "Could not convert to string"); 2739 "Could not convert to string");
2921 } 2740 }
2922 2741
2923 2742
2924 void v8::Symbol::CheckCast(v8::Value* that) { 2743 void v8::Symbol::CheckCast(v8::Value* that) {
2925 if (IsDeadCheck(i::Isolate::Current(), "v8::Symbol::Cast()")) return;
2926 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2744 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2927 ApiCheck(obj->IsSymbol(), 2745 ApiCheck(obj->IsSymbol(),
2928 "v8::Symbol::Cast()", 2746 "v8::Symbol::Cast()",
2929 "Could not convert to symbol"); 2747 "Could not convert to symbol");
2930 } 2748 }
2931 2749
2932 2750
2933 void v8::Number::CheckCast(v8::Value* that) { 2751 void v8::Number::CheckCast(v8::Value* that) {
2934 if (IsDeadCheck(i::Isolate::Current(), "v8::Number::Cast()")) return;
2935 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2752 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2936 ApiCheck(obj->IsNumber(), 2753 ApiCheck(obj->IsNumber(),
2937 "v8::Number::Cast()", 2754 "v8::Number::Cast()",
2938 "Could not convert to number"); 2755 "Could not convert to number");
2939 } 2756 }
2940 2757
2941 2758
2942 void v8::Integer::CheckCast(v8::Value* that) { 2759 void v8::Integer::CheckCast(v8::Value* that) {
2943 if (IsDeadCheck(i::Isolate::Current(), "v8::Integer::Cast()")) return;
2944 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2760 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2945 ApiCheck(obj->IsNumber(), 2761 ApiCheck(obj->IsNumber(),
2946 "v8::Integer::Cast()", 2762 "v8::Integer::Cast()",
2947 "Could not convert to number"); 2763 "Could not convert to number");
2948 } 2764 }
2949 2765
2950 2766
2951 void v8::Array::CheckCast(Value* that) { 2767 void v8::Array::CheckCast(Value* that) {
2952 if (IsDeadCheck(i::Isolate::Current(), "v8::Array::Cast()")) return;
2953 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2768 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2954 ApiCheck(obj->IsJSArray(), 2769 ApiCheck(obj->IsJSArray(),
2955 "v8::Array::Cast()", 2770 "v8::Array::Cast()",
2956 "Could not convert to array"); 2771 "Could not convert to array");
2957 } 2772 }
2958 2773
2959 2774
2960 void v8::ArrayBuffer::CheckCast(Value* that) { 2775 void v8::ArrayBuffer::CheckCast(Value* that) {
2961 if (IsDeadCheck(i::Isolate::Current(), "v8::ArrayBuffer::Cast()")) return;
2962 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2776 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2963 ApiCheck(obj->IsJSArrayBuffer(), 2777 ApiCheck(obj->IsJSArrayBuffer(),
2964 "v8::ArrayBuffer::Cast()", 2778 "v8::ArrayBuffer::Cast()",
2965 "Could not convert to ArrayBuffer"); 2779 "Could not convert to ArrayBuffer");
2966 } 2780 }
2967 2781
2968 2782
2969 void v8::ArrayBufferView::CheckCast(Value* that) { 2783 void v8::ArrayBufferView::CheckCast(Value* that) {
2970 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2784 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2971 ApiCheck(obj->IsJSArrayBufferView(), 2785 ApiCheck(obj->IsJSArrayBufferView(),
2972 "v8::ArrayBufferView::Cast()", 2786 "v8::ArrayBufferView::Cast()",
2973 "Could not convert to ArrayBufferView"); 2787 "Could not convert to ArrayBufferView");
2974 } 2788 }
2975 2789
2976 2790
2977 void v8::TypedArray::CheckCast(Value* that) { 2791 void v8::TypedArray::CheckCast(Value* that) {
2978 if (IsDeadCheck(i::Isolate::Current(), "v8::TypedArray::Cast()")) return;
2979 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2792 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2980 ApiCheck(obj->IsJSTypedArray(), 2793 ApiCheck(obj->IsJSTypedArray(),
2981 "v8::TypedArray::Cast()", 2794 "v8::TypedArray::Cast()",
2982 "Could not convert to TypedArray"); 2795 "Could not convert to TypedArray");
2983 } 2796 }
2984 2797
2985 2798
2986 #define CHECK_TYPED_ARRAY_CAST(ApiClass, typeConst) \ 2799 #define CHECK_TYPED_ARRAY_CAST(ApiClass, typeConst) \
2987 void v8::ApiClass::CheckCast(Value* that) { \ 2800 void v8::ApiClass::CheckCast(Value* that) { \
2988 if (IsDeadCheck(i::Isolate::Current(), "v8::" #ApiClass "::Cast()")) \
2989 return; \
2990 i::Handle<i::Object> obj = Utils::OpenHandle(that); \ 2801 i::Handle<i::Object> obj = Utils::OpenHandle(that); \
2991 ApiCheck(obj->IsJSTypedArray() && \ 2802 ApiCheck(obj->IsJSTypedArray() && \
2992 i::JSTypedArray::cast(*obj)->type() == typeConst, \ 2803 i::JSTypedArray::cast(*obj)->type() == typeConst, \
2993 "v8::" #ApiClass "::Cast()", \ 2804 "v8::" #ApiClass "::Cast()", \
2994 "Could not convert to " #ApiClass); \ 2805 "Could not convert to " #ApiClass); \
2995 } 2806 }
2996 2807
2997 2808
2998 TYPED_ARRAY_LIST(CHECK_TYPED_ARRAY_CAST) 2809 TYPED_ARRAY_LIST(CHECK_TYPED_ARRAY_CAST)
2999 2810
3000 #undef CHECK_TYPED_ARRAY_CAST 2811 #undef CHECK_TYPED_ARRAY_CAST
3001 2812
3002 2813
3003 void v8::DataView::CheckCast(Value* that) { 2814 void v8::DataView::CheckCast(Value* that) {
3004 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2815 i::Handle<i::Object> obj = Utils::OpenHandle(that);
3005 ApiCheck(obj->IsJSDataView(), 2816 ApiCheck(obj->IsJSDataView(),
3006 "v8::DataView::Cast()", 2817 "v8::DataView::Cast()",
3007 "Could not convert to DataView"); 2818 "Could not convert to DataView");
3008 } 2819 }
3009 2820
3010 2821
3011 void v8::Date::CheckCast(v8::Value* that) { 2822 void v8::Date::CheckCast(v8::Value* that) {
3012 i::Isolate* isolate = i::Isolate::Current(); 2823 i::Isolate* isolate = i::Isolate::Current();
3013 if (IsDeadCheck(isolate, "v8::Date::Cast()")) return;
3014 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2824 i::Handle<i::Object> obj = Utils::OpenHandle(that);
3015 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Date_string()), 2825 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Date_string()),
3016 "v8::Date::Cast()", 2826 "v8::Date::Cast()",
3017 "Could not convert to date"); 2827 "Could not convert to date");
3018 } 2828 }
3019 2829
3020 2830
3021 void v8::StringObject::CheckCast(v8::Value* that) { 2831 void v8::StringObject::CheckCast(v8::Value* that) {
3022 i::Isolate* isolate = i::Isolate::Current(); 2832 i::Isolate* isolate = i::Isolate::Current();
3023 if (IsDeadCheck(isolate, "v8::StringObject::Cast()")) return;
3024 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2833 i::Handle<i::Object> obj = Utils::OpenHandle(that);
3025 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->String_string()), 2834 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->String_string()),
3026 "v8::StringObject::Cast()", 2835 "v8::StringObject::Cast()",
3027 "Could not convert to StringObject"); 2836 "Could not convert to StringObject");
3028 } 2837 }
3029 2838
3030 2839
3031 void v8::SymbolObject::CheckCast(v8::Value* that) { 2840 void v8::SymbolObject::CheckCast(v8::Value* that) {
3032 i::Isolate* isolate = i::Isolate::Current(); 2841 i::Isolate* isolate = i::Isolate::Current();
3033 if (IsDeadCheck(isolate, "v8::SymbolObject::Cast()")) return;
3034 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2842 i::Handle<i::Object> obj = Utils::OpenHandle(that);
3035 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Symbol_string()), 2843 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Symbol_string()),
3036 "v8::SymbolObject::Cast()", 2844 "v8::SymbolObject::Cast()",
3037 "Could not convert to SymbolObject"); 2845 "Could not convert to SymbolObject");
3038 } 2846 }
3039 2847
3040 2848
3041 void v8::NumberObject::CheckCast(v8::Value* that) { 2849 void v8::NumberObject::CheckCast(v8::Value* that) {
3042 i::Isolate* isolate = i::Isolate::Current(); 2850 i::Isolate* isolate = i::Isolate::Current();
3043 if (IsDeadCheck(isolate, "v8::NumberObject::Cast()")) return;
3044 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2851 i::Handle<i::Object> obj = Utils::OpenHandle(that);
3045 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Number_string()), 2852 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Number_string()),
3046 "v8::NumberObject::Cast()", 2853 "v8::NumberObject::Cast()",
3047 "Could not convert to NumberObject"); 2854 "Could not convert to NumberObject");
3048 } 2855 }
3049 2856
3050 2857
3051 void v8::BooleanObject::CheckCast(v8::Value* that) { 2858 void v8::BooleanObject::CheckCast(v8::Value* that) {
3052 i::Isolate* isolate = i::Isolate::Current(); 2859 i::Isolate* isolate = i::Isolate::Current();
3053 if (IsDeadCheck(isolate, "v8::BooleanObject::Cast()")) return;
3054 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2860 i::Handle<i::Object> obj = Utils::OpenHandle(that);
3055 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Boolean_string()), 2861 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Boolean_string()),
3056 "v8::BooleanObject::Cast()", 2862 "v8::BooleanObject::Cast()",
3057 "Could not convert to BooleanObject"); 2863 "Could not convert to BooleanObject");
3058 } 2864 }
3059 2865
3060 2866
3061 void v8::RegExp::CheckCast(v8::Value* that) { 2867 void v8::RegExp::CheckCast(v8::Value* that) {
3062 if (IsDeadCheck(i::Isolate::Current(), "v8::RegExp::Cast()")) return;
3063 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2868 i::Handle<i::Object> obj = Utils::OpenHandle(that);
3064 ApiCheck(obj->IsJSRegExp(), 2869 ApiCheck(obj->IsJSRegExp(),
3065 "v8::RegExp::Cast()", 2870 "v8::RegExp::Cast()",
3066 "Could not convert to regular expression"); 2871 "Could not convert to regular expression");
3067 } 2872 }
3068 2873
3069 2874
3070 bool Value::BooleanValue() const { 2875 bool Value::BooleanValue() const {
3071 return Utils::OpenHandle(this)->BooleanValue(); 2876 return Utils::OpenHandle(this)->BooleanValue();
3072 } 2877 }
3073 2878
3074 2879
3075 double Value::NumberValue() const { 2880 double Value::NumberValue() const {
3076 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2881 i::Handle<i::Object> obj = Utils::OpenHandle(this);
3077 i::Handle<i::Object> num; 2882 i::Handle<i::Object> num;
3078 if (obj->IsNumber()) { 2883 if (obj->IsNumber()) {
3079 num = obj; 2884 num = obj;
3080 } else { 2885 } else {
3081 i::Isolate* isolate = i::Isolate::Current(); 2886 i::Isolate* isolate = i::Isolate::Current();
3082 if (IsDeadCheck(isolate, "v8::Value::NumberValue()")) {
3083 return i::OS::nan_value();
3084 }
3085 LOG_API(isolate, "NumberValue"); 2887 LOG_API(isolate, "NumberValue");
3086 ENTER_V8(isolate); 2888 ENTER_V8(isolate);
3087 EXCEPTION_PREAMBLE(isolate); 2889 EXCEPTION_PREAMBLE(isolate);
3088 num = i::Execution::ToNumber(isolate, obj, &has_pending_exception); 2890 num = i::Execution::ToNumber(isolate, obj, &has_pending_exception);
3089 EXCEPTION_BAILOUT_CHECK(isolate, i::OS::nan_value()); 2891 EXCEPTION_BAILOUT_CHECK(isolate, i::OS::nan_value());
3090 } 2892 }
3091 return num->Number(); 2893 return num->Number();
3092 } 2894 }
3093 2895
3094 2896
3095 int64_t Value::IntegerValue() const { 2897 int64_t Value::IntegerValue() const {
3096 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2898 i::Handle<i::Object> obj = Utils::OpenHandle(this);
3097 i::Handle<i::Object> num; 2899 i::Handle<i::Object> num;
3098 if (obj->IsNumber()) { 2900 if (obj->IsNumber()) {
3099 num = obj; 2901 num = obj;
3100 } else { 2902 } else {
3101 i::Isolate* isolate = i::Isolate::Current(); 2903 i::Isolate* isolate = i::Isolate::Current();
3102 if (IsDeadCheck(isolate, "v8::Value::IntegerValue()")) return 0;
3103 LOG_API(isolate, "IntegerValue"); 2904 LOG_API(isolate, "IntegerValue");
3104 ENTER_V8(isolate); 2905 ENTER_V8(isolate);
3105 EXCEPTION_PREAMBLE(isolate); 2906 EXCEPTION_PREAMBLE(isolate);
3106 num = i::Execution::ToInteger(isolate, obj, &has_pending_exception); 2907 num = i::Execution::ToInteger(isolate, obj, &has_pending_exception);
3107 EXCEPTION_BAILOUT_CHECK(isolate, 0); 2908 EXCEPTION_BAILOUT_CHECK(isolate, 0);
3108 } 2909 }
3109 if (num->IsSmi()) { 2910 if (num->IsSmi()) {
3110 return i::Smi::cast(*num)->value(); 2911 return i::Smi::cast(*num)->value();
3111 } else { 2912 } else {
3112 return static_cast<int64_t>(num->Number()); 2913 return static_cast<int64_t>(num->Number());
3113 } 2914 }
3114 } 2915 }
3115 2916
3116 2917
3117 Local<Int32> Value::ToInt32() const { 2918 Local<Int32> Value::ToInt32() const {
3118 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2919 i::Handle<i::Object> obj = Utils::OpenHandle(this);
3119 i::Handle<i::Object> num; 2920 i::Handle<i::Object> num;
3120 if (obj->IsSmi()) { 2921 if (obj->IsSmi()) {
3121 num = obj; 2922 num = obj;
3122 } else { 2923 } else {
3123 i::Isolate* isolate = i::Isolate::Current(); 2924 i::Isolate* isolate = i::Isolate::Current();
3124 if (IsDeadCheck(isolate, "v8::Value::ToInt32()")) return Local<Int32>();
3125 LOG_API(isolate, "ToInt32"); 2925 LOG_API(isolate, "ToInt32");
3126 ENTER_V8(isolate); 2926 ENTER_V8(isolate);
3127 EXCEPTION_PREAMBLE(isolate); 2927 EXCEPTION_PREAMBLE(isolate);
3128 num = i::Execution::ToInt32(isolate, obj, &has_pending_exception); 2928 num = i::Execution::ToInt32(isolate, obj, &has_pending_exception);
3129 EXCEPTION_BAILOUT_CHECK(isolate, Local<Int32>()); 2929 EXCEPTION_BAILOUT_CHECK(isolate, Local<Int32>());
3130 } 2930 }
3131 return ToApiHandle<Int32>(num); 2931 return ToApiHandle<Int32>(num);
3132 } 2932 }
3133 2933
3134 2934
3135 Local<Uint32> Value::ToUint32() const { 2935 Local<Uint32> Value::ToUint32() const {
3136 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2936 i::Handle<i::Object> obj = Utils::OpenHandle(this);
3137 i::Handle<i::Object> num; 2937 i::Handle<i::Object> num;
3138 if (obj->IsSmi()) { 2938 if (obj->IsSmi()) {
3139 num = obj; 2939 num = obj;
3140 } else { 2940 } else {
3141 i::Isolate* isolate = i::Isolate::Current(); 2941 i::Isolate* isolate = i::Isolate::Current();
3142 if (IsDeadCheck(isolate, "v8::Value::ToUint32()")) return Local<Uint32>();
3143 LOG_API(isolate, "ToUInt32"); 2942 LOG_API(isolate, "ToUInt32");
3144 ENTER_V8(isolate); 2943 ENTER_V8(isolate);
3145 EXCEPTION_PREAMBLE(isolate); 2944 EXCEPTION_PREAMBLE(isolate);
3146 num = i::Execution::ToUint32(isolate, obj, &has_pending_exception); 2945 num = i::Execution::ToUint32(isolate, obj, &has_pending_exception);
3147 EXCEPTION_BAILOUT_CHECK(isolate, Local<Uint32>()); 2946 EXCEPTION_BAILOUT_CHECK(isolate, Local<Uint32>());
3148 } 2947 }
3149 return ToApiHandle<Uint32>(num); 2948 return ToApiHandle<Uint32>(num);
3150 } 2949 }
3151 2950
3152 2951
3153 Local<Uint32> Value::ToArrayIndex() const { 2952 Local<Uint32> Value::ToArrayIndex() const {
3154 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2953 i::Handle<i::Object> obj = Utils::OpenHandle(this);
3155 if (obj->IsSmi()) { 2954 if (obj->IsSmi()) {
3156 if (i::Smi::cast(*obj)->value() >= 0) return Utils::Uint32ToLocal(obj); 2955 if (i::Smi::cast(*obj)->value() >= 0) return Utils::Uint32ToLocal(obj);
3157 return Local<Uint32>(); 2956 return Local<Uint32>();
3158 } 2957 }
3159 i::Isolate* isolate = i::Isolate::Current(); 2958 i::Isolate* isolate = i::Isolate::Current();
3160 if (IsDeadCheck(isolate, "v8::Value::ToArrayIndex()")) return Local<Uint32>();
3161 LOG_API(isolate, "ToArrayIndex"); 2959 LOG_API(isolate, "ToArrayIndex");
3162 ENTER_V8(isolate); 2960 ENTER_V8(isolate);
3163 EXCEPTION_PREAMBLE(isolate); 2961 EXCEPTION_PREAMBLE(isolate);
3164 i::Handle<i::Object> string_obj = 2962 i::Handle<i::Object> string_obj =
3165 i::Execution::ToString(isolate, obj, &has_pending_exception); 2963 i::Execution::ToString(isolate, obj, &has_pending_exception);
3166 EXCEPTION_BAILOUT_CHECK(isolate, Local<Uint32>()); 2964 EXCEPTION_BAILOUT_CHECK(isolate, Local<Uint32>());
3167 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);
3168 uint32_t index; 2966 uint32_t index;
3169 if (str->AsArrayIndex(&index)) { 2967 if (str->AsArrayIndex(&index)) {
3170 i::Handle<i::Object> value; 2968 i::Handle<i::Object> value;
3171 if (index <= static_cast<uint32_t>(i::Smi::kMaxValue)) { 2969 if (index <= static_cast<uint32_t>(i::Smi::kMaxValue)) {
3172 value = i::Handle<i::Object>(i::Smi::FromInt(index), isolate); 2970 value = i::Handle<i::Object>(i::Smi::FromInt(index), isolate);
3173 } else { 2971 } else {
3174 value = isolate->factory()->NewNumber(index); 2972 value = isolate->factory()->NewNumber(index);
3175 } 2973 }
3176 return Utils::Uint32ToLocal(value); 2974 return Utils::Uint32ToLocal(value);
3177 } 2975 }
3178 return Local<Uint32>(); 2976 return Local<Uint32>();
3179 } 2977 }
3180 2978
3181 2979
3182 int32_t Value::Int32Value() const { 2980 int32_t Value::Int32Value() const {
3183 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2981 i::Handle<i::Object> obj = Utils::OpenHandle(this);
3184 if (obj->IsSmi()) { 2982 if (obj->IsSmi()) {
3185 return i::Smi::cast(*obj)->value(); 2983 return i::Smi::cast(*obj)->value();
3186 } else { 2984 } else {
3187 i::Isolate* isolate = i::Isolate::Current(); 2985 i::Isolate* isolate = i::Isolate::Current();
3188 if (IsDeadCheck(isolate, "v8::Value::Int32Value()")) return 0;
3189 LOG_API(isolate, "Int32Value (slow)"); 2986 LOG_API(isolate, "Int32Value (slow)");
3190 ENTER_V8(isolate); 2987 ENTER_V8(isolate);
3191 EXCEPTION_PREAMBLE(isolate); 2988 EXCEPTION_PREAMBLE(isolate);
3192 i::Handle<i::Object> num = 2989 i::Handle<i::Object> num =
3193 i::Execution::ToInt32(isolate, obj, &has_pending_exception); 2990 i::Execution::ToInt32(isolate, obj, &has_pending_exception);
3194 EXCEPTION_BAILOUT_CHECK(isolate, 0); 2991 EXCEPTION_BAILOUT_CHECK(isolate, 0);
3195 if (num->IsSmi()) { 2992 if (num->IsSmi()) {
3196 return i::Smi::cast(*num)->value(); 2993 return i::Smi::cast(*num)->value();
3197 } else { 2994 } else {
3198 return static_cast<int32_t>(num->Number()); 2995 return static_cast<int32_t>(num->Number());
3199 } 2996 }
3200 } 2997 }
3201 } 2998 }
3202 2999
3203 3000
3204 bool Value::Equals(Handle<Value> that) const { 3001 bool Value::Equals(Handle<Value> that) const {
3205 i::Isolate* isolate = i::Isolate::Current(); 3002 i::Isolate* isolate = i::Isolate::Current();
3206 if (IsDeadCheck(isolate, "v8::Value::Equals()") 3003 if (EmptyCheck("v8::Value::Equals()", this) ||
3207 || EmptyCheck("v8::Value::Equals()", this) 3004 EmptyCheck("v8::Value::Equals()", that)) {
3208 || EmptyCheck("v8::Value::Equals()", that)) {
3209 return false; 3005 return false;
3210 } 3006 }
3211 LOG_API(isolate, "Equals"); 3007 LOG_API(isolate, "Equals");
3212 ENTER_V8(isolate); 3008 ENTER_V8(isolate);
3213 i::Handle<i::Object> obj = Utils::OpenHandle(this); 3009 i::Handle<i::Object> obj = Utils::OpenHandle(this);
3214 i::Handle<i::Object> other = Utils::OpenHandle(*that); 3010 i::Handle<i::Object> other = Utils::OpenHandle(*that);
3215 // 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
3216 // immediately when going into JS builtin. The reason is Invoke 3012 // immediately when going into JS builtin. The reason is Invoke
3217 // would overwrite global object receiver with global proxy. 3013 // would overwrite global object receiver with global proxy.
3218 if (obj->IsJSObject() && other->IsJSObject()) { 3014 if (obj->IsJSObject() && other->IsJSObject()) {
3219 return *obj == *other; 3015 return *obj == *other;
3220 } 3016 }
3221 i::Handle<i::Object> args[] = { other }; 3017 i::Handle<i::Object> args[] = { other };
3222 EXCEPTION_PREAMBLE(isolate); 3018 EXCEPTION_PREAMBLE(isolate);
3223 i::Handle<i::Object> result = 3019 i::Handle<i::Object> result =
3224 CallV8HeapFunction("EQUALS", obj, ARRAY_SIZE(args), args, 3020 CallV8HeapFunction("EQUALS", obj, ARRAY_SIZE(args), args,
3225 &has_pending_exception); 3021 &has_pending_exception);
3226 EXCEPTION_BAILOUT_CHECK(isolate, false); 3022 EXCEPTION_BAILOUT_CHECK(isolate, false);
3227 return *result == i::Smi::FromInt(i::EQUAL); 3023 return *result == i::Smi::FromInt(i::EQUAL);
3228 } 3024 }
3229 3025
3230 3026
3231 bool Value::StrictEquals(Handle<Value> that) const { 3027 bool Value::StrictEquals(Handle<Value> that) const {
3232 i::Isolate* isolate = i::Isolate::Current(); 3028 i::Isolate* isolate = i::Isolate::Current();
3233 if (IsDeadCheck(isolate, "v8::Value::StrictEquals()") 3029 if (EmptyCheck("v8::Value::StrictEquals()", this) ||
3234 || EmptyCheck("v8::Value::StrictEquals()", this) 3030 EmptyCheck("v8::Value::StrictEquals()", that)) {
3235 || EmptyCheck("v8::Value::StrictEquals()", that)) {
3236 return false; 3031 return false;
3237 } 3032 }
3238 LOG_API(isolate, "StrictEquals"); 3033 LOG_API(isolate, "StrictEquals");
3239 i::Handle<i::Object> obj = Utils::OpenHandle(this); 3034 i::Handle<i::Object> obj = Utils::OpenHandle(this);
3240 i::Handle<i::Object> other = Utils::OpenHandle(*that); 3035 i::Handle<i::Object> other = Utils::OpenHandle(*that);
3241 // Must check HeapNumber first, since NaN !== NaN. 3036 // Must check HeapNumber first, since NaN !== NaN.
3242 if (obj->IsHeapNumber()) { 3037 if (obj->IsHeapNumber()) {
3243 if (!other->IsNumber()) return false; 3038 if (!other->IsNumber()) return false;
3244 double x = obj->Number(); 3039 double x = obj->Number();
3245 double y = other->Number(); 3040 double y = other->Number();
(...skipping 13 matching lines...) Expand all
3259 } 3054 }
3260 } 3055 }
3261 3056
3262 3057
3263 uint32_t Value::Uint32Value() const { 3058 uint32_t Value::Uint32Value() const {
3264 i::Handle<i::Object> obj = Utils::OpenHandle(this); 3059 i::Handle<i::Object> obj = Utils::OpenHandle(this);
3265 if (obj->IsSmi()) { 3060 if (obj->IsSmi()) {
3266 return i::Smi::cast(*obj)->value(); 3061 return i::Smi::cast(*obj)->value();
3267 } else { 3062 } else {
3268 i::Isolate* isolate = i::Isolate::Current(); 3063 i::Isolate* isolate = i::Isolate::Current();
3269 if (IsDeadCheck(isolate, "v8::Value::Uint32Value()")) return 0;
3270 LOG_API(isolate, "Uint32Value"); 3064 LOG_API(isolate, "Uint32Value");
3271 ENTER_V8(isolate); 3065 ENTER_V8(isolate);
3272 EXCEPTION_PREAMBLE(isolate); 3066 EXCEPTION_PREAMBLE(isolate);
3273 i::Handle<i::Object> num = 3067 i::Handle<i::Object> num =
3274 i::Execution::ToUint32(isolate, obj, &has_pending_exception); 3068 i::Execution::ToUint32(isolate, obj, &has_pending_exception);
3275 EXCEPTION_BAILOUT_CHECK(isolate, 0); 3069 EXCEPTION_BAILOUT_CHECK(isolate, 0);
3276 if (num->IsSmi()) { 3070 if (num->IsSmi()) {
3277 return i::Smi::cast(*num)->value(); 3071 return i::Smi::cast(*num)->value();
3278 } else { 3072 } else {
3279 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
4325 int Function::ScriptId() const { 4119 int Function::ScriptId() const {
4326 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); 4120 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
4327 if (!func->shared()->script()->IsScript()) return v8::Script::kNoScriptId; 4121 if (!func->shared()->script()->IsScript()) return v8::Script::kNoScriptId;
4328 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); 4122 i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
4329 return script->id()->value(); 4123 return script->id()->value();
4330 } 4124 }
4331 4125
4332 4126
4333 int String::Length() const { 4127 int String::Length() const {
4334 i::Handle<i::String> str = Utils::OpenHandle(this); 4128 i::Handle<i::String> str = Utils::OpenHandle(this);
4335 if (IsDeadCheck(str->GetIsolate(), "v8::String::Length()")) return 0;
4336 return str->length(); 4129 return str->length();
4337 } 4130 }
4338 4131
4339 4132
4340 bool String::IsOneByte() const { 4133 bool String::IsOneByte() const {
4341 i::Handle<i::String> str = Utils::OpenHandle(this); 4134 i::Handle<i::String> str = Utils::OpenHandle(this);
4342 if (IsDeadCheck(str->GetIsolate(), "v8::String::IsOneByte()")) {
4343 return false;
4344 }
4345 return str->HasOnlyOneByteChars(); 4135 return str->HasOnlyOneByteChars();
4346 } 4136 }
4347 4137
4348 4138
4349 // Helpers for ContainsOnlyOneByteHelper 4139 // Helpers for ContainsOnlyOneByteHelper
4350 template<size_t size> struct OneByteMask; 4140 template<size_t size> struct OneByteMask;
4351 template<> struct OneByteMask<4> { 4141 template<> struct OneByteMask<4> {
4352 static const uint32_t value = 0xFF00FF00; 4142 static const uint32_t value = 0xFF00FF00;
4353 }; 4143 };
4354 template<> struct OneByteMask<8> { 4144 template<> struct OneByteMask<8> {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
4450 } 4240 }
4451 return is_one_byte_; 4241 return is_one_byte_;
4452 } 4242 }
4453 bool is_one_byte_; 4243 bool is_one_byte_;
4454 DISALLOW_COPY_AND_ASSIGN(ContainsOnlyOneByteHelper); 4244 DISALLOW_COPY_AND_ASSIGN(ContainsOnlyOneByteHelper);
4455 }; 4245 };
4456 4246
4457 4247
4458 bool String::ContainsOnlyOneByte() const { 4248 bool String::ContainsOnlyOneByte() const {
4459 i::Handle<i::String> str = Utils::OpenHandle(this); 4249 i::Handle<i::String> str = Utils::OpenHandle(this);
4460 if (IsDeadCheck(str->GetIsolate(),
4461 "v8::String::ContainsOnlyOneByte()")) {
4462 return false;
4463 }
4464 if (str->HasOnlyOneByteChars()) return true; 4250 if (str->HasOnlyOneByteChars()) return true;
4465 ContainsOnlyOneByteHelper helper; 4251 ContainsOnlyOneByteHelper helper;
4466 return helper.Check(*str); 4252 return helper.Check(*str);
4467 } 4253 }
4468 4254
4469 4255
4470 class Utf8LengthHelper : public i::AllStatic { 4256 class Utf8LengthHelper : public i::AllStatic {
4471 public: 4257 public:
4472 enum State { 4258 enum State {
4473 kEndsWithLeadingSurrogate = 1 << 0, 4259 kEndsWithLeadingSurrogate = 1 << 0,
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
4657 i::ConsString* cons_string = 4443 i::ConsString* cons_string =
4658 Utf8LengthHelper::Visitor::VisitFlat(str, &length, &state); 4444 Utf8LengthHelper::Visitor::VisitFlat(str, &length, &state);
4659 if (cons_string == NULL) return length; 4445 if (cons_string == NULL) return length;
4660 return Utf8LengthHelper::Calculate(cons_string); 4446 return Utf8LengthHelper::Calculate(cons_string);
4661 } 4447 }
4662 4448
4663 4449
4664 int String::Utf8Length() const { 4450 int String::Utf8Length() const {
4665 i::Handle<i::String> str = Utils::OpenHandle(this); 4451 i::Handle<i::String> str = Utils::OpenHandle(this);
4666 i::Isolate* isolate = str->GetIsolate(); 4452 i::Isolate* isolate = str->GetIsolate();
4667 if (IsDeadCheck(isolate, "v8::String::Utf8Length()")) return 0;
4668 return v8::Utf8Length(*str, isolate); 4453 return v8::Utf8Length(*str, isolate);
4669 } 4454 }
4670 4455
4671 4456
4672 class Utf8WriterVisitor { 4457 class Utf8WriterVisitor {
4673 public: 4458 public:
4674 Utf8WriterVisitor( 4459 Utf8WriterVisitor(
4675 char* buffer, int capacity, bool skip_capacity_check) 4460 char* buffer, int capacity, bool skip_capacity_check)
4676 : early_termination_(false), 4461 : early_termination_(false),
4677 last_character_(unibrow::Utf16::kNoPreviousCharacter), 4462 last_character_(unibrow::Utf16::kNoPreviousCharacter),
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
4843 } 4628 }
4844 return true; 4629 return true;
4845 } 4630 }
4846 4631
4847 4632
4848 int String::WriteUtf8(char* buffer, 4633 int String::WriteUtf8(char* buffer,
4849 int capacity, 4634 int capacity,
4850 int* nchars_ref, 4635 int* nchars_ref,
4851 int options) const { 4636 int options) const {
4852 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 4637 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4853 if (IsDeadCheck(isolate, "v8::String::WriteUtf8()")) return 0;
4854 LOG_API(isolate, "String::WriteUtf8"); 4638 LOG_API(isolate, "String::WriteUtf8");
4855 ENTER_V8(isolate); 4639 ENTER_V8(isolate);
4856 i::Handle<i::String> str = Utils::OpenHandle(this); 4640 i::Handle<i::String> str = Utils::OpenHandle(this);
4857 if (options & HINT_MANY_WRITES_EXPECTED) { 4641 if (options & HINT_MANY_WRITES_EXPECTED) {
4858 FlattenString(str); // Flatten the string for efficiency. 4642 FlattenString(str); // Flatten the string for efficiency.
4859 } 4643 }
4860 const int string_length = str->length(); 4644 const int string_length = str->length();
4861 bool write_null = !(options & NO_NULL_TERMINATION); 4645 bool write_null = !(options & NO_NULL_TERMINATION);
4862 // 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.
4863 if (capacity == -1 || capacity / 3 >= string_length) { 4647 if (capacity == -1 || capacity / 3 >= string_length) {
(...skipping 29 matching lines...) Expand all
4893 i::String::VisitFlat(&writer, *str); 4677 i::String::VisitFlat(&writer, *str);
4894 return writer.CompleteWrite(write_null, nchars_ref); 4678 return writer.CompleteWrite(write_null, nchars_ref);
4895 } 4679 }
4896 4680
4897 4681
4898 int String::WriteAscii(char* buffer, 4682 int String::WriteAscii(char* buffer,
4899 int start, 4683 int start,
4900 int length, 4684 int length,
4901 int options) const { 4685 int options) const {
4902 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 4686 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4903 if (IsDeadCheck(isolate, "v8::String::WriteAscii()")) return 0;
4904 LOG_API(isolate, "String::WriteAscii"); 4687 LOG_API(isolate, "String::WriteAscii");
4905 ENTER_V8(isolate); 4688 ENTER_V8(isolate);
4906 ASSERT(start >= 0 && length >= -1); 4689 ASSERT(start >= 0 && length >= -1);
4907 i::Handle<i::String> str = Utils::OpenHandle(this); 4690 i::Handle<i::String> str = Utils::OpenHandle(this);
4908 isolate->string_tracker()->RecordWrite(str); 4691 isolate->string_tracker()->RecordWrite(str);
4909 if (options & HINT_MANY_WRITES_EXPECTED) { 4692 if (options & HINT_MANY_WRITES_EXPECTED) {
4910 FlattenString(str); // Flatten the string for efficiency. 4693 FlattenString(str); // Flatten the string for efficiency.
4911 } 4694 }
4912 4695
4913 int end = length; 4696 int end = length;
(...skipping 15 matching lines...) Expand all
4929 } 4712 }
4930 4713
4931 4714
4932 template<typename CharType> 4715 template<typename CharType>
4933 static inline int WriteHelper(const String* string, 4716 static inline int WriteHelper(const String* string,
4934 CharType* buffer, 4717 CharType* buffer,
4935 int start, 4718 int start,
4936 int length, 4719 int length,
4937 int options) { 4720 int options) {
4938 i::Isolate* isolate = Utils::OpenHandle(string)->GetIsolate(); 4721 i::Isolate* isolate = Utils::OpenHandle(string)->GetIsolate();
4939 if (IsDeadCheck(isolate, "v8::String::Write()")) return 0;
4940 LOG_API(isolate, "String::Write"); 4722 LOG_API(isolate, "String::Write");
4941 ENTER_V8(isolate); 4723 ENTER_V8(isolate);
4942 ASSERT(start >= 0 && length >= -1); 4724 ASSERT(start >= 0 && length >= -1);
4943 i::Handle<i::String> str = Utils::OpenHandle(string); 4725 i::Handle<i::String> str = Utils::OpenHandle(string);
4944 isolate->string_tracker()->RecordWrite(str); 4726 isolate->string_tracker()->RecordWrite(str);
4945 if (options & String::HINT_MANY_WRITES_EXPECTED) { 4727 if (options & String::HINT_MANY_WRITES_EXPECTED) {
4946 // Flatten the string for efficiency. This applies whether we are 4728 // Flatten the string for efficiency. This applies whether we are
4947 // using StringCharacterStream or Get(i) to access the characters. 4729 // using StringCharacterStream or Get(i) to access the characters.
4948 FlattenString(str); 4730 FlattenString(str);
4949 } 4731 }
(...skipping 21 matching lines...) Expand all
4971 int String::Write(uint16_t* buffer, 4753 int String::Write(uint16_t* buffer,
4972 int start, 4754 int start,
4973 int length, 4755 int length,
4974 int options) const { 4756 int options) const {
4975 return WriteHelper(this, buffer, start, length, options); 4757 return WriteHelper(this, buffer, start, length, options);
4976 } 4758 }
4977 4759
4978 4760
4979 bool v8::String::IsExternal() const { 4761 bool v8::String::IsExternal() const {
4980 i::Handle<i::String> str = Utils::OpenHandle(this); 4762 i::Handle<i::String> str = Utils::OpenHandle(this);
4981 if (IsDeadCheck(str->GetIsolate(), "v8::String::IsExternal()")) {
4982 return false;
4983 }
4984 EnsureInitializedForIsolate(str->GetIsolate(), "v8::String::IsExternal()"); 4763 EnsureInitializedForIsolate(str->GetIsolate(), "v8::String::IsExternal()");
4985 return i::StringShape(*str).IsExternalTwoByte(); 4764 return i::StringShape(*str).IsExternalTwoByte();
4986 } 4765 }
4987 4766
4988 4767
4989 bool v8::String::IsExternalAscii() const { 4768 bool v8::String::IsExternalAscii() const {
4990 i::Handle<i::String> str = Utils::OpenHandle(this); 4769 i::Handle<i::String> str = Utils::OpenHandle(this);
4991 if (IsDeadCheck(str->GetIsolate(), "v8::String::IsExternalAscii()")) {
4992 return false;
4993 }
4994 return i::StringShape(*str).IsExternalAscii(); 4770 return i::StringShape(*str).IsExternalAscii();
4995 } 4771 }
4996 4772
4997 4773
4998 void v8::String::VerifyExternalStringResource( 4774 void v8::String::VerifyExternalStringResource(
4999 v8::String::ExternalStringResource* value) const { 4775 v8::String::ExternalStringResource* value) const {
5000 i::Handle<i::String> str = Utils::OpenHandle(this); 4776 i::Handle<i::String> str = Utils::OpenHandle(this);
5001 const v8::String::ExternalStringResource* expected; 4777 const v8::String::ExternalStringResource* expected;
5002 if (i::StringShape(*str).IsExternalTwoByte()) { 4778 if (i::StringShape(*str).IsExternalTwoByte()) {
5003 const void* resource = 4779 const void* resource =
(...skipping 25 matching lines...) Expand all
5029 expectedEncoding = str->IsOneByteRepresentation() ? ASCII_ENCODING 4805 expectedEncoding = str->IsOneByteRepresentation() ? ASCII_ENCODING
5030 : TWO_BYTE_ENCODING; 4806 : TWO_BYTE_ENCODING;
5031 } 4807 }
5032 CHECK_EQ(expected, value); 4808 CHECK_EQ(expected, value);
5033 CHECK_EQ(expectedEncoding, encoding); 4809 CHECK_EQ(expectedEncoding, encoding);
5034 } 4810 }
5035 4811
5036 const v8::String::ExternalAsciiStringResource* 4812 const v8::String::ExternalAsciiStringResource*
5037 v8::String::GetExternalAsciiStringResource() const { 4813 v8::String::GetExternalAsciiStringResource() const {
5038 i::Handle<i::String> str = Utils::OpenHandle(this); 4814 i::Handle<i::String> str = Utils::OpenHandle(this);
5039 if (IsDeadCheck(str->GetIsolate(),
5040 "v8::String::GetExternalAsciiStringResource()")) {
5041 return NULL;
5042 }
5043 if (i::StringShape(*str).IsExternalAscii()) { 4815 if (i::StringShape(*str).IsExternalAscii()) {
5044 const void* resource = 4816 const void* resource =
5045 i::Handle<i::ExternalAsciiString>::cast(str)->resource(); 4817 i::Handle<i::ExternalAsciiString>::cast(str)->resource();
5046 return reinterpret_cast<const ExternalAsciiStringResource*>(resource); 4818 return reinterpret_cast<const ExternalAsciiStringResource*>(resource);
5047 } else { 4819 } else {
5048 return NULL; 4820 return NULL;
5049 } 4821 }
5050 } 4822 }
5051 4823
5052 4824
5053 Local<Value> Symbol::Name() const { 4825 Local<Value> Symbol::Name() const {
5054 if (IsDeadCheck(i::Isolate::Current(), "v8::Symbol::Name()"))
5055 return Local<Value>();
5056 i::Handle<i::Symbol> sym = Utils::OpenHandle(this); 4826 i::Handle<i::Symbol> sym = Utils::OpenHandle(this);
5057 i::Handle<i::Object> name(sym->name(), sym->GetIsolate()); 4827 i::Handle<i::Object> name(sym->name(), sym->GetIsolate());
5058 return Utils::ToLocal(name); 4828 return Utils::ToLocal(name);
5059 } 4829 }
5060 4830
5061 4831
5062 double Number::Value() const { 4832 double Number::Value() const {
5063 if (IsDeadCheck(i::Isolate::Current(), "v8::Number::Value()")) return 0;
5064 i::Handle<i::Object> obj = Utils::OpenHandle(this); 4833 i::Handle<i::Object> obj = Utils::OpenHandle(this);
5065 return obj->Number(); 4834 return obj->Number();
5066 } 4835 }
5067 4836
5068 4837
5069 bool Boolean::Value() const { 4838 bool Boolean::Value() const {
5070 if (IsDeadCheck(i::Isolate::Current(), "v8::Boolean::Value()")) return false;
5071 i::Handle<i::Object> obj = Utils::OpenHandle(this); 4839 i::Handle<i::Object> obj = Utils::OpenHandle(this);
5072 return obj->IsTrue(); 4840 return obj->IsTrue();
5073 } 4841 }
5074 4842
5075 4843
5076 int64_t Integer::Value() const { 4844 int64_t Integer::Value() const {
5077 if (IsDeadCheck(i::Isolate::Current(), "v8::Integer::Value()")) return 0;
5078 i::Handle<i::Object> obj = Utils::OpenHandle(this); 4845 i::Handle<i::Object> obj = Utils::OpenHandle(this);
5079 if (obj->IsSmi()) { 4846 if (obj->IsSmi()) {
5080 return i::Smi::cast(*obj)->value(); 4847 return i::Smi::cast(*obj)->value();
5081 } else { 4848 } else {
5082 return static_cast<int64_t>(obj->Number()); 4849 return static_cast<int64_t>(obj->Number());
5083 } 4850 }
5084 } 4851 }
5085 4852
5086 4853
5087 int32_t Int32::Value() const { 4854 int32_t Int32::Value() const {
5088 if (IsDeadCheck(i::Isolate::Current(), "v8::Int32::Value()")) return 0;
5089 i::Handle<i::Object> obj = Utils::OpenHandle(this); 4855 i::Handle<i::Object> obj = Utils::OpenHandle(this);
5090 if (obj->IsSmi()) { 4856 if (obj->IsSmi()) {
5091 return i::Smi::cast(*obj)->value(); 4857 return i::Smi::cast(*obj)->value();
5092 } else { 4858 } else {
5093 return static_cast<int32_t>(obj->Number()); 4859 return static_cast<int32_t>(obj->Number());
5094 } 4860 }
5095 } 4861 }
5096 4862
5097 4863
5098 uint32_t Uint32::Value() const { 4864 uint32_t Uint32::Value() const {
5099 if (IsDeadCheck(i::Isolate::Current(), "v8::Uint32::Value()")) return 0;
5100 i::Handle<i::Object> obj = Utils::OpenHandle(this); 4865 i::Handle<i::Object> obj = Utils::OpenHandle(this);
5101 if (obj->IsSmi()) { 4866 if (obj->IsSmi()) {
5102 return i::Smi::cast(*obj)->value(); 4867 return i::Smi::cast(*obj)->value();
5103 } else { 4868 } else {
5104 return static_cast<uint32_t>(obj->Number()); 4869 return static_cast<uint32_t>(obj->Number());
5105 } 4870 }
5106 } 4871 }
5107 4872
5108 4873
5109 int v8::Object::InternalFieldCount() { 4874 int v8::Object::InternalFieldCount() {
5110 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 4875 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
5111 if (IsDeadCheck(obj->GetIsolate(), "v8::Object::InternalFieldCount()")) {
5112 return 0;
5113 }
5114 return obj->GetInternalFieldCount(); 4876 return obj->GetInternalFieldCount();
5115 } 4877 }
5116 4878
5117 4879
5118 static bool InternalFieldOK(i::Handle<i::JSObject> obj, 4880 static bool InternalFieldOK(i::Handle<i::JSObject> obj,
5119 int index, 4881 int index,
5120 const char* location) { 4882 const char* location) {
5121 return !IsDeadCheck(obj->GetIsolate(), location) && 4883 return ApiCheck(index < obj->GetInternalFieldCount(),
5122 ApiCheck(index < obj->GetInternalFieldCount(), 4884 location,
5123 location, 4885 "Internal field out of bounds");
5124 "Internal field out of bounds");
5125 } 4886 }
5126 4887
5127 4888
5128 Local<Value> v8::Object::SlowGetInternalField(int index) { 4889 Local<Value> v8::Object::SlowGetInternalField(int index) {
5129 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 4890 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
5130 const char* location = "v8::Object::GetInternalField()"; 4891 const char* location = "v8::Object::GetInternalField()";
5131 if (!InternalFieldOK(obj, index, location)) return Local<Value>(); 4892 if (!InternalFieldOK(obj, index, location)) return Local<Value>();
5132 i::Handle<i::Object> value(obj->GetInternalField(index), obj->GetIsolate()); 4893 i::Handle<i::Object> value(obj->GetInternalField(index), obj->GetIsolate());
5133 return Utils::ToLocal(value); 4894 return Utils::ToLocal(value);
5134 } 4895 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
5268 heap_statistics->heap_size_limit_ = 0; 5029 heap_statistics->heap_size_limit_ = 0;
5269 return; 5030 return;
5270 } 5031 }
5271 Isolate* ext_isolate = reinterpret_cast<Isolate*>(isolate); 5032 Isolate* ext_isolate = reinterpret_cast<Isolate*>(isolate);
5272 return ext_isolate->GetHeapStatistics(heap_statistics); 5033 return ext_isolate->GetHeapStatistics(heap_statistics);
5273 } 5034 }
5274 5035
5275 5036
5276 void v8::V8::VisitExternalResources(ExternalResourceVisitor* visitor) { 5037 void v8::V8::VisitExternalResources(ExternalResourceVisitor* visitor) {
5277 i::Isolate* isolate = i::Isolate::Current(); 5038 i::Isolate* isolate = i::Isolate::Current();
5278 IsDeadCheck(isolate, "v8::V8::VisitExternalResources");
5279 isolate->heap()->VisitExternalResources(visitor); 5039 isolate->heap()->VisitExternalResources(visitor);
5280 } 5040 }
5281 5041
5282 5042
5283 class VisitorAdapter : public i::ObjectVisitor { 5043 class VisitorAdapter : public i::ObjectVisitor {
5284 public: 5044 public:
5285 explicit VisitorAdapter(PersistentHandleVisitor* visitor) 5045 explicit VisitorAdapter(PersistentHandleVisitor* visitor)
5286 : visitor_(visitor) {} 5046 : visitor_(visitor) {}
5287 virtual void VisitPointers(i::Object** start, i::Object** end) { 5047 virtual void VisitPointers(i::Object** start, i::Object** end) {
5288 UNREACHABLE(); 5048 UNREACHABLE();
5289 } 5049 }
5290 virtual void VisitEmbedderReference(i::Object** p, uint16_t class_id) { 5050 virtual void VisitEmbedderReference(i::Object** p, uint16_t class_id) {
5291 Value* value = ToApi<Value>(i::Handle<i::Object>(p)); 5051 Value* value = ToApi<Value>(i::Handle<i::Object>(p));
5292 visitor_->VisitPersistentHandle( 5052 visitor_->VisitPersistentHandle(
5293 reinterpret_cast<Persistent<Value>*>(&value), class_id); 5053 reinterpret_cast<Persistent<Value>*>(&value), class_id);
5294 } 5054 }
5295 private: 5055 private:
5296 PersistentHandleVisitor* visitor_; 5056 PersistentHandleVisitor* visitor_;
5297 }; 5057 };
5298 5058
5299 5059
5300 void v8::V8::VisitHandlesWithClassIds(PersistentHandleVisitor* visitor) { 5060 void v8::V8::VisitHandlesWithClassIds(PersistentHandleVisitor* visitor) {
5301 i::Isolate* isolate = i::Isolate::Current(); 5061 i::Isolate* isolate = i::Isolate::Current();
5302 IsDeadCheck(isolate, "v8::V8::VisitHandlesWithClassId");
5303
5304 i::DisallowHeapAllocation no_allocation; 5062 i::DisallowHeapAllocation no_allocation;
5305 5063
5306 VisitorAdapter visitor_adapter(visitor); 5064 VisitorAdapter visitor_adapter(visitor);
5307 isolate->global_handles()->IterateAllRootsWithClassIds(&visitor_adapter); 5065 isolate->global_handles()->IterateAllRootsWithClassIds(&visitor_adapter);
5308 } 5066 }
5309 5067
5310 5068
5311 void v8::V8::VisitHandlesForPartialDependence( 5069 void v8::V8::VisitHandlesForPartialDependence(
5312 Isolate* exported_isolate, PersistentHandleVisitor* visitor) { 5070 Isolate* exported_isolate, PersistentHandleVisitor* visitor) {
5313 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(exported_isolate); 5071 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(exported_isolate);
5314 ASSERT(isolate == i::Isolate::Current()); 5072 ASSERT(isolate == i::Isolate::Current());
5315 IsDeadCheck(isolate, "v8::V8::VisitHandlesForPartialDependence");
5316
5317 i::DisallowHeapAllocation no_allocation; 5073 i::DisallowHeapAllocation no_allocation;
5318 5074
5319 VisitorAdapter visitor_adapter(visitor); 5075 VisitorAdapter visitor_adapter(visitor);
5320 isolate->global_handles()->IterateAllRootsInNewSpaceWithClassIds( 5076 isolate->global_handles()->IterateAllRootsInNewSpaceWithClassIds(
5321 &visitor_adapter); 5077 &visitor_adapter);
5322 } 5078 }
5323 5079
5324 5080
5325 bool v8::V8::IdleNotification(int hint) { 5081 bool v8::V8::IdleNotification(int hint) {
5326 // 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
5431 i::HandleScope scope(isolate); 5187 i::HandleScope scope(isolate);
5432 i::Handle<i::Context> env = 5188 i::Handle<i::Context> env =
5433 CreateEnvironment(isolate, extensions, global_template, global_object); 5189 CreateEnvironment(isolate, extensions, global_template, global_object);
5434 if (env.is_null()) return Local<Context>(); 5190 if (env.is_null()) return Local<Context>();
5435 return Utils::ToLocal(scope.CloseAndEscape(env)); 5191 return Utils::ToLocal(scope.CloseAndEscape(env));
5436 } 5192 }
5437 5193
5438 5194
5439 void v8::Context::SetSecurityToken(Handle<Value> token) { 5195 void v8::Context::SetSecurityToken(Handle<Value> token) {
5440 i::Isolate* isolate = i::Isolate::Current(); 5196 i::Isolate* isolate = i::Isolate::Current();
5441 if (IsDeadCheck(isolate, "v8::Context::SetSecurityToken()")) {
5442 return;
5443 }
5444 ENTER_V8(isolate); 5197 ENTER_V8(isolate);
5445 i::Handle<i::Context> env = Utils::OpenHandle(this); 5198 i::Handle<i::Context> env = Utils::OpenHandle(this);
5446 i::Handle<i::Object> token_handle = Utils::OpenHandle(*token); 5199 i::Handle<i::Object> token_handle = Utils::OpenHandle(*token);
5447 env->set_security_token(*token_handle); 5200 env->set_security_token(*token_handle);
5448 } 5201 }
5449 5202
5450 5203
5451 void v8::Context::UseDefaultSecurityToken() { 5204 void v8::Context::UseDefaultSecurityToken() {
5452 i::Isolate* isolate = i::Isolate::Current(); 5205 i::Isolate* isolate = i::Isolate::Current();
5453 if (IsDeadCheck(isolate,
5454 "v8::Context::UseDefaultSecurityToken()")) {
5455 return;
5456 }
5457 ENTER_V8(isolate); 5206 ENTER_V8(isolate);
5458 i::Handle<i::Context> env = Utils::OpenHandle(this); 5207 i::Handle<i::Context> env = Utils::OpenHandle(this);
5459 env->set_security_token(env->global_object()); 5208 env->set_security_token(env->global_object());
5460 } 5209 }
5461 5210
5462 5211
5463 Handle<Value> v8::Context::GetSecurityToken() { 5212 Handle<Value> v8::Context::GetSecurityToken() {
5464 i::Isolate* isolate = i::Isolate::Current(); 5213 i::Isolate* isolate = i::Isolate::Current();
5465 if (IsDeadCheck(isolate, "v8::Context::GetSecurityToken()")) {
5466 return Handle<Value>();
5467 }
5468 i::Handle<i::Context> env = Utils::OpenHandle(this); 5214 i::Handle<i::Context> env = Utils::OpenHandle(this);
5469 i::Object* security_token = env->security_token(); 5215 i::Object* security_token = env->security_token();
5470 i::Handle<i::Object> token_handle(security_token, isolate); 5216 i::Handle<i::Object> token_handle(security_token, isolate);
5471 return Utils::ToLocal(token_handle); 5217 return Utils::ToLocal(token_handle);
5472 } 5218 }
5473 5219
5474 5220
5475 bool Context::HasOutOfMemoryException() { 5221 bool Context::HasOutOfMemoryException() {
5476 i::Handle<i::Context> env = Utils::OpenHandle(this); 5222 i::Handle<i::Context> env = Utils::OpenHandle(this);
5477 return env->has_out_of_memory(); 5223 return env->has_out_of_memory();
5478 } 5224 }
5479 5225
5480 5226
5481 bool Context::InContext() { 5227 bool Context::InContext() {
5482 return i::Isolate::Current()->context() != NULL; 5228 return i::Isolate::Current()->context() != NULL;
5483 } 5229 }
5484 5230
5485 5231
5486 v8::Isolate* Context::GetIsolate() { 5232 v8::Isolate* Context::GetIsolate() {
5487 i::Handle<i::Context> env = Utils::OpenHandle(this); 5233 i::Handle<i::Context> env = Utils::OpenHandle(this);
5488 return reinterpret_cast<Isolate*>(env->GetIsolate()); 5234 return reinterpret_cast<Isolate*>(env->GetIsolate());
5489 } 5235 }
5490 5236
5491 5237
5492 v8::Local<v8::Context> Context::GetEntered() { 5238 v8::Local<v8::Context> Context::GetEntered() {
5493 i::Isolate* isolate = i::Isolate::Current(); 5239 i::Isolate* isolate = i::Isolate::Current();
5494 if (!EnsureInitializedForIsolate(isolate, "v8::Context::GetEntered()")) { 5240 if (!EnsureInitializedForIsolate(isolate, "v8::Context::GetEntered()")) {
5495 return Local<Context>(); 5241 return Local<Context>();
5496 } 5242 }
5497 i::Handle<i::Object> last = 5243 return reinterpret_cast<Isolate*>(isolate)->GetEnteredContext();
5498 isolate->handle_scope_implementer()->LastEnteredContext();
5499 if (last.is_null()) return Local<Context>();
5500 i::Handle<i::Context> context = i::Handle<i::Context>::cast(last);
5501 return Utils::ToLocal(context);
5502 } 5244 }
5503 5245
5504 5246
5505 v8::Local<v8::Context> Context::GetCurrent() { 5247 v8::Local<v8::Context> Context::GetCurrent() {
5506 i::Isolate* isolate = i::Isolate::Current(); 5248 i::Isolate* isolate = i::Isolate::Current();
5507 if (IsDeadCheck(isolate, "v8::Context::GetCurrent()")) {
5508 return Local<Context>();
5509 }
5510 return reinterpret_cast<Isolate*>(isolate)->GetCurrentContext(); 5249 return reinterpret_cast<Isolate*>(isolate)->GetCurrentContext();
5511 } 5250 }
5512 5251
5513 5252
5514 v8::Local<v8::Context> Context::GetCalling() { 5253 v8::Local<v8::Context> Context::GetCalling() {
5515 i::Isolate* isolate = i::Isolate::Current(); 5254 i::Isolate* isolate = i::Isolate::Current();
5516 if (IsDeadCheck(isolate, "v8::Context::GetCalling()")) { 5255 return reinterpret_cast<Isolate*>(isolate)->GetCallingContext();
5517 return Local<Context>();
5518 }
5519 i::Handle<i::Object> calling =
5520 isolate->GetCallingNativeContext();
5521 if (calling.is_null()) return Local<Context>();
5522 i::Handle<i::Context> context = i::Handle<i::Context>::cast(calling);
5523 return Utils::ToLocal(context);
5524 } 5256 }
5525 5257
5526 5258
5527 v8::Local<v8::Object> Context::Global() { 5259 v8::Local<v8::Object> Context::Global() {
5528 i::Isolate* isolate = i::Isolate::Current(); 5260 i::Handle<i::Context> context = Utils::OpenHandle(this);
5529 if (IsDeadCheck(isolate, "v8::Context::Global()")) { 5261 i::Isolate* isolate = context->GetIsolate();
5530 return Local<v8::Object>();
5531 }
5532 i::Object** ctx = reinterpret_cast<i::Object**>(this);
5533 i::Handle<i::Context> context =
5534 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx));
5535 i::Handle<i::Object> global(context->global_proxy(), isolate); 5262 i::Handle<i::Object> global(context->global_proxy(), isolate);
5536 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global)); 5263 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global));
5537 } 5264 }
5538 5265
5539 5266
5540 void Context::DetachGlobal() { 5267 void Context::DetachGlobal() {
5541 i::Isolate* isolate = i::Isolate::Current(); 5268 i::Handle<i::Context> context = Utils::OpenHandle(this);
5542 if (IsDeadCheck(isolate, "v8::Context::DetachGlobal()")) return; 5269 i::Isolate* isolate = context->GetIsolate();
5543 ENTER_V8(isolate); 5270 ENTER_V8(isolate);
5544 i::Object** ctx = reinterpret_cast<i::Object**>(this);
5545 i::Handle<i::Context> context =
5546 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx));
5547 isolate->bootstrapper()->DetachGlobal(context); 5271 isolate->bootstrapper()->DetachGlobal(context);
5548 } 5272 }
5549 5273
5550 5274
5551 void Context::ReattachGlobal(Handle<Object> global_object) { 5275 void Context::ReattachGlobal(Handle<Object> global_object) {
5552 i::Isolate* isolate = i::Isolate::Current(); 5276 i::Handle<i::Context> context = Utils::OpenHandle(this);
5553 if (IsDeadCheck(isolate, "v8::Context::ReattachGlobal()")) return; 5277 i::Isolate* isolate = context->GetIsolate();
5554 ENTER_V8(isolate); 5278 ENTER_V8(isolate);
5555 i::Object** ctx = reinterpret_cast<i::Object**>(this);
5556 i::Handle<i::Context> context =
5557 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx));
5558 i::Handle<i::JSGlobalProxy> global_proxy = 5279 i::Handle<i::JSGlobalProxy> global_proxy =
5559 i::Handle<i::JSGlobalProxy>::cast(Utils::OpenHandle(*global_object)); 5280 i::Handle<i::JSGlobalProxy>::cast(Utils::OpenHandle(*global_object));
5560 isolate->bootstrapper()->ReattachGlobal(context, global_proxy); 5281 isolate->bootstrapper()->ReattachGlobal(context, global_proxy);
5561 } 5282 }
5562 5283
5563 5284
5564 void Context::AllowCodeGenerationFromStrings(bool allow) { 5285 void Context::AllowCodeGenerationFromStrings(bool allow) {
5565 i::Isolate* isolate = i::Isolate::Current(); 5286 i::Handle<i::Context> context = Utils::OpenHandle(this);
5566 if (IsDeadCheck(isolate, "v8::Context::AllowCodeGenerationFromStrings()")) { 5287 i::Isolate* isolate = context->GetIsolate();
5567 return;
5568 }
5569 ENTER_V8(isolate); 5288 ENTER_V8(isolate);
5570 i::Object** ctx = reinterpret_cast<i::Object**>(this);
5571 i::Handle<i::Context> context =
5572 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx));
5573 context->set_allow_code_gen_from_strings( 5289 context->set_allow_code_gen_from_strings(
5574 allow ? isolate->heap()->true_value() : isolate->heap()->false_value()); 5290 allow ? isolate->heap()->true_value() : isolate->heap()->false_value());
5575 } 5291 }
5576 5292
5577 5293
5578 bool Context::IsCodeGenerationFromStringsAllowed() { 5294 bool Context::IsCodeGenerationFromStringsAllowed() {
5579 i::Isolate* isolate = i::Isolate::Current(); 5295 i::Handle<i::Context> context = Utils::OpenHandle(this);
5580 if (IsDeadCheck(isolate,
5581 "v8::Context::IsCodeGenerationFromStringsAllowed()")) {
5582 return false;
5583 }
5584 ENTER_V8(isolate);
5585 i::Object** ctx = reinterpret_cast<i::Object**>(this);
5586 i::Handle<i::Context> context =
5587 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx));
5588 return !context->allow_code_gen_from_strings()->IsFalse(); 5296 return !context->allow_code_gen_from_strings()->IsFalse();
5589 } 5297 }
5590 5298
5591 5299
5592 void Context::SetErrorMessageForCodeGenerationFromStrings( 5300 void Context::SetErrorMessageForCodeGenerationFromStrings(
5593 Handle<String> error) { 5301 Handle<String> error) {
5594 i::Isolate* isolate = i::Isolate::Current(); 5302 i::Handle<i::Context> context = Utils::OpenHandle(this);
5595 if (IsDeadCheck(isolate,
5596 "v8::Context::SetErrorMessageForCodeGenerationFromStrings()")) {
5597 return;
5598 }
5599 ENTER_V8(isolate);
5600 i::Object** ctx = reinterpret_cast<i::Object**>(this);
5601 i::Handle<i::Context> context =
5602 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx));
5603 i::Handle<i::String> error_handle = Utils::OpenHandle(*error); 5303 i::Handle<i::String> error_handle = Utils::OpenHandle(*error);
5604 context->set_error_message_for_code_gen_from_strings(*error_handle); 5304 context->set_error_message_for_code_gen_from_strings(*error_handle);
5605 } 5305 }
5606 5306
5607 5307
5608 Local<v8::Object> ObjectTemplate::NewInstance() { 5308 Local<v8::Object> ObjectTemplate::NewInstance() {
5609 i::Isolate* isolate = i::Isolate::Current(); 5309 i::Isolate* isolate = i::Isolate::Current();
5610 ON_BAILOUT(isolate, "v8::ObjectTemplate::NewInstance()", 5310 ON_BAILOUT(isolate, "v8::ObjectTemplate::NewInstance()",
5611 return Local<v8::Object>()); 5311 return Local<v8::Object>());
5612 LOG_API(isolate, "ObjectTemplate::NewInstance"); 5312 LOG_API(isolate, "ObjectTemplate::NewInstance");
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
5648 i::Isolate* isolate = i::Isolate::Current(); 5348 i::Isolate* isolate = i::Isolate::Current();
5649 EnsureInitializedForIsolate(isolate, "v8::External::New()"); 5349 EnsureInitializedForIsolate(isolate, "v8::External::New()");
5650 LOG_API(isolate, "External::New"); 5350 LOG_API(isolate, "External::New");
5651 ENTER_V8(isolate); 5351 ENTER_V8(isolate);
5652 i::Handle<i::JSObject> external = isolate->factory()->NewExternal(value); 5352 i::Handle<i::JSObject> external = isolate->factory()->NewExternal(value);
5653 return Utils::ExternalToLocal(external); 5353 return Utils::ExternalToLocal(external);
5654 } 5354 }
5655 5355
5656 5356
5657 void* External::Value() const { 5357 void* External::Value() const {
5658 if (IsDeadCheck(i::Isolate::Current(), "v8::External::Value()")) return NULL;
5659 return ExternalValue(*Utils::OpenHandle(this)); 5358 return ExternalValue(*Utils::OpenHandle(this));
5660 } 5359 }
5661 5360
5662 5361
5663 Local<String> v8::String::Empty() { 5362 Local<String> v8::String::Empty() {
5664 i::Isolate* isolate = i::Isolate::Current(); 5363 i::Isolate* isolate = i::Isolate::Current();
5665 if (!EnsureInitializedForIsolate(isolate, "v8::String::Empty()")) { 5364 if (!EnsureInitializedForIsolate(isolate, "v8::String::Empty()")) {
5666 return v8::Local<String>(); 5365 return v8::Local<String>();
5667 } 5366 }
5668 LOG_API(isolate, "String::Empty()"); 5367 LOG_API(isolate, "String::Empty()");
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
5841 CHECK(resource && resource->data()); 5540 CHECK(resource && resource->data());
5842 i::Handle<i::String> result = NewExternalStringHandle(isolate, resource); 5541 i::Handle<i::String> result = NewExternalStringHandle(isolate, resource);
5843 isolate->heap()->external_string_table()->AddString(*result); 5542 isolate->heap()->external_string_table()->AddString(*result);
5844 return Utils::ToLocal(result); 5543 return Utils::ToLocal(result);
5845 } 5544 }
5846 5545
5847 5546
5848 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { 5547 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) {
5849 i::Handle<i::String> obj = Utils::OpenHandle(this); 5548 i::Handle<i::String> obj = Utils::OpenHandle(this);
5850 i::Isolate* isolate = obj->GetIsolate(); 5549 i::Isolate* isolate = obj->GetIsolate();
5851 if (IsDeadCheck(isolate, "v8::String::MakeExternal()")) return false;
5852 if (i::StringShape(*obj).IsExternalTwoByte()) { 5550 if (i::StringShape(*obj).IsExternalTwoByte()) {
5853 return false; // Already an external string. 5551 return false; // Already an external string.
5854 } 5552 }
5855 ENTER_V8(isolate); 5553 ENTER_V8(isolate);
5856 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { 5554 if (isolate->string_tracker()->IsFreshUnusedString(obj)) {
5857 return false; 5555 return false;
5858 } 5556 }
5859 if (isolate->heap()->IsInGCPostProcessing()) { 5557 if (isolate->heap()->IsInGCPostProcessing()) {
5860 return false; 5558 return false;
5861 } 5559 }
(...skipping 30 matching lines...) Expand all
5892 i::Handle<i::String> result = NewExternalAsciiStringHandle(isolate, resource); 5590 i::Handle<i::String> result = NewExternalAsciiStringHandle(isolate, resource);
5893 isolate->heap()->external_string_table()->AddString(*result); 5591 isolate->heap()->external_string_table()->AddString(*result);
5894 return Utils::ToLocal(result); 5592 return Utils::ToLocal(result);
5895 } 5593 }
5896 5594
5897 5595
5898 bool v8::String::MakeExternal( 5596 bool v8::String::MakeExternal(
5899 v8::String::ExternalAsciiStringResource* resource) { 5597 v8::String::ExternalAsciiStringResource* resource) {
5900 i::Handle<i::String> obj = Utils::OpenHandle(this); 5598 i::Handle<i::String> obj = Utils::OpenHandle(this);
5901 i::Isolate* isolate = obj->GetIsolate(); 5599 i::Isolate* isolate = obj->GetIsolate();
5902 if (IsDeadCheck(isolate, "v8::String::MakeExternal()")) return false;
5903 if (i::StringShape(*obj).IsExternalTwoByte()) { 5600 if (i::StringShape(*obj).IsExternalTwoByte()) {
5904 return false; // Already an external string. 5601 return false; // Already an external string.
5905 } 5602 }
5906 ENTER_V8(isolate); 5603 ENTER_V8(isolate);
5907 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { 5604 if (isolate->string_tracker()->IsFreshUnusedString(obj)) {
5908 return false; 5605 return false;
5909 } 5606 }
5910 if (isolate->heap()->IsInGCPostProcessing()) { 5607 if (isolate->heap()->IsInGCPostProcessing()) {
5911 return false; 5608 return false;
5912 } 5609 }
(...skipping 17 matching lines...) Expand all
5930 isolate->heap()->external_string_table()->AddString(*external); 5627 isolate->heap()->external_string_table()->AddString(*external);
5931 } 5628 }
5932 return result; 5629 return result;
5933 } 5630 }
5934 5631
5935 5632
5936 bool v8::String::CanMakeExternal() { 5633 bool v8::String::CanMakeExternal() {
5937 if (!internal::FLAG_clever_optimizations) return false; 5634 if (!internal::FLAG_clever_optimizations) return false;
5938 i::Handle<i::String> obj = Utils::OpenHandle(this); 5635 i::Handle<i::String> obj = Utils::OpenHandle(this);
5939 i::Isolate* isolate = obj->GetIsolate(); 5636 i::Isolate* isolate = obj->GetIsolate();
5940 if (IsDeadCheck(isolate, "v8::String::CanMakeExternal()")) return false;
5941 if (isolate->string_tracker()->IsFreshUnusedString(obj)) return false; 5637 if (isolate->string_tracker()->IsFreshUnusedString(obj)) return false;
5942 int size = obj->Size(); // Byte size of the original string. 5638 int size = obj->Size(); // Byte size of the original string.
5943 if (size < i::ExternalString::kShortSize) return false; 5639 if (size < i::ExternalString::kShortSize) return false;
5944 i::StringShape shape(*obj); 5640 i::StringShape shape(*obj);
5945 return !shape.IsExternal(); 5641 return !shape.IsExternal();
5946 } 5642 }
5947 5643
5948 5644
5949 Local<v8::Object> v8::Object::New() { 5645 Local<v8::Object> v8::Object::New() {
5950 i::Isolate* isolate = i::Isolate::Current(); 5646 i::Isolate* isolate = i::Isolate::Current();
(...skipping 12 matching lines...) Expand all
5963 LOG_API(isolate, "NumberObject::New"); 5659 LOG_API(isolate, "NumberObject::New");
5964 ENTER_V8(isolate); 5660 ENTER_V8(isolate);
5965 i::Handle<i::Object> number = isolate->factory()->NewNumber(value); 5661 i::Handle<i::Object> number = isolate->factory()->NewNumber(value);
5966 i::Handle<i::Object> obj = isolate->factory()->ToObject(number); 5662 i::Handle<i::Object> obj = isolate->factory()->ToObject(number);
5967 return Utils::ToLocal(obj); 5663 return Utils::ToLocal(obj);
5968 } 5664 }
5969 5665
5970 5666
5971 double v8::NumberObject::ValueOf() const { 5667 double v8::NumberObject::ValueOf() const {
5972 i::Isolate* isolate = i::Isolate::Current(); 5668 i::Isolate* isolate = i::Isolate::Current();
5973 if (IsDeadCheck(isolate, "v8::NumberObject::NumberValue()")) return 0;
5974 LOG_API(isolate, "NumberObject::NumberValue"); 5669 LOG_API(isolate, "NumberObject::NumberValue");
5975 i::Handle<i::Object> obj = Utils::OpenHandle(this); 5670 i::Handle<i::Object> obj = Utils::OpenHandle(this);
5976 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); 5671 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
5977 return jsvalue->value()->Number(); 5672 return jsvalue->value()->Number();
5978 } 5673 }
5979 5674
5980 5675
5981 Local<v8::Value> v8::BooleanObject::New(bool value) { 5676 Local<v8::Value> v8::BooleanObject::New(bool value) {
5982 i::Isolate* isolate = i::Isolate::Current(); 5677 i::Isolate* isolate = i::Isolate::Current();
5983 EnsureInitializedForIsolate(isolate, "v8::BooleanObject::New()"); 5678 EnsureInitializedForIsolate(isolate, "v8::BooleanObject::New()");
5984 LOG_API(isolate, "BooleanObject::New"); 5679 LOG_API(isolate, "BooleanObject::New");
5985 ENTER_V8(isolate); 5680 ENTER_V8(isolate);
5986 i::Handle<i::Object> boolean(value 5681 i::Handle<i::Object> boolean(value
5987 ? isolate->heap()->true_value() 5682 ? isolate->heap()->true_value()
5988 : isolate->heap()->false_value(), 5683 : isolate->heap()->false_value(),
5989 isolate); 5684 isolate);
5990 i::Handle<i::Object> obj = isolate->factory()->ToObject(boolean); 5685 i::Handle<i::Object> obj = isolate->factory()->ToObject(boolean);
5991 return Utils::ToLocal(obj); 5686 return Utils::ToLocal(obj);
5992 } 5687 }
5993 5688
5994 5689
5995 bool v8::BooleanObject::ValueOf() const { 5690 bool v8::BooleanObject::ValueOf() const {
5996 i::Isolate* isolate = i::Isolate::Current(); 5691 i::Isolate* isolate = i::Isolate::Current();
5997 if (IsDeadCheck(isolate, "v8::BooleanObject::BooleanValue()")) return 0;
5998 LOG_API(isolate, "BooleanObject::BooleanValue"); 5692 LOG_API(isolate, "BooleanObject::BooleanValue");
5999 i::Handle<i::Object> obj = Utils::OpenHandle(this); 5693 i::Handle<i::Object> obj = Utils::OpenHandle(this);
6000 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); 5694 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
6001 return jsvalue->value()->IsTrue(); 5695 return jsvalue->value()->IsTrue();
6002 } 5696 }
6003 5697
6004 5698
6005 Local<v8::Value> v8::StringObject::New(Handle<String> value) { 5699 Local<v8::Value> v8::StringObject::New(Handle<String> value) {
6006 i::Isolate* isolate = i::Isolate::Current(); 5700 i::Isolate* isolate = i::Isolate::Current();
6007 EnsureInitializedForIsolate(isolate, "v8::StringObject::New()"); 5701 EnsureInitializedForIsolate(isolate, "v8::StringObject::New()");
6008 LOG_API(isolate, "StringObject::New"); 5702 LOG_API(isolate, "StringObject::New");
6009 ENTER_V8(isolate); 5703 ENTER_V8(isolate);
6010 i::Handle<i::Object> obj = 5704 i::Handle<i::Object> obj =
6011 isolate->factory()->ToObject(Utils::OpenHandle(*value)); 5705 isolate->factory()->ToObject(Utils::OpenHandle(*value));
6012 return Utils::ToLocal(obj); 5706 return Utils::ToLocal(obj);
6013 } 5707 }
6014 5708
6015 5709
6016 Local<v8::String> v8::StringObject::ValueOf() const { 5710 Local<v8::String> v8::StringObject::ValueOf() const {
6017 i::Isolate* isolate = i::Isolate::Current(); 5711 i::Isolate* isolate = i::Isolate::Current();
6018 if (IsDeadCheck(isolate, "v8::StringObject::StringValue()")) {
6019 return Local<v8::String>();
6020 }
6021 LOG_API(isolate, "StringObject::StringValue"); 5712 LOG_API(isolate, "StringObject::StringValue");
6022 i::Handle<i::Object> obj = Utils::OpenHandle(this); 5713 i::Handle<i::Object> obj = Utils::OpenHandle(this);
6023 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); 5714 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
6024 return Utils::ToLocal( 5715 return Utils::ToLocal(
6025 i::Handle<i::String>(i::String::cast(jsvalue->value()))); 5716 i::Handle<i::String>(i::String::cast(jsvalue->value())));
6026 } 5717 }
6027 5718
6028 5719
6029 Local<v8::Value> v8::SymbolObject::New(Isolate* isolate, Handle<Symbol> value) { 5720 Local<v8::Value> v8::SymbolObject::New(Isolate* isolate, Handle<Symbol> value) {
6030 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 5721 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6031 EnsureInitializedForIsolate(i_isolate, "v8::SymbolObject::New()"); 5722 EnsureInitializedForIsolate(i_isolate, "v8::SymbolObject::New()");
6032 LOG_API(i_isolate, "SymbolObject::New"); 5723 LOG_API(i_isolate, "SymbolObject::New");
6033 ENTER_V8(i_isolate); 5724 ENTER_V8(i_isolate);
6034 i::Handle<i::Object> obj = 5725 i::Handle<i::Object> obj =
6035 i_isolate->factory()->ToObject(Utils::OpenHandle(*value)); 5726 i_isolate->factory()->ToObject(Utils::OpenHandle(*value));
6036 return Utils::ToLocal(obj); 5727 return Utils::ToLocal(obj);
6037 } 5728 }
6038 5729
6039 5730
6040 Local<v8::Symbol> v8::SymbolObject::ValueOf() const { 5731 Local<v8::Symbol> v8::SymbolObject::ValueOf() const {
6041 i::Isolate* isolate = i::Isolate::Current(); 5732 i::Isolate* isolate = i::Isolate::Current();
6042 if (IsDeadCheck(isolate, "v8::SymbolObject::SymbolValue()"))
6043 return Local<v8::Symbol>();
6044 LOG_API(isolate, "SymbolObject::SymbolValue"); 5733 LOG_API(isolate, "SymbolObject::SymbolValue");
6045 i::Handle<i::Object> obj = Utils::OpenHandle(this); 5734 i::Handle<i::Object> obj = Utils::OpenHandle(this);
6046 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); 5735 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
6047 return Utils::ToLocal( 5736 return Utils::ToLocal(
6048 i::Handle<i::Symbol>(i::Symbol::cast(jsvalue->value()))); 5737 i::Handle<i::Symbol>(i::Symbol::cast(jsvalue->value())));
6049 } 5738 }
6050 5739
6051 5740
6052 Local<v8::Value> v8::Date::New(double time) { 5741 Local<v8::Value> v8::Date::New(double time) {
6053 i::Isolate* isolate = i::Isolate::Current(); 5742 i::Isolate* isolate = i::Isolate::Current();
6054 EnsureInitializedForIsolate(isolate, "v8::Date::New()"); 5743 EnsureInitializedForIsolate(isolate, "v8::Date::New()");
6055 LOG_API(isolate, "Date::New"); 5744 LOG_API(isolate, "Date::New");
6056 if (std::isnan(time)) { 5745 if (std::isnan(time)) {
6057 // 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.
6058 time = i::OS::nan_value(); 5747 time = i::OS::nan_value();
6059 } 5748 }
6060 ENTER_V8(isolate); 5749 ENTER_V8(isolate);
6061 EXCEPTION_PREAMBLE(isolate); 5750 EXCEPTION_PREAMBLE(isolate);
6062 i::Handle<i::Object> obj = 5751 i::Handle<i::Object> obj =
6063 i::Execution::NewDate(isolate, time, &has_pending_exception); 5752 i::Execution::NewDate(isolate, time, &has_pending_exception);
6064 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Value>()); 5753 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Value>());
6065 return Utils::ToLocal(obj); 5754 return Utils::ToLocal(obj);
6066 } 5755 }
6067 5756
6068 5757
6069 double v8::Date::ValueOf() const { 5758 double v8::Date::ValueOf() const {
6070 i::Isolate* isolate = i::Isolate::Current(); 5759 i::Isolate* isolate = i::Isolate::Current();
6071 if (IsDeadCheck(isolate, "v8::Date::NumberValue()")) return 0;
6072 LOG_API(isolate, "Date::NumberValue"); 5760 LOG_API(isolate, "Date::NumberValue");
6073 i::Handle<i::Object> obj = Utils::OpenHandle(this); 5761 i::Handle<i::Object> obj = Utils::OpenHandle(this);
6074 i::Handle<i::JSDate> jsdate = i::Handle<i::JSDate>::cast(obj); 5762 i::Handle<i::JSDate> jsdate = i::Handle<i::JSDate>::cast(obj);
6075 return jsdate->value()->Number(); 5763 return jsdate->value()->Number();
6076 } 5764 }
6077 5765
6078 5766
6079 void v8::Date::DateTimeConfigurationChangeNotification() { 5767 void v8::Date::DateTimeConfigurationChangeNotification() {
6080 i::Isolate* isolate = i::Isolate::Current(); 5768 i::Isolate* isolate = i::Isolate::Current();
6081 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
6135 i::Handle<i::JSRegExp> obj = i::Execution::NewJSRegExp( 5823 i::Handle<i::JSRegExp> obj = i::Execution::NewJSRegExp(
6136 Utils::OpenHandle(*pattern), 5824 Utils::OpenHandle(*pattern),
6137 RegExpFlagsToString(flags), 5825 RegExpFlagsToString(flags),
6138 &has_pending_exception); 5826 &has_pending_exception);
6139 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::RegExp>()); 5827 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::RegExp>());
6140 return Utils::ToLocal(i::Handle<i::JSRegExp>::cast(obj)); 5828 return Utils::ToLocal(i::Handle<i::JSRegExp>::cast(obj));
6141 } 5829 }
6142 5830
6143 5831
6144 Local<v8::String> v8::RegExp::GetSource() const { 5832 Local<v8::String> v8::RegExp::GetSource() const {
6145 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
6146 if (IsDeadCheck(isolate, "v8::RegExp::GetSource()")) {
6147 return Local<v8::String>();
6148 }
6149 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); 5833 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this);
6150 return Utils::ToLocal(i::Handle<i::String>(obj->Pattern())); 5834 return Utils::ToLocal(i::Handle<i::String>(obj->Pattern()));
6151 } 5835 }
6152 5836
6153 5837
6154 // Assert that the static flags cast in GetFlags is valid. 5838 // Assert that the static flags cast in GetFlags is valid.
6155 #define REGEXP_FLAG_ASSERT_EQ(api_flag, internal_flag) \ 5839 #define REGEXP_FLAG_ASSERT_EQ(api_flag, internal_flag) \
6156 STATIC_ASSERT(static_cast<int>(v8::RegExp::api_flag) == \ 5840 STATIC_ASSERT(static_cast<int>(v8::RegExp::api_flag) == \
6157 static_cast<int>(i::JSRegExp::internal_flag)) 5841 static_cast<int>(i::JSRegExp::internal_flag))
6158 REGEXP_FLAG_ASSERT_EQ(kNone, NONE); 5842 REGEXP_FLAG_ASSERT_EQ(kNone, NONE);
6159 REGEXP_FLAG_ASSERT_EQ(kGlobal, GLOBAL); 5843 REGEXP_FLAG_ASSERT_EQ(kGlobal, GLOBAL);
6160 REGEXP_FLAG_ASSERT_EQ(kIgnoreCase, IGNORE_CASE); 5844 REGEXP_FLAG_ASSERT_EQ(kIgnoreCase, IGNORE_CASE);
6161 REGEXP_FLAG_ASSERT_EQ(kMultiline, MULTILINE); 5845 REGEXP_FLAG_ASSERT_EQ(kMultiline, MULTILINE);
6162 #undef REGEXP_FLAG_ASSERT_EQ 5846 #undef REGEXP_FLAG_ASSERT_EQ
6163 5847
6164 v8::RegExp::Flags v8::RegExp::GetFlags() const { 5848 v8::RegExp::Flags v8::RegExp::GetFlags() const {
6165 if (IsDeadCheck(i::Isolate::Current(), "v8::RegExp::GetFlags()")) {
6166 return v8::RegExp::kNone;
6167 }
6168 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); 5849 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this);
6169 return static_cast<RegExp::Flags>(obj->GetFlags().value()); 5850 return static_cast<RegExp::Flags>(obj->GetFlags().value());
6170 } 5851 }
6171 5852
6172 5853
6173 Local<v8::Array> v8::Array::New(int length) { 5854 Local<v8::Array> v8::Array::New(int length) {
6174 i::Isolate* isolate = i::Isolate::Current(); 5855 i::Isolate* isolate = i::Isolate::Current();
6175 EnsureInitializedForIsolate(isolate, "v8::Array::New()"); 5856 EnsureInitializedForIsolate(isolate, "v8::Array::New()");
6176 LOG_API(isolate, "Array::New"); 5857 LOG_API(isolate, "Array::New");
6177 ENTER_V8(isolate); 5858 ENTER_V8(isolate);
6178 int real_length = length > 0 ? length : 0; 5859 int real_length = length > 0 ? length : 0;
6179 i::Handle<i::JSArray> obj = isolate->factory()->NewJSArray(real_length); 5860 i::Handle<i::JSArray> obj = isolate->factory()->NewJSArray(real_length);
6180 i::Handle<i::Object> length_obj = 5861 i::Handle<i::Object> length_obj =
6181 isolate->factory()->NewNumberFromInt(real_length); 5862 isolate->factory()->NewNumberFromInt(real_length);
6182 obj->set_length(*length_obj); 5863 obj->set_length(*length_obj);
6183 return Utils::ToLocal(obj); 5864 return Utils::ToLocal(obj);
6184 } 5865 }
6185 5866
6186 5867
6187 uint32_t v8::Array::Length() const { 5868 uint32_t v8::Array::Length() const {
6188 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
6189 if (IsDeadCheck(isolate, "v8::Array::Length()")) return 0;
6190 i::Handle<i::JSArray> obj = Utils::OpenHandle(this); 5869 i::Handle<i::JSArray> obj = Utils::OpenHandle(this);
6191 i::Object* length = obj->length(); 5870 i::Object* length = obj->length();
6192 if (length->IsSmi()) { 5871 if (length->IsSmi()) {
6193 return i::Smi::cast(length)->value(); 5872 return i::Smi::cast(length)->value();
6194 } else { 5873 } else {
6195 return static_cast<uint32_t>(length->Number()); 5874 return static_cast<uint32_t>(length->Number());
6196 } 5875 }
6197 } 5876 }
6198 5877
6199 5878
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
6257 } else { 5936 } else {
6258 UNREACHABLE(); 5937 UNREACHABLE();
6259 } 5938 }
6260 view_obj = i::handle(view->weak_next(), isolate); 5939 view_obj = i::handle(view->weak_next(), isolate);
6261 } 5940 }
6262 obj->Neuter(); 5941 obj->Neuter();
6263 } 5942 }
6264 5943
6265 5944
6266 size_t v8::ArrayBuffer::ByteLength() const { 5945 size_t v8::ArrayBuffer::ByteLength() const {
6267 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
6268 if (IsDeadCheck(isolate, "v8::ArrayBuffer::ByteLength()")) return 0;
6269 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); 5946 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this);
6270 return static_cast<size_t>(obj->byte_length()->Number()); 5947 return static_cast<size_t>(obj->byte_length()->Number());
6271 } 5948 }
6272 5949
6273 5950
6274 Local<ArrayBuffer> v8::ArrayBuffer::New(size_t byte_length) { 5951 Local<ArrayBuffer> v8::ArrayBuffer::New(size_t byte_length) {
6275 i::Isolate* isolate = i::Isolate::Current(); 5952 i::Isolate* isolate = i::Isolate::Current();
6276 EnsureInitializedForIsolate(isolate, "v8::ArrayBuffer::New(size_t)"); 5953 EnsureInitializedForIsolate(isolate, "v8::ArrayBuffer::New(size_t)");
6277 LOG_API(isolate, "v8::ArrayBuffer::New(size_t)"); 5954 LOG_API(isolate, "v8::ArrayBuffer::New(size_t)");
6278 ENTER_V8(isolate); 5955 ENTER_V8(isolate);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
6318 void* v8::ArrayBufferView::BaseAddress() { 5995 void* v8::ArrayBufferView::BaseAddress() {
6319 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); 5996 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this);
6320 i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(obj->buffer())); 5997 i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(obj->buffer()));
6321 void* buffer_data = buffer->backing_store(); 5998 void* buffer_data = buffer->backing_store();
6322 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());
6323 return static_cast<uint8_t*>(buffer_data) + byte_offset; 6000 return static_cast<uint8_t*>(buffer_data) + byte_offset;
6324 } 6001 }
6325 6002
6326 6003
6327 size_t v8::TypedArray::Length() { 6004 size_t v8::TypedArray::Length() {
6328 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
6329 if (IsDeadCheck(isolate, "v8::TypedArray::Length()")) return 0;
6330 i::Handle<i::JSTypedArray> obj = Utils::OpenHandle(this); 6005 i::Handle<i::JSTypedArray> obj = Utils::OpenHandle(this);
6331 return static_cast<size_t>(obj->length()->Number()); 6006 return static_cast<size_t>(obj->length()->Number());
6332 } 6007 }
6333 6008
6334 6009
6335 static inline void SetupArrayBufferView( 6010 static inline void SetupArrayBufferView(
6336 i::Isolate* isolate, 6011 i::Isolate* isolate,
6337 i::Handle<i::JSArrayBufferView> obj, 6012 i::Handle<i::JSArrayBufferView> obj,
6338 i::Handle<i::JSArrayBuffer> buffer, 6013 i::Handle<i::JSArrayBuffer> buffer,
6339 size_t byte_offset, 6014 size_t byte_offset,
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
6577 StackTrace::StackTraceOptions options) { 6252 StackTrace::StackTraceOptions options) {
6578 i::Isolate::Current()->SetCaptureStackTraceForUncaughtExceptions( 6253 i::Isolate::Current()->SetCaptureStackTraceForUncaughtExceptions(
6579 capture, 6254 capture,
6580 frame_limit, 6255 frame_limit,
6581 options); 6256 options);
6582 } 6257 }
6583 6258
6584 6259
6585 void V8::SetCounterFunction(CounterLookupCallback callback) { 6260 void V8::SetCounterFunction(CounterLookupCallback callback) {
6586 i::Isolate* isolate = EnterIsolateIfNeeded(); 6261 i::Isolate* isolate = EnterIsolateIfNeeded();
6587 if (IsDeadCheck(isolate, "v8::V8::SetCounterFunction()")) return;
6588 isolate->stats_table()->SetCounterFunction(callback); 6262 isolate->stats_table()->SetCounterFunction(callback);
6589 } 6263 }
6590 6264
6591 6265
6592 void V8::SetCreateHistogramFunction(CreateHistogramCallback callback) { 6266 void V8::SetCreateHistogramFunction(CreateHistogramCallback callback) {
6593 i::Isolate* isolate = EnterIsolateIfNeeded(); 6267 i::Isolate* isolate = EnterIsolateIfNeeded();
6594 if (IsDeadCheck(isolate, "v8::V8::SetCreateHistogramFunction()")) return;
6595 isolate->stats_table()->SetCreateHistogramFunction(callback); 6268 isolate->stats_table()->SetCreateHistogramFunction(callback);
6596 isolate->InitializeLoggingAndCounters(); 6269 isolate->InitializeLoggingAndCounters();
6597 isolate->counters()->ResetHistograms(); 6270 isolate->counters()->ResetHistograms();
6598 } 6271 }
6599 6272
6600 6273
6601 void V8::SetAddHistogramSampleFunction(AddHistogramSampleCallback callback) { 6274 void V8::SetAddHistogramSampleFunction(AddHistogramSampleCallback callback) {
6602 i::Isolate* isolate = EnterIsolateIfNeeded(); 6275 i::Isolate* isolate = EnterIsolateIfNeeded();
6603 if (IsDeadCheck(isolate, "v8::V8::SetAddHistogramSampleFunction()")) return;
6604 isolate->stats_table()-> 6276 isolate->stats_table()->
6605 SetAddHistogramSampleFunction(callback); 6277 SetAddHistogramSampleFunction(callback);
6606 } 6278 }
6607 6279
6608 void V8::SetFailedAccessCheckCallbackFunction( 6280 void V8::SetFailedAccessCheckCallbackFunction(
6609 FailedAccessCheckCallback callback) { 6281 FailedAccessCheckCallback callback) {
6610 i::Isolate* isolate = i::Isolate::Current(); 6282 i::Isolate* isolate = i::Isolate::Current();
6611 if (IsDeadCheck(isolate, "v8::V8::SetFailedAccessCheckCallbackFunction()")) {
6612 return;
6613 }
6614 isolate->SetFailedAccessCheckCallback(callback); 6283 isolate->SetFailedAccessCheckCallback(callback);
6615 } 6284 }
6616 6285
6617 6286
6618 intptr_t Isolate::AdjustAmountOfExternalAllocatedMemory( 6287 intptr_t Isolate::AdjustAmountOfExternalAllocatedMemory(
6619 intptr_t change_in_bytes) { 6288 intptr_t change_in_bytes) {
6620 i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap(); 6289 i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap();
6621 return heap->AdjustAmountOfExternalAllocatedMemory(change_in_bytes); 6290 return heap->AdjustAmountOfExternalAllocatedMemory(change_in_bytes);
6622 } 6291 }
6623 6292
6624 6293
6625 intptr_t V8::AdjustAmountOfExternalAllocatedMemory(intptr_t change_in_bytes) { 6294 intptr_t V8::AdjustAmountOfExternalAllocatedMemory(intptr_t change_in_bytes) {
6626 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); 6295 i::Isolate* isolate = i::Isolate::UncheckedCurrent();
6627 if (isolate == NULL || !isolate->IsInitialized() || 6296 if (isolate == NULL || !isolate->IsInitialized()) {
6628 IsDeadCheck(isolate, "v8::V8::AdjustAmountOfExternalAllocatedMemory()")) {
6629 return 0; 6297 return 0;
6630 } 6298 }
6631 Isolate* isolate_ext = reinterpret_cast<Isolate*>(isolate); 6299 Isolate* isolate_ext = reinterpret_cast<Isolate*>(isolate);
6632 return isolate_ext->AdjustAmountOfExternalAllocatedMemory(change_in_bytes); 6300 return isolate_ext->AdjustAmountOfExternalAllocatedMemory(change_in_bytes);
6633 } 6301 }
6634 6302
6635 6303
6636 HeapProfiler* Isolate::GetHeapProfiler() { 6304 HeapProfiler* Isolate::GetHeapProfiler() {
6637 i::HeapProfiler* heap_profiler = 6305 i::HeapProfiler* heap_profiler =
6638 reinterpret_cast<i::Isolate*>(this)->heap_profiler(); 6306 reinterpret_cast<i::Isolate*>(this)->heap_profiler();
6639 return reinterpret_cast<HeapProfiler*>(heap_profiler); 6307 return reinterpret_cast<HeapProfiler*>(heap_profiler);
6640 } 6308 }
6641 6309
6642 6310
6643 CpuProfiler* Isolate::GetCpuProfiler() { 6311 CpuProfiler* Isolate::GetCpuProfiler() {
6644 i::CpuProfiler* cpu_profiler = 6312 i::CpuProfiler* cpu_profiler =
6645 reinterpret_cast<i::Isolate*>(this)->cpu_profiler(); 6313 reinterpret_cast<i::Isolate*>(this)->cpu_profiler();
6646 return reinterpret_cast<CpuProfiler*>(cpu_profiler); 6314 return reinterpret_cast<CpuProfiler*>(cpu_profiler);
6647 } 6315 }
6648 6316
6649 6317
6318 bool Isolate::InContext() {
6319 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6320 return isolate->context() != NULL;
6321 }
6322
6323
6650 v8::Local<v8::Context> Isolate::GetCurrentContext() { 6324 v8::Local<v8::Context> Isolate::GetCurrentContext() {
6651 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this); 6325 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6652 i::Context* context = internal_isolate->context(); 6326 i::Context* context = isolate->context();
6653 if (context == NULL) return Local<Context>(); 6327 if (context == NULL) return Local<Context>();
6654 i::Context* native_context = context->global_object()->native_context(); 6328 i::Context* native_context = context->global_object()->native_context();
6655 if (native_context == NULL) return Local<Context>(); 6329 if (native_context == NULL) return Local<Context>();
6656 return Utils::ToLocal(i::Handle<i::Context>(native_context)); 6330 return Utils::ToLocal(i::Handle<i::Context>(native_context));
6657 } 6331 }
6658 6332
6659 6333
6334 v8::Local<v8::Context> Isolate::GetCallingContext() {
6335 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6336 i::Handle<i::Object> calling = isolate->GetCallingNativeContext();
6337 if (calling.is_null()) return Local<Context>();
6338 return Utils::ToLocal(i::Handle<i::Context>::cast(calling));
6339 }
6340
6341
6342 v8::Local<v8::Context> Isolate::GetEnteredContext() {
6343 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6344 i::Handle<i::Object> last =
6345 isolate->handle_scope_implementer()->LastEnteredContext();
6346 if (last.is_null()) return Local<Context>();
6347 return Utils::ToLocal(i::Handle<i::Context>::cast(last));
6348 }
6349
6350
6660 void Isolate::SetObjectGroupId(const Persistent<Value>& object, 6351 void Isolate::SetObjectGroupId(const Persistent<Value>& object,
6661 UniqueId id) { 6352 UniqueId id) {
6662 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this); 6353 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this);
6663 internal_isolate->global_handles()->SetObjectGroupId( 6354 internal_isolate->global_handles()->SetObjectGroupId(
6664 Utils::OpenPersistent(object).location(), 6355 Utils::OpenPersistent(object).location(),
6665 id); 6356 id);
6666 } 6357 }
6667 6358
6668 6359
6669 void Isolate::SetReferenceFromGroup(UniqueId id, 6360 void Isolate::SetReferenceFromGroup(UniqueId id,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
6706 6397
6707 6398
6708 void Isolate::RemoveGCEpilogueCallback(GCEpilogueCallback callback) { 6399 void Isolate::RemoveGCEpilogueCallback(GCEpilogueCallback callback) {
6709 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); 6400 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6710 isolate->heap()->RemoveGCEpilogueCallback(callback); 6401 isolate->heap()->RemoveGCEpilogueCallback(callback);
6711 } 6402 }
6712 6403
6713 6404
6714 void V8::AddGCPrologueCallback(GCPrologueCallback callback, GCType gc_type) { 6405 void V8::AddGCPrologueCallback(GCPrologueCallback callback, GCType gc_type) {
6715 i::Isolate* isolate = i::Isolate::Current(); 6406 i::Isolate* isolate = i::Isolate::Current();
6716 if (IsDeadCheck(isolate, "v8::V8::AddGCPrologueCallback()")) return;
6717 isolate->heap()->AddGCPrologueCallback( 6407 isolate->heap()->AddGCPrologueCallback(
6718 reinterpret_cast<v8::Isolate::GCPrologueCallback>(callback), 6408 reinterpret_cast<v8::Isolate::GCPrologueCallback>(callback),
6719 gc_type, 6409 gc_type,
6720 false); 6410 false);
6721 } 6411 }
6722 6412
6723 6413
6724 void V8::RemoveGCPrologueCallback(GCPrologueCallback callback) { 6414 void V8::RemoveGCPrologueCallback(GCPrologueCallback callback) {
6725 i::Isolate* isolate = i::Isolate::Current(); 6415 i::Isolate* isolate = i::Isolate::Current();
6726 if (IsDeadCheck(isolate, "v8::V8::RemoveGCPrologueCallback()")) return;
6727 isolate->heap()->RemoveGCPrologueCallback( 6416 isolate->heap()->RemoveGCPrologueCallback(
6728 reinterpret_cast<v8::Isolate::GCPrologueCallback>(callback)); 6417 reinterpret_cast<v8::Isolate::GCPrologueCallback>(callback));
6729 } 6418 }
6730 6419
6731 6420
6732 void V8::AddGCEpilogueCallback(GCEpilogueCallback callback, GCType gc_type) { 6421 void V8::AddGCEpilogueCallback(GCEpilogueCallback callback, GCType gc_type) {
6733 i::Isolate* isolate = i::Isolate::Current(); 6422 i::Isolate* isolate = i::Isolate::Current();
6734 if (IsDeadCheck(isolate, "v8::V8::AddGCEpilogueCallback()")) return;
6735 isolate->heap()->AddGCEpilogueCallback( 6423 isolate->heap()->AddGCEpilogueCallback(
6736 reinterpret_cast<v8::Isolate::GCEpilogueCallback>(callback), 6424 reinterpret_cast<v8::Isolate::GCEpilogueCallback>(callback),
6737 gc_type, 6425 gc_type,
6738 false); 6426 false);
6739 } 6427 }
6740 6428
6741 6429
6742 void V8::RemoveGCEpilogueCallback(GCEpilogueCallback callback) { 6430 void V8::RemoveGCEpilogueCallback(GCEpilogueCallback callback) {
6743 i::Isolate* isolate = i::Isolate::Current(); 6431 i::Isolate* isolate = i::Isolate::Current();
6744 if (IsDeadCheck(isolate, "v8::V8::RemoveGCEpilogueCallback()")) return;
6745 isolate->heap()->RemoveGCEpilogueCallback( 6432 isolate->heap()->RemoveGCEpilogueCallback(
6746 reinterpret_cast<v8::Isolate::GCEpilogueCallback>(callback)); 6433 reinterpret_cast<v8::Isolate::GCEpilogueCallback>(callback));
6747 } 6434 }
6748 6435
6749 6436
6750 void V8::AddMemoryAllocationCallback(MemoryAllocationCallback callback, 6437 void V8::AddMemoryAllocationCallback(MemoryAllocationCallback callback,
6751 ObjectSpace space, 6438 ObjectSpace space,
6752 AllocationAction action) { 6439 AllocationAction action) {
6753 i::Isolate* isolate = i::Isolate::Current(); 6440 i::Isolate* isolate = i::Isolate::Current();
6754 if (IsDeadCheck(isolate, "v8::V8::AddMemoryAllocationCallback()")) return;
6755 isolate->memory_allocator()->AddMemoryAllocationCallback( 6441 isolate->memory_allocator()->AddMemoryAllocationCallback(
6756 callback, space, action); 6442 callback, space, action);
6757 } 6443 }
6758 6444
6759 6445
6760 void V8::RemoveMemoryAllocationCallback(MemoryAllocationCallback callback) { 6446 void V8::RemoveMemoryAllocationCallback(MemoryAllocationCallback callback) {
6761 i::Isolate* isolate = i::Isolate::Current(); 6447 i::Isolate* isolate = i::Isolate::Current();
6762 if (IsDeadCheck(isolate, "v8::V8::RemoveMemoryAllocationCallback()")) return;
6763 isolate->memory_allocator()->RemoveMemoryAllocationCallback( 6448 isolate->memory_allocator()->RemoveMemoryAllocationCallback(
6764 callback); 6449 callback);
6765 } 6450 }
6766 6451
6767 6452
6768 void V8::AddCallCompletedCallback(CallCompletedCallback callback) { 6453 void V8::AddCallCompletedCallback(CallCompletedCallback callback) {
6769 if (callback == NULL) return; 6454 if (callback == NULL) return;
6770 i::Isolate* isolate = i::Isolate::Current();
6771 if (IsDeadCheck(isolate, "v8::V8::AddLeaveScriptCallback()")) return;
6772 i::V8::AddCallCompletedCallback(callback); 6455 i::V8::AddCallCompletedCallback(callback);
6773 } 6456 }
6774 6457
6775 6458
6776 void V8::RemoveCallCompletedCallback(CallCompletedCallback callback) { 6459 void V8::RemoveCallCompletedCallback(CallCompletedCallback callback) {
6777 i::Isolate* isolate = i::Isolate::Current();
6778 if (IsDeadCheck(isolate, "v8::V8::RemoveLeaveScriptCallback()")) return;
6779 i::V8::RemoveCallCompletedCallback(callback); 6460 i::V8::RemoveCallCompletedCallback(callback);
6780 } 6461 }
6781 6462
6782 6463
6783 void V8::TerminateExecution(Isolate* isolate) { 6464 void V8::TerminateExecution(Isolate* isolate) {
6784 // If no isolate is supplied, use the default isolate. 6465 // If no isolate is supplied, use the default isolate.
6785 if (isolate != NULL) { 6466 if (isolate != NULL) {
6786 reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->TerminateExecution(); 6467 reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->TerminateExecution();
6787 } else { 6468 } else {
6788 i::Isolate::GetDefaultIsolateStackGuard()->TerminateExecution(); 6469 i::Isolate::GetDefaultIsolateStackGuard()->TerminateExecution();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
6854 heap->CommittedMemoryExecutable(); 6535 heap->CommittedMemoryExecutable();
6855 heap_statistics->total_physical_size_ = heap->CommittedPhysicalMemory(); 6536 heap_statistics->total_physical_size_ = heap->CommittedPhysicalMemory();
6856 heap_statistics->used_heap_size_ = heap->SizeOfObjects(); 6537 heap_statistics->used_heap_size_ = heap->SizeOfObjects();
6857 heap_statistics->heap_size_limit_ = heap->MaxReserved(); 6538 heap_statistics->heap_size_limit_ = heap->MaxReserved();
6858 } 6539 }
6859 6540
6860 6541
6861 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) 6542 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj)
6862 : str_(NULL), length_(0) { 6543 : str_(NULL), length_(0) {
6863 i::Isolate* isolate = i::Isolate::Current(); 6544 i::Isolate* isolate = i::Isolate::Current();
6864 if (IsDeadCheck(isolate, "v8::String::Utf8Value::Utf8Value()")) return;
6865 if (obj.IsEmpty()) return; 6545 if (obj.IsEmpty()) return;
6866 ENTER_V8(isolate); 6546 ENTER_V8(isolate);
6867 i::HandleScope scope(isolate); 6547 i::HandleScope scope(isolate);
6868 TryCatch try_catch; 6548 TryCatch try_catch;
6869 Handle<String> str = obj->ToString(); 6549 Handle<String> str = obj->ToString();
6870 if (str.IsEmpty()) return; 6550 if (str.IsEmpty()) return;
6871 i::Handle<i::String> i_str = Utils::OpenHandle(*str); 6551 i::Handle<i::String> i_str = Utils::OpenHandle(*str);
6872 length_ = v8::Utf8Length(*i_str, isolate); 6552 length_ = v8::Utf8Length(*i_str, isolate);
6873 str_ = i::NewArray<char>(length_ + 1); 6553 str_ = i::NewArray<char>(length_ + 1);
6874 str->WriteUtf8(str_); 6554 str->WriteUtf8(str_);
6875 } 6555 }
6876 6556
6877 6557
6878 String::Utf8Value::~Utf8Value() { 6558 String::Utf8Value::~Utf8Value() {
6879 i::DeleteArray(str_); 6559 i::DeleteArray(str_);
6880 } 6560 }
6881 6561
6882 6562
6883 String::AsciiValue::AsciiValue(v8::Handle<v8::Value> obj) 6563 String::AsciiValue::AsciiValue(v8::Handle<v8::Value> obj)
6884 : str_(NULL), length_(0) { 6564 : str_(NULL), length_(0) {
6885 i::Isolate* isolate = i::Isolate::Current(); 6565 i::Isolate* isolate = i::Isolate::Current();
6886 if (IsDeadCheck(isolate, "v8::String::AsciiValue::AsciiValue()")) return;
6887 if (obj.IsEmpty()) return; 6566 if (obj.IsEmpty()) return;
6888 ENTER_V8(isolate); 6567 ENTER_V8(isolate);
6889 i::HandleScope scope(isolate); 6568 i::HandleScope scope(isolate);
6890 TryCatch try_catch; 6569 TryCatch try_catch;
6891 Handle<String> str = obj->ToString(); 6570 Handle<String> str = obj->ToString();
6892 if (str.IsEmpty()) return; 6571 if (str.IsEmpty()) return;
6893 length_ = str->Utf8Length(); 6572 length_ = str->Utf8Length();
6894 str_ = i::NewArray<char>(length_ + 1); 6573 str_ = i::NewArray<char>(length_ + 1);
6895 str->WriteUtf8(str_); 6574 str->WriteUtf8(str_);
6896 ASSERT(i::String::NonAsciiStart(str_, length_) >= length_); 6575 ASSERT(i::String::NonAsciiStart(str_, length_) >= length_);
6897 } 6576 }
6898 6577
6899 6578
6900 String::AsciiValue::~AsciiValue() { 6579 String::AsciiValue::~AsciiValue() {
6901 i::DeleteArray(str_); 6580 i::DeleteArray(str_);
6902 } 6581 }
6903 6582
6904 6583
6905 String::Value::Value(v8::Handle<v8::Value> obj) 6584 String::Value::Value(v8::Handle<v8::Value> obj)
6906 : str_(NULL), length_(0) { 6585 : str_(NULL), length_(0) {
6907 i::Isolate* isolate = i::Isolate::Current(); 6586 i::Isolate* isolate = i::Isolate::Current();
6908 if (IsDeadCheck(isolate, "v8::String::Value::Value()")) return;
6909 if (obj.IsEmpty()) return; 6587 if (obj.IsEmpty()) return;
6910 ENTER_V8(isolate); 6588 ENTER_V8(isolate);
6911 i::HandleScope scope(isolate); 6589 i::HandleScope scope(isolate);
6912 TryCatch try_catch; 6590 TryCatch try_catch;
6913 Handle<String> str = obj->ToString(); 6591 Handle<String> str = obj->ToString();
6914 if (str.IsEmpty()) return; 6592 if (str.IsEmpty()) return;
6915 length_ = str->Length(); 6593 length_ = str->Length();
6916 str_ = i::NewArray<uint16_t>(length_ + 1); 6594 str_ = i::NewArray<uint16_t>(length_ + 1);
6917 str->Write(str_); 6595 str->Write(str_);
6918 } 6596 }
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
7208 } 6886 }
7209 debugger->set_live_edit_enabled(enable); 6887 debugger->set_live_edit_enabled(enable);
7210 } 6888 }
7211 6889
7212 6890
7213 #endif // ENABLE_DEBUGGER_SUPPORT 6891 #endif // ENABLE_DEBUGGER_SUPPORT
7214 6892
7215 6893
7216 Handle<String> CpuProfileNode::GetFunctionName() const { 6894 Handle<String> CpuProfileNode::GetFunctionName() const {
7217 i::Isolate* isolate = i::Isolate::Current(); 6895 i::Isolate* isolate = i::Isolate::Current();
7218 IsDeadCheck(isolate, "v8::CpuProfileNode::GetFunctionName");
7219 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); 6896 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
7220 const i::CodeEntry* entry = node->entry(); 6897 const i::CodeEntry* entry = node->entry();
7221 if (!entry->has_name_prefix()) { 6898 if (!entry->has_name_prefix()) {
7222 return ToApiHandle<String>( 6899 return ToApiHandle<String>(
7223 isolate->factory()->InternalizeUtf8String(entry->name())); 6900 isolate->factory()->InternalizeUtf8String(entry->name()));
7224 } else { 6901 } else {
7225 return ToApiHandle<String>(isolate->factory()->NewConsString( 6902 return ToApiHandle<String>(isolate->factory()->NewConsString(
7226 isolate->factory()->InternalizeUtf8String(entry->name_prefix()), 6903 isolate->factory()->InternalizeUtf8String(entry->name_prefix()),
7227 isolate->factory()->InternalizeUtf8String(entry->name()))); 6904 isolate->factory()->InternalizeUtf8String(entry->name())));
7228 } 6905 }
7229 } 6906 }
7230 6907
7231 6908
7232 int CpuProfileNode::GetScriptId() const { 6909 int CpuProfileNode::GetScriptId() const {
7233 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); 6910 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
7234 const i::CodeEntry* entry = node->entry(); 6911 const i::CodeEntry* entry = node->entry();
7235 return entry->script_id(); 6912 return entry->script_id();
7236 } 6913 }
7237 6914
7238 6915
7239 Handle<String> CpuProfileNode::GetScriptResourceName() const { 6916 Handle<String> CpuProfileNode::GetScriptResourceName() const {
7240 i::Isolate* isolate = i::Isolate::Current(); 6917 i::Isolate* isolate = i::Isolate::Current();
7241 IsDeadCheck(isolate, "v8::CpuProfileNode::GetScriptResourceName");
7242 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); 6918 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
7243 return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String( 6919 return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String(
7244 node->entry()->resource_name())); 6920 node->entry()->resource_name()));
7245 } 6921 }
7246 6922
7247 6923
7248 int CpuProfileNode::GetLineNumber() const { 6924 int CpuProfileNode::GetLineNumber() const {
7249 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->line_number(); 6925 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->line_number();
7250 } 6926 }
7251 6927
7252 6928
7253 const char* CpuProfileNode::GetBailoutReason() const { 6929 const char* CpuProfileNode::GetBailoutReason() const {
7254 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); 6930 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
7255 return node->entry()->bailout_reason(); 6931 return node->entry()->bailout_reason();
7256 } 6932 }
7257 6933
7258 6934
7259 double CpuProfileNode::GetSelfSamplesCount() const { 6935 double CpuProfileNode::GetSelfSamplesCount() const {
7260 i::Isolate* isolate = i::Isolate::Current();
7261 IsDeadCheck(isolate, "v8::CpuProfileNode::GetSelfSamplesCount");
7262 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks(); 6936 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks();
7263 } 6937 }
7264 6938
7265 6939
7266 unsigned CpuProfileNode::GetHitCount() const { 6940 unsigned CpuProfileNode::GetHitCount() const {
7267 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks(); 6941 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks();
7268 } 6942 }
7269 6943
7270 6944
7271 unsigned CpuProfileNode::GetCallUid() const { 6945 unsigned CpuProfileNode::GetCallUid() const {
(...skipping 13 matching lines...) Expand all
7285 6959
7286 const CpuProfileNode* CpuProfileNode::GetChild(int index) const { 6960 const CpuProfileNode* CpuProfileNode::GetChild(int index) const {
7287 const i::ProfileNode* child = 6961 const i::ProfileNode* child =
7288 reinterpret_cast<const i::ProfileNode*>(this)->children()->at(index); 6962 reinterpret_cast<const i::ProfileNode*>(this)->children()->at(index);
7289 return reinterpret_cast<const CpuProfileNode*>(child); 6963 return reinterpret_cast<const CpuProfileNode*>(child);
7290 } 6964 }
7291 6965
7292 6966
7293 void CpuProfile::Delete() { 6967 void CpuProfile::Delete() {
7294 i::Isolate* isolate = i::Isolate::Current(); 6968 i::Isolate* isolate = i::Isolate::Current();
7295 IsDeadCheck(isolate, "v8::CpuProfile::Delete");
7296 i::CpuProfiler* profiler = isolate->cpu_profiler(); 6969 i::CpuProfiler* profiler = isolate->cpu_profiler();
7297 ASSERT(profiler != NULL); 6970 ASSERT(profiler != NULL);
7298 profiler->DeleteProfile(reinterpret_cast<i::CpuProfile*>(this)); 6971 profiler->DeleteProfile(reinterpret_cast<i::CpuProfile*>(this));
7299 if (profiler->GetProfilesCount() == 0) { 6972 if (profiler->GetProfilesCount() == 0) {
7300 // 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.
7301 profiler->DeleteAllProfiles(); 6974 profiler->DeleteAllProfiles();
7302 } 6975 }
7303 } 6976 }
7304 6977
7305 6978
7306 unsigned CpuProfile::GetUid() const { 6979 unsigned CpuProfile::GetUid() const {
7307 return reinterpret_cast<const i::CpuProfile*>(this)->uid(); 6980 return reinterpret_cast<const i::CpuProfile*>(this)->uid();
7308 } 6981 }
7309 6982
7310 6983
7311 Handle<String> CpuProfile::GetTitle() const { 6984 Handle<String> CpuProfile::GetTitle() const {
7312 i::Isolate* isolate = i::Isolate::Current(); 6985 i::Isolate* isolate = i::Isolate::Current();
7313 IsDeadCheck(isolate, "v8::CpuProfile::GetTitle");
7314 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); 6986 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
7315 return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String( 6987 return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String(
7316 profile->title())); 6988 profile->title()));
7317 } 6989 }
7318 6990
7319 6991
7320 const CpuProfileNode* CpuProfile::GetTopDownRoot() const { 6992 const CpuProfileNode* CpuProfile::GetTopDownRoot() const {
7321 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); 6993 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
7322 return reinterpret_cast<const CpuProfileNode*>(profile->top_down()->root()); 6994 return reinterpret_cast<const CpuProfileNode*>(profile->top_down()->root());
7323 } 6995 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
7395 } 7067 }
7396 7068
7397 7069
7398 static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) { 7070 static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) {
7399 return const_cast<i::HeapGraphEdge*>( 7071 return const_cast<i::HeapGraphEdge*>(
7400 reinterpret_cast<const i::HeapGraphEdge*>(edge)); 7072 reinterpret_cast<const i::HeapGraphEdge*>(edge));
7401 } 7073 }
7402 7074
7403 7075
7404 HeapGraphEdge::Type HeapGraphEdge::GetType() const { 7076 HeapGraphEdge::Type HeapGraphEdge::GetType() const {
7405 i::Isolate* isolate = i::Isolate::Current();
7406 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetType");
7407 return static_cast<HeapGraphEdge::Type>(ToInternal(this)->type()); 7077 return static_cast<HeapGraphEdge::Type>(ToInternal(this)->type());
7408 } 7078 }
7409 7079
7410 7080
7411 Handle<Value> HeapGraphEdge::GetName() const { 7081 Handle<Value> HeapGraphEdge::GetName() const {
7412 i::Isolate* isolate = i::Isolate::Current(); 7082 i::Isolate* isolate = i::Isolate::Current();
7413 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetName");
7414 i::HeapGraphEdge* edge = ToInternal(this); 7083 i::HeapGraphEdge* edge = ToInternal(this);
7415 switch (edge->type()) { 7084 switch (edge->type()) {
7416 case i::HeapGraphEdge::kContextVariable: 7085 case i::HeapGraphEdge::kContextVariable:
7417 case i::HeapGraphEdge::kInternal: 7086 case i::HeapGraphEdge::kInternal:
7418 case i::HeapGraphEdge::kProperty: 7087 case i::HeapGraphEdge::kProperty:
7419 case i::HeapGraphEdge::kShortcut: 7088 case i::HeapGraphEdge::kShortcut:
7420 return ToApiHandle<String>( 7089 return ToApiHandle<String>(
7421 isolate->factory()->InternalizeUtf8String(edge->name())); 7090 isolate->factory()->InternalizeUtf8String(edge->name()));
7422 case i::HeapGraphEdge::kElement: 7091 case i::HeapGraphEdge::kElement:
7423 case i::HeapGraphEdge::kHidden: 7092 case i::HeapGraphEdge::kHidden:
7424 case i::HeapGraphEdge::kWeak: 7093 case i::HeapGraphEdge::kWeak:
7425 return ToApiHandle<Number>( 7094 return ToApiHandle<Number>(
7426 isolate->factory()->NewNumberFromInt(edge->index())); 7095 isolate->factory()->NewNumberFromInt(edge->index()));
7427 default: UNREACHABLE(); 7096 default: UNREACHABLE();
7428 } 7097 }
7429 return v8::Undefined(); 7098 return v8::Undefined();
7430 } 7099 }
7431 7100
7432 7101
7433 const HeapGraphNode* HeapGraphEdge::GetFromNode() const { 7102 const HeapGraphNode* HeapGraphEdge::GetFromNode() const {
7434 i::Isolate* isolate = i::Isolate::Current();
7435 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetFromNode");
7436 const i::HeapEntry* from = ToInternal(this)->from(); 7103 const i::HeapEntry* from = ToInternal(this)->from();
7437 return reinterpret_cast<const HeapGraphNode*>(from); 7104 return reinterpret_cast<const HeapGraphNode*>(from);
7438 } 7105 }
7439 7106
7440 7107
7441 const HeapGraphNode* HeapGraphEdge::GetToNode() const { 7108 const HeapGraphNode* HeapGraphEdge::GetToNode() const {
7442 i::Isolate* isolate = i::Isolate::Current();
7443 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetToNode");
7444 const i::HeapEntry* to = ToInternal(this)->to(); 7109 const i::HeapEntry* to = ToInternal(this)->to();
7445 return reinterpret_cast<const HeapGraphNode*>(to); 7110 return reinterpret_cast<const HeapGraphNode*>(to);
7446 } 7111 }
7447 7112
7448 7113
7449 static i::HeapEntry* ToInternal(const HeapGraphNode* entry) { 7114 static i::HeapEntry* ToInternal(const HeapGraphNode* entry) {
7450 return const_cast<i::HeapEntry*>( 7115 return const_cast<i::HeapEntry*>(
7451 reinterpret_cast<const i::HeapEntry*>(entry)); 7116 reinterpret_cast<const i::HeapEntry*>(entry));
7452 } 7117 }
7453 7118
7454 7119
7455 HeapGraphNode::Type HeapGraphNode::GetType() const { 7120 HeapGraphNode::Type HeapGraphNode::GetType() const {
7456 i::Isolate* isolate = i::Isolate::Current();
7457 IsDeadCheck(isolate, "v8::HeapGraphNode::GetType");
7458 return static_cast<HeapGraphNode::Type>(ToInternal(this)->type()); 7121 return static_cast<HeapGraphNode::Type>(ToInternal(this)->type());
7459 } 7122 }
7460 7123
7461 7124
7462 Handle<String> HeapGraphNode::GetName() const { 7125 Handle<String> HeapGraphNode::GetName() const {
7463 i::Isolate* isolate = i::Isolate::Current(); 7126 i::Isolate* isolate = i::Isolate::Current();
7464 IsDeadCheck(isolate, "v8::HeapGraphNode::GetName");
7465 return ToApiHandle<String>( 7127 return ToApiHandle<String>(
7466 isolate->factory()->InternalizeUtf8String(ToInternal(this)->name())); 7128 isolate->factory()->InternalizeUtf8String(ToInternal(this)->name()));
7467 } 7129 }
7468 7130
7469 7131
7470 SnapshotObjectId HeapGraphNode::GetId() const { 7132 SnapshotObjectId HeapGraphNode::GetId() const {
7471 i::Isolate* isolate = i::Isolate::Current();
7472 IsDeadCheck(isolate, "v8::HeapGraphNode::GetId");
7473 return ToInternal(this)->id(); 7133 return ToInternal(this)->id();
7474 } 7134 }
7475 7135
7476 7136
7477 int HeapGraphNode::GetSelfSize() const { 7137 int HeapGraphNode::GetSelfSize() const {
7478 i::Isolate* isolate = i::Isolate::Current();
7479 IsDeadCheck(isolate, "v8::HeapGraphNode::GetSelfSize");
7480 return ToInternal(this)->self_size(); 7138 return ToInternal(this)->self_size();
7481 } 7139 }
7482 7140
7483 7141
7484 int HeapGraphNode::GetChildrenCount() const { 7142 int HeapGraphNode::GetChildrenCount() const {
7485 i::Isolate* isolate = i::Isolate::Current();
7486 IsDeadCheck(isolate, "v8::HeapSnapshot::GetChildrenCount");
7487 return ToInternal(this)->children().length(); 7143 return ToInternal(this)->children().length();
7488 } 7144 }
7489 7145
7490 7146
7491 const HeapGraphEdge* HeapGraphNode::GetChild(int index) const { 7147 const HeapGraphEdge* HeapGraphNode::GetChild(int index) const {
7492 i::Isolate* isolate = i::Isolate::Current();
7493 IsDeadCheck(isolate, "v8::HeapSnapshot::GetChild");
7494 return reinterpret_cast<const HeapGraphEdge*>( 7148 return reinterpret_cast<const HeapGraphEdge*>(
7495 ToInternal(this)->children()[index]); 7149 ToInternal(this)->children()[index]);
7496 } 7150 }
7497 7151
7498 7152
7499 v8::Handle<v8::Value> HeapGraphNode::GetHeapValue() const { 7153 v8::Handle<v8::Value> HeapGraphNode::GetHeapValue() const {
7500 i::Isolate* isolate = i::Isolate::Current(); 7154 i::Isolate* isolate = i::Isolate::Current();
7501 IsDeadCheck(isolate, "v8::HeapGraphNode::GetHeapValue");
7502 i::Handle<i::HeapObject> object = ToInternal(this)->GetHeapObject(); 7155 i::Handle<i::HeapObject> object = ToInternal(this)->GetHeapObject();
7503 return !object.is_null() ? 7156 return !object.is_null() ?
7504 ToApiHandle<Value>(object) : 7157 ToApiHandle<Value>(object) :
7505 ToApiHandle<Value>(isolate->factory()->undefined_value()); 7158 ToApiHandle<Value>(isolate->factory()->undefined_value());
7506 } 7159 }
7507 7160
7508 7161
7509 static i::HeapSnapshot* ToInternal(const HeapSnapshot* snapshot) { 7162 static i::HeapSnapshot* ToInternal(const HeapSnapshot* snapshot) {
7510 return const_cast<i::HeapSnapshot*>( 7163 return const_cast<i::HeapSnapshot*>(
7511 reinterpret_cast<const i::HeapSnapshot*>(snapshot)); 7164 reinterpret_cast<const i::HeapSnapshot*>(snapshot));
7512 } 7165 }
7513 7166
7514 7167
7515 void HeapSnapshot::Delete() { 7168 void HeapSnapshot::Delete() {
7516 i::Isolate* isolate = i::Isolate::Current(); 7169 i::Isolate* isolate = i::Isolate::Current();
7517 IsDeadCheck(isolate, "v8::HeapSnapshot::Delete");
7518 if (isolate->heap_profiler()->GetSnapshotsCount() > 1) { 7170 if (isolate->heap_profiler()->GetSnapshotsCount() > 1) {
7519 ToInternal(this)->Delete(); 7171 ToInternal(this)->Delete();
7520 } else { 7172 } else {
7521 // 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.
7522 isolate->heap_profiler()->DeleteAllSnapshots(); 7174 isolate->heap_profiler()->DeleteAllSnapshots();
7523 } 7175 }
7524 } 7176 }
7525 7177
7526 7178
7527 unsigned HeapSnapshot::GetUid() const { 7179 unsigned HeapSnapshot::GetUid() const {
7528 i::Isolate* isolate = i::Isolate::Current();
7529 IsDeadCheck(isolate, "v8::HeapSnapshot::GetUid");
7530 return ToInternal(this)->uid(); 7180 return ToInternal(this)->uid();
7531 } 7181 }
7532 7182
7533 7183
7534 Handle<String> HeapSnapshot::GetTitle() const { 7184 Handle<String> HeapSnapshot::GetTitle() const {
7535 i::Isolate* isolate = i::Isolate::Current(); 7185 i::Isolate* isolate = i::Isolate::Current();
7536 IsDeadCheck(isolate, "v8::HeapSnapshot::GetTitle");
7537 return ToApiHandle<String>( 7186 return ToApiHandle<String>(
7538 isolate->factory()->InternalizeUtf8String(ToInternal(this)->title())); 7187 isolate->factory()->InternalizeUtf8String(ToInternal(this)->title()));
7539 } 7188 }
7540 7189
7541 7190
7542 const HeapGraphNode* HeapSnapshot::GetRoot() const { 7191 const HeapGraphNode* HeapSnapshot::GetRoot() const {
7543 i::Isolate* isolate = i::Isolate::Current();
7544 IsDeadCheck(isolate, "v8::HeapSnapshot::GetHead");
7545 return reinterpret_cast<const HeapGraphNode*>(ToInternal(this)->root()); 7192 return reinterpret_cast<const HeapGraphNode*>(ToInternal(this)->root());
7546 } 7193 }
7547 7194
7548 7195
7549 const HeapGraphNode* HeapSnapshot::GetNodeById(SnapshotObjectId id) const { 7196 const HeapGraphNode* HeapSnapshot::GetNodeById(SnapshotObjectId id) const {
7550 i::Isolate* isolate = i::Isolate::Current();
7551 IsDeadCheck(isolate, "v8::HeapSnapshot::GetNodeById");
7552 return reinterpret_cast<const HeapGraphNode*>( 7197 return reinterpret_cast<const HeapGraphNode*>(
7553 ToInternal(this)->GetEntryById(id)); 7198 ToInternal(this)->GetEntryById(id));
7554 } 7199 }
7555 7200
7556 7201
7557 int HeapSnapshot::GetNodesCount() const { 7202 int HeapSnapshot::GetNodesCount() const {
7558 i::Isolate* isolate = i::Isolate::Current();
7559 IsDeadCheck(isolate, "v8::HeapSnapshot::GetNodesCount");
7560 return ToInternal(this)->entries().length(); 7203 return ToInternal(this)->entries().length();
7561 } 7204 }
7562 7205
7563 7206
7564 const HeapGraphNode* HeapSnapshot::GetNode(int index) const { 7207 const HeapGraphNode* HeapSnapshot::GetNode(int index) const {
7565 i::Isolate* isolate = i::Isolate::Current();
7566 IsDeadCheck(isolate, "v8::HeapSnapshot::GetNode");
7567 return reinterpret_cast<const HeapGraphNode*>( 7208 return reinterpret_cast<const HeapGraphNode*>(
7568 &ToInternal(this)->entries().at(index)); 7209 &ToInternal(this)->entries().at(index));
7569 } 7210 }
7570 7211
7571 7212
7572 SnapshotObjectId HeapSnapshot::GetMaxSnapshotJSObjectId() const { 7213 SnapshotObjectId HeapSnapshot::GetMaxSnapshotJSObjectId() const {
7573 i::Isolate* isolate = i::Isolate::Current();
7574 IsDeadCheck(isolate, "v8::HeapSnapshot::GetMaxSnapshotJSObjectId");
7575 return ToInternal(this)->max_snapshot_js_object_id(); 7214 return ToInternal(this)->max_snapshot_js_object_id();
7576 } 7215 }
7577 7216
7578 7217
7579 void HeapSnapshot::Serialize(OutputStream* stream, 7218 void HeapSnapshot::Serialize(OutputStream* stream,
7580 HeapSnapshot::SerializationFormat format) const { 7219 HeapSnapshot::SerializationFormat format) const {
7581 i::Isolate* isolate = i::Isolate::Current();
7582 IsDeadCheck(isolate, "v8::HeapSnapshot::Serialize");
7583 ApiCheck(format == kJSON, 7220 ApiCheck(format == kJSON,
7584 "v8::HeapSnapshot::Serialize", 7221 "v8::HeapSnapshot::Serialize",
7585 "Unknown serialization format"); 7222 "Unknown serialization format");
7586 ApiCheck(stream->GetOutputEncoding() == OutputStream::kAscii, 7223 ApiCheck(stream->GetOutputEncoding() == OutputStream::kAscii,
7587 "v8::HeapSnapshot::Serialize", 7224 "v8::HeapSnapshot::Serialize",
7588 "Unsupported output encoding"); 7225 "Unsupported output encoding");
7589 ApiCheck(stream->GetChunkSize() > 0, 7226 ApiCheck(stream->GetChunkSize() > 0,
7590 "v8::HeapSnapshot::Serialize", 7227 "v8::HeapSnapshot::Serialize",
7591 "Invalid stream chunk size"); 7228 "Invalid stream chunk size");
7592 i::HeapSnapshotJSONSerializer serializer(ToInternal(this)); 7229 i::HeapSnapshotJSONSerializer serializer(ToInternal(this));
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
7783 } 7420 }
7784 7421
7785 ASSERT(last_handle_before_deferred_block_ == NULL || 7422 ASSERT(last_handle_before_deferred_block_ == NULL ||
7786 found_block_before_deferred); 7423 found_block_before_deferred);
7787 7424
7788 // Iterate over live handles in the last block (if any). 7425 // Iterate over live handles in the last block (if any).
7789 if (!blocks()->is_empty()) { 7426 if (!blocks()->is_empty()) {
7790 v->VisitPointers(blocks()->last(), handle_scope_data_.next); 7427 v->VisitPointers(blocks()->last(), handle_scope_data_.next);
7791 } 7428 }
7792 7429
7793 if (!saved_contexts_.is_empty()) { 7430 List<Context*>* context_lists[2] = { &saved_contexts_, &entered_contexts_};
7794 Object** start = reinterpret_cast<Object**>(&saved_contexts_.first()); 7431 for (unsigned i = 0; i < ARRAY_SIZE(context_lists); i++) {
7795 v->VisitPointers(start, start + saved_contexts_.length()); 7432 if (context_lists[i]->is_empty()) continue;
7433 Object** start = reinterpret_cast<Object**>(&context_lists[i]->first());
7434 v->VisitPointers(start, start + context_lists[i]->length());
7796 } 7435 }
7797 } 7436 }
7798 7437
7799 7438
7800 void HandleScopeImplementer::Iterate(ObjectVisitor* v) { 7439 void HandleScopeImplementer::Iterate(ObjectVisitor* v) {
7801 v8::ImplementationUtilities::HandleScopeData* current = 7440 v8::ImplementationUtilities::HandleScopeData* current =
7802 isolate_->handle_scope_data(); 7441 isolate_->handle_scope_data();
7803 handle_scope_data_ = *current; 7442 handle_scope_data_ = *current;
7804 IterateThis(v); 7443 IterateThis(v);
7805 } 7444 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
7892 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7531 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7893 Address callback_address = 7532 Address callback_address =
7894 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7533 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7895 VMState<EXTERNAL> state(isolate); 7534 VMState<EXTERNAL> state(isolate);
7896 ExternalCallbackScope call_scope(isolate, callback_address); 7535 ExternalCallbackScope call_scope(isolate, callback_address);
7897 callback(info); 7536 callback(info);
7898 } 7537 }
7899 7538
7900 7539
7901 } } // namespace v8::internal 7540 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.h ('k') | src/arm/assembler-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698