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

Side by Side Diff: src/api.cc

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

Powered by Google App Engine
This is Rietveld 408576698