| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 void V8::SetFlagsFromString(const char* str, int length) { | 465 void V8::SetFlagsFromString(const char* str, int length) { |
| 466 i::FlagList::SetFlagsFromString(str, length); | 466 i::FlagList::SetFlagsFromString(str, length); |
| 467 } | 467 } |
| 468 | 468 |
| 469 | 469 |
| 470 void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) { | 470 void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) { |
| 471 i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags); | 471 i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags); |
| 472 } | 472 } |
| 473 | 473 |
| 474 | 474 |
| 475 v8::Handle<Value> ThrowException(v8::Handle<v8::Value> value) { | |
| 476 return v8::Isolate::GetCurrent()->ThrowException(value); | |
| 477 } | |
| 478 | |
| 479 | |
| 480 RegisteredExtension* RegisteredExtension::first_extension_ = NULL; | 475 RegisteredExtension* RegisteredExtension::first_extension_ = NULL; |
| 481 | 476 |
| 482 | 477 |
| 483 RegisteredExtension::RegisteredExtension(Extension* extension) | 478 RegisteredExtension::RegisteredExtension(Extension* extension) |
| 484 : extension_(extension) { } | 479 : extension_(extension) { } |
| 485 | 480 |
| 486 | 481 |
| 487 void RegisteredExtension::Register(RegisteredExtension* that) { | 482 void RegisteredExtension::Register(RegisteredExtension* that) { |
| 488 that->next_ = first_extension_; | 483 that->next_ = first_extension_; |
| 489 first_extension_ = that; | 484 first_extension_ = that; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 516 source_length : | 511 source_length : |
| 517 (source ? static_cast<int>(strlen(source)) : 0)), | 512 (source ? static_cast<int>(strlen(source)) : 0)), |
| 518 source_(source, source_length_), | 513 source_(source, source_length_), |
| 519 dep_count_(dep_count), | 514 dep_count_(dep_count), |
| 520 deps_(deps), | 515 deps_(deps), |
| 521 auto_enable_(false) { | 516 auto_enable_(false) { |
| 522 CHECK(source != NULL || source_length_ == 0); | 517 CHECK(source != NULL || source_length_ == 0); |
| 523 } | 518 } |
| 524 | 519 |
| 525 | 520 |
| 526 v8::Handle<Primitive> Undefined() { | |
| 527 i::Isolate* isolate = i::Isolate::Current(); | |
| 528 if (!EnsureInitializedForIsolate(isolate, "v8::Undefined()")) { | |
| 529 return v8::Handle<v8::Primitive>(); | |
| 530 } | |
| 531 return ToApiHandle<Primitive>(isolate->factory()->undefined_value()); | |
| 532 } | |
| 533 | |
| 534 | |
| 535 v8::Handle<Primitive> Null() { | |
| 536 i::Isolate* isolate = i::Isolate::Current(); | |
| 537 if (!EnsureInitializedForIsolate(isolate, "v8::Null()")) { | |
| 538 return v8::Handle<v8::Primitive>(); | |
| 539 } | |
| 540 return ToApiHandle<Primitive>(isolate->factory()->null_value()); | |
| 541 } | |
| 542 | |
| 543 | |
| 544 v8::Handle<Boolean> True() { | |
| 545 i::Isolate* isolate = i::Isolate::Current(); | |
| 546 if (!EnsureInitializedForIsolate(isolate, "v8::True()")) { | |
| 547 return v8::Handle<Boolean>(); | |
| 548 } | |
| 549 return ToApiHandle<Boolean>(isolate->factory()->true_value()); | |
| 550 } | |
| 551 | |
| 552 | |
| 553 v8::Handle<Boolean> False() { | |
| 554 i::Isolate* isolate = i::Isolate::Current(); | |
| 555 if (!EnsureInitializedForIsolate(isolate, "v8::False()")) { | |
| 556 return v8::Handle<Boolean>(); | |
| 557 } | |
| 558 return ToApiHandle<Boolean>(isolate->factory()->false_value()); | |
| 559 } | |
| 560 | |
| 561 | |
| 562 ResourceConstraints::ResourceConstraints() | 521 ResourceConstraints::ResourceConstraints() |
| 563 : max_young_space_size_(0), | 522 : max_young_space_size_(0), |
| 564 max_old_space_size_(0), | 523 max_old_space_size_(0), |
| 565 max_executable_size_(0), | 524 max_executable_size_(0), |
| 566 stack_limit_(NULL), | 525 stack_limit_(NULL), |
| 567 max_available_threads_(0) { } | 526 max_available_threads_(0) { } |
| 568 | 527 |
| 569 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, | 528 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, |
| 570 uint32_t number_of_processors) { | 529 uint32_t number_of_processors) { |
| 571 const int lump_of_memory = (i::kPointerSize / 4) * i::MB; | 530 const int lump_of_memory = (i::kPointerSize / 4) * i::MB; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 598 } else { | 557 } else { |
| 599 set_max_young_space_size(16 * lump_of_memory); | 558 set_max_young_space_size(16 * lump_of_memory); |
| 600 set_max_old_space_size(700 * lump_of_memory); | 559 set_max_old_space_size(700 * lump_of_memory); |
| 601 set_max_executable_size(256 * lump_of_memory); | 560 set_max_executable_size(256 * lump_of_memory); |
| 602 } | 561 } |
| 603 | 562 |
| 604 set_max_available_threads(i::Max(i::Min(number_of_processors, 4u), 1u)); | 563 set_max_available_threads(i::Max(i::Min(number_of_processors, 4u), 1u)); |
| 605 } | 564 } |
| 606 | 565 |
| 607 | 566 |
| 608 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory) { | |
| 609 ConfigureDefaults(physical_memory, i::CPU::NumberOfProcessorsOnline()); | |
| 610 } | |
| 611 | |
| 612 | |
| 613 bool SetResourceConstraints(Isolate* v8_isolate, | 567 bool SetResourceConstraints(Isolate* v8_isolate, |
| 614 ResourceConstraints* constraints) { | 568 ResourceConstraints* constraints) { |
| 615 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 569 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
| 616 int young_space_size = constraints->max_young_space_size(); | 570 int young_space_size = constraints->max_young_space_size(); |
| 617 int old_gen_size = constraints->max_old_space_size(); | 571 int old_gen_size = constraints->max_old_space_size(); |
| 618 int max_executable_size = constraints->max_executable_size(); | 572 int max_executable_size = constraints->max_executable_size(); |
| 619 if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0) { | 573 if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0) { |
| 620 // After initialization it's too late to change Heap constraints. | 574 // After initialization it's too late to change Heap constraints. |
| 621 ASSERT(!isolate->IsInitialized()); | 575 ASSERT(!isolate->IsInitialized()); |
| 622 bool result = isolate->heap()->ConfigureHeap(young_space_size / 2, | 576 bool result = isolate->heap()->ConfigureHeap(young_space_size / 2, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 648 i::Handle<i::Object> result = i::GlobalHandles::CopyGlobal(obj); | 602 i::Handle<i::Object> result = i::GlobalHandles::CopyGlobal(obj); |
| 649 #ifdef DEBUG | 603 #ifdef DEBUG |
| 650 (*obj)->Verify(); | 604 (*obj)->Verify(); |
| 651 #endif // DEBUG | 605 #endif // DEBUG |
| 652 return result.location(); | 606 return result.location(); |
| 653 } | 607 } |
| 654 | 608 |
| 655 | 609 |
| 656 void V8::MakeWeak(i::Object** object, | 610 void V8::MakeWeak(i::Object** object, |
| 657 void* parameters, | 611 void* parameters, |
| 658 WeakCallback weak_callback, | 612 WeakCallback weak_callback) { |
| 659 RevivableCallback weak_reference_callback) { | 613 i::GlobalHandles::MakeWeak(object, parameters, weak_callback); |
| 660 i::GlobalHandles::MakeWeak(object, | |
| 661 parameters, | |
| 662 weak_callback, | |
| 663 weak_reference_callback); | |
| 664 } | 614 } |
| 665 | 615 |
| 666 | 616 |
| 667 void V8::ClearWeak(i::Object** obj) { | 617 void V8::ClearWeak(i::Object** obj) { |
| 668 i::GlobalHandles::ClearWeakness(obj); | 618 i::GlobalHandles::ClearWeakness(obj); |
| 669 } | 619 } |
| 670 | 620 |
| 671 | 621 |
| 672 void V8::DisposeGlobal(i::Object** obj) { | 622 void V8::DisposeGlobal(i::Object** obj) { |
| 673 i::GlobalHandles::Destroy(obj); | 623 i::GlobalHandles::Destroy(obj); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 696 | 646 |
| 697 | 647 |
| 698 void HandleScope::Initialize(Isolate* isolate) { | 648 void HandleScope::Initialize(Isolate* isolate) { |
| 699 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); | 649 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 700 API_ENTRY_CHECK(internal_isolate, "HandleScope::HandleScope"); | 650 API_ENTRY_CHECK(internal_isolate, "HandleScope::HandleScope"); |
| 701 v8::ImplementationUtilities::HandleScopeData* current = | 651 v8::ImplementationUtilities::HandleScopeData* current = |
| 702 internal_isolate->handle_scope_data(); | 652 internal_isolate->handle_scope_data(); |
| 703 isolate_ = internal_isolate; | 653 isolate_ = internal_isolate; |
| 704 prev_next_ = current->next; | 654 prev_next_ = current->next; |
| 705 prev_limit_ = current->limit; | 655 prev_limit_ = current->limit; |
| 706 is_closed_ = false; | |
| 707 current->level++; | 656 current->level++; |
| 708 } | 657 } |
| 709 | 658 |
| 710 | 659 |
| 711 HandleScope::~HandleScope() { | 660 HandleScope::~HandleScope() { |
| 712 if (!is_closed_) { | 661 i::HandleScope::CloseScope(isolate_, prev_next_, prev_limit_); |
| 713 Leave(); | |
| 714 } | |
| 715 } | 662 } |
| 716 | 663 |
| 717 | 664 |
| 718 void HandleScope::Leave() { | |
| 719 return i::HandleScope::CloseScope(isolate_, prev_next_, prev_limit_); | |
| 720 } | |
| 721 | |
| 722 | |
| 723 int HandleScope::NumberOfHandles() { | 665 int HandleScope::NumberOfHandles() { |
| 724 i::Isolate* isolate = i::Isolate::Current(); | 666 i::Isolate* isolate = i::Isolate::Current(); |
| 725 if (!EnsureInitializedForIsolate(isolate, "HandleScope::NumberOfHandles")) { | 667 if (!EnsureInitializedForIsolate(isolate, "HandleScope::NumberOfHandles")) { |
| 726 return 0; | 668 return 0; |
| 727 } | 669 } |
| 728 return i::HandleScope::NumberOfHandles(isolate); | 670 return i::HandleScope::NumberOfHandles(isolate); |
| 729 } | 671 } |
| 730 | 672 |
| 731 | 673 |
| 732 i::Object** HandleScope::CreateHandle(i::Isolate* isolate, i::Object* value) { | 674 i::Object** HandleScope::CreateHandle(i::Isolate* isolate, i::Object* value) { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 | 794 |
| 853 | 795 |
| 854 void Context::SetAlignedPointerInEmbedderData(int index, void* value) { | 796 void Context::SetAlignedPointerInEmbedderData(int index, void* value) { |
| 855 const char* location = "v8::Context::SetAlignedPointerInEmbedderData()"; | 797 const char* location = "v8::Context::SetAlignedPointerInEmbedderData()"; |
| 856 i::Handle<i::FixedArray> data = EmbedderDataFor(this, index, true, location); | 798 i::Handle<i::FixedArray> data = EmbedderDataFor(this, index, true, location); |
| 857 data->set(index, EncodeAlignedAsSmi(value, location)); | 799 data->set(index, EncodeAlignedAsSmi(value, location)); |
| 858 ASSERT_EQ(value, GetAlignedPointerFromEmbedderData(index)); | 800 ASSERT_EQ(value, GetAlignedPointerFromEmbedderData(index)); |
| 859 } | 801 } |
| 860 | 802 |
| 861 | 803 |
| 862 i::Object** v8::HandleScope::RawClose(i::Object** value) { | |
| 863 if (!ApiCheck(!is_closed_, | |
| 864 "v8::HandleScope::Close()", | |
| 865 "Local scope has already been closed")) { | |
| 866 return 0; | |
| 867 } | |
| 868 LOG_API(isolate_, "CloseHandleScope"); | |
| 869 | |
| 870 // Read the result before popping the handle block. | |
| 871 i::Object* result = NULL; | |
| 872 if (value != NULL) { | |
| 873 result = *value; | |
| 874 } | |
| 875 is_closed_ = true; | |
| 876 Leave(); | |
| 877 | |
| 878 if (value == NULL) { | |
| 879 return NULL; | |
| 880 } | |
| 881 | |
| 882 // Allocate a new handle on the previous handle block. | |
| 883 i::Handle<i::Object> handle(result, isolate_); | |
| 884 return handle.location(); | |
| 885 } | |
| 886 | |
| 887 | |
| 888 // --- N e a n d e r --- | 804 // --- N e a n d e r --- |
| 889 | 805 |
| 890 | 806 |
| 891 // A constructor cannot easily return an error value, therefore it is necessary | 807 // A constructor cannot easily return an error value, therefore it is necessary |
| 892 // to check for a dead VM with ON_BAILOUT before constructing any Neander | 808 // to check for a dead VM with ON_BAILOUT before constructing any Neander |
| 893 // objects. To remind you about this there is no HandleScope in the | 809 // objects. To remind you about this there is no HandleScope in the |
| 894 // NeanderObject constructor. When you add one to the site calling the | 810 // NeanderObject constructor. When you add one to the site calling the |
| 895 // constructor you should check that you ensured the VM was not dead first. | 811 // constructor you should check that you ensured the VM was not dead first. |
| 896 NeanderObject::NeanderObject(int size) { | 812 NeanderObject::NeanderObject(int size) { |
| 897 i::Isolate* isolate = i::Isolate::Current(); | 813 i::Isolate* isolate = i::Isolate::Current(); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 for (int i = 0; i < argc; i++) { | 1033 for (int i = 0; i < argc; i++) { |
| 1118 if (!argv[i].IsEmpty()) | 1034 if (!argv[i].IsEmpty()) |
| 1119 args->set(i, *Utils::OpenHandle(*argv[i])); | 1035 args->set(i, *Utils::OpenHandle(*argv[i])); |
| 1120 } | 1036 } |
| 1121 obj->set_args(*args); | 1037 obj->set_args(*args); |
| 1122 } | 1038 } |
| 1123 return Utils::ToLocal(obj); | 1039 return Utils::ToLocal(obj); |
| 1124 } | 1040 } |
| 1125 | 1041 |
| 1126 | 1042 |
| 1127 Local<Signature> Signature::New(Handle<FunctionTemplate> receiver, | |
| 1128 int argc, Handle<FunctionTemplate> argv[]) { | |
| 1129 return New(Isolate::GetCurrent(), receiver, argc, argv); | |
| 1130 } | |
| 1131 | |
| 1132 | |
| 1133 Local<AccessorSignature> AccessorSignature::New( | 1043 Local<AccessorSignature> AccessorSignature::New( |
| 1134 Isolate* isolate, | 1044 Isolate* isolate, |
| 1135 Handle<FunctionTemplate> receiver) { | 1045 Handle<FunctionTemplate> receiver) { |
| 1136 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver)); | 1046 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver)); |
| 1137 } | 1047 } |
| 1138 | 1048 |
| 1139 | 1049 |
| 1140 // While this is just a cast, it's lame not to use an Isolate parameter. | |
| 1141 Local<AccessorSignature> AccessorSignature::New( | |
| 1142 Handle<FunctionTemplate> receiver) { | |
| 1143 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver)); | |
| 1144 } | |
| 1145 | |
| 1146 | |
| 1147 template<typename Operation> | 1050 template<typename Operation> |
| 1148 static Local<Operation> NewDescriptor( | 1051 static Local<Operation> NewDescriptor( |
| 1149 Isolate* isolate, | 1052 Isolate* isolate, |
| 1150 const i::DeclaredAccessorDescriptorData& data, | 1053 const i::DeclaredAccessorDescriptorData& data, |
| 1151 Data* previous_descriptor) { | 1054 Data* previous_descriptor) { |
| 1152 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); | 1055 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 1153 i::Handle<i::DeclaredAccessorDescriptor> previous = | 1056 i::Handle<i::DeclaredAccessorDescriptor> previous = |
| 1154 i::Handle<i::DeclaredAccessorDescriptor>(); | 1057 i::Handle<i::DeclaredAccessorDescriptor>(); |
| 1155 if (previous_descriptor != NULL) { | 1058 if (previous_descriptor != NULL) { |
| 1156 previous = Utils::OpenHandle( | 1059 previous = Utils::OpenHandle( |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1458 if (!constructor.IsEmpty()) | 1361 if (!constructor.IsEmpty()) |
| 1459 obj->set_constructor(*Utils::OpenHandle(*constructor)); | 1362 obj->set_constructor(*Utils::OpenHandle(*constructor)); |
| 1460 obj->set_internal_field_count(i::Smi::FromInt(0)); | 1363 obj->set_internal_field_count(i::Smi::FromInt(0)); |
| 1461 return Utils::ToLocal(obj); | 1364 return Utils::ToLocal(obj); |
| 1462 } | 1365 } |
| 1463 | 1366 |
| 1464 | 1367 |
| 1465 // Ensure that the object template has a constructor. If no | 1368 // Ensure that the object template has a constructor. If no |
| 1466 // constructor is available we create one. | 1369 // constructor is available we create one. |
| 1467 static i::Handle<i::FunctionTemplateInfo> EnsureConstructor( | 1370 static i::Handle<i::FunctionTemplateInfo> EnsureConstructor( |
| 1371 i::Isolate* isolate, |
| 1468 ObjectTemplate* object_template) { | 1372 ObjectTemplate* object_template) { |
| 1469 i::Object* obj = Utils::OpenHandle(object_template)->constructor(); | 1373 i::Object* obj = Utils::OpenHandle(object_template)->constructor(); |
| 1470 if (!obj ->IsUndefined()) { | 1374 if (!obj ->IsUndefined()) { |
| 1471 i::FunctionTemplateInfo* info = i::FunctionTemplateInfo::cast(obj); | 1375 i::FunctionTemplateInfo* info = i::FunctionTemplateInfo::cast(obj); |
| 1472 return i::Handle<i::FunctionTemplateInfo>(info, info->GetIsolate()); | 1376 return i::Handle<i::FunctionTemplateInfo>(info, isolate); |
| 1473 } | 1377 } |
| 1474 Local<FunctionTemplate> templ = FunctionTemplate::New(); | 1378 Local<FunctionTemplate> templ = |
| 1379 FunctionTemplate::New(reinterpret_cast<Isolate*>(isolate)); |
| 1475 i::Handle<i::FunctionTemplateInfo> constructor = Utils::OpenHandle(*templ); | 1380 i::Handle<i::FunctionTemplateInfo> constructor = Utils::OpenHandle(*templ); |
| 1476 constructor->set_instance_template(*Utils::OpenHandle(object_template)); | 1381 constructor->set_instance_template(*Utils::OpenHandle(object_template)); |
| 1477 Utils::OpenHandle(object_template)->set_constructor(*constructor); | 1382 Utils::OpenHandle(object_template)->set_constructor(*constructor); |
| 1478 return constructor; | 1383 return constructor; |
| 1479 } | 1384 } |
| 1480 | 1385 |
| 1481 | 1386 |
| 1482 static inline void AddPropertyToTemplate( | 1387 static inline void AddPropertyToTemplate( |
| 1483 i::Handle<i::TemplateInfo> info, | 1388 i::Handle<i::TemplateInfo> info, |
| 1484 i::Handle<i::AccessorInfo> obj) { | 1389 i::Handle<i::AccessorInfo> obj) { |
| 1485 i::Handle<i::Object> list(info->property_accessors(), info->GetIsolate()); | 1390 i::Handle<i::Object> list(info->property_accessors(), info->GetIsolate()); |
| 1486 if (list->IsUndefined()) { | 1391 if (list->IsUndefined()) { |
| 1487 list = NeanderArray().value(); | 1392 list = NeanderArray().value(); |
| 1488 info->set_property_accessors(*list); | 1393 info->set_property_accessors(*list); |
| 1489 } | 1394 } |
| 1490 NeanderArray array(list); | 1395 NeanderArray array(list); |
| 1491 array.add(obj); | 1396 array.add(obj); |
| 1492 } | 1397 } |
| 1493 | 1398 |
| 1494 | 1399 |
| 1495 static inline i::Handle<i::TemplateInfo> GetTemplateInfo( | 1400 static inline i::Handle<i::TemplateInfo> GetTemplateInfo( |
| 1401 i::Isolate* isolate, |
| 1496 Template* template_obj) { | 1402 Template* template_obj) { |
| 1497 return Utils::OpenHandle(template_obj); | 1403 return Utils::OpenHandle(template_obj); |
| 1498 } | 1404 } |
| 1499 | 1405 |
| 1500 | 1406 |
| 1501 // TODO(dcarney): remove this with ObjectTemplate::SetAccessor | 1407 // TODO(dcarney): remove this with ObjectTemplate::SetAccessor |
| 1502 static inline i::Handle<i::TemplateInfo> GetTemplateInfo( | 1408 static inline i::Handle<i::TemplateInfo> GetTemplateInfo( |
| 1409 i::Isolate* isolate, |
| 1503 ObjectTemplate* object_template) { | 1410 ObjectTemplate* object_template) { |
| 1504 EnsureConstructor(object_template); | 1411 EnsureConstructor(isolate, object_template); |
| 1505 return Utils::OpenHandle(object_template); | 1412 return Utils::OpenHandle(object_template); |
| 1506 } | 1413 } |
| 1507 | 1414 |
| 1508 | 1415 |
| 1509 template<typename Setter, typename Getter, typename Data, typename Template> | 1416 template<typename Setter, typename Getter, typename Data, typename Template> |
| 1510 static bool TemplateSetAccessor( | 1417 static bool TemplateSetAccessor( |
| 1511 Template* template_obj, | 1418 Template* template_obj, |
| 1512 v8::Local<String> name, | 1419 v8::Local<String> name, |
| 1513 Getter getter, | 1420 Getter getter, |
| 1514 Setter setter, | 1421 Setter setter, |
| 1515 Data data, | 1422 Data data, |
| 1516 AccessControl settings, | 1423 AccessControl settings, |
| 1517 PropertyAttribute attribute, | 1424 PropertyAttribute attribute, |
| 1518 v8::Local<AccessorSignature> signature) { | 1425 v8::Local<AccessorSignature> signature) { |
| 1519 i::Isolate* isolate = Utils::OpenHandle(template_obj)->GetIsolate(); | 1426 i::Isolate* isolate = Utils::OpenHandle(template_obj)->GetIsolate(); |
| 1520 ENTER_V8(isolate); | 1427 ENTER_V8(isolate); |
| 1521 i::HandleScope scope(isolate); | 1428 i::HandleScope scope(isolate); |
| 1522 i::Handle<i::AccessorInfo> obj = MakeAccessorInfo( | 1429 i::Handle<i::AccessorInfo> obj = MakeAccessorInfo( |
| 1523 name, getter, setter, data, settings, attribute, signature); | 1430 name, getter, setter, data, settings, attribute, signature); |
| 1524 if (obj.is_null()) return false; | 1431 if (obj.is_null()) return false; |
| 1525 i::Handle<i::TemplateInfo> info = GetTemplateInfo(template_obj); | 1432 i::Handle<i::TemplateInfo> info = GetTemplateInfo(isolate, template_obj); |
| 1526 AddPropertyToTemplate(info, obj); | 1433 AddPropertyToTemplate(info, obj); |
| 1527 return true; | 1434 return true; |
| 1528 } | 1435 } |
| 1529 | 1436 |
| 1530 | 1437 |
| 1531 bool Template::SetDeclaredAccessor( | 1438 bool Template::SetDeclaredAccessor( |
| 1532 Local<String> name, | 1439 Local<String> name, |
| 1533 Local<DeclaredAccessorDescriptor> descriptor, | 1440 Local<DeclaredAccessorDescriptor> descriptor, |
| 1534 PropertyAttribute attribute, | 1441 PropertyAttribute attribute, |
| 1535 Local<AccessorSignature> signature, | 1442 Local<AccessorSignature> signature, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1567 void ObjectTemplate::SetNamedPropertyHandler( | 1474 void ObjectTemplate::SetNamedPropertyHandler( |
| 1568 NamedPropertyGetterCallback getter, | 1475 NamedPropertyGetterCallback getter, |
| 1569 NamedPropertySetterCallback setter, | 1476 NamedPropertySetterCallback setter, |
| 1570 NamedPropertyQueryCallback query, | 1477 NamedPropertyQueryCallback query, |
| 1571 NamedPropertyDeleterCallback remover, | 1478 NamedPropertyDeleterCallback remover, |
| 1572 NamedPropertyEnumeratorCallback enumerator, | 1479 NamedPropertyEnumeratorCallback enumerator, |
| 1573 Handle<Value> data) { | 1480 Handle<Value> data) { |
| 1574 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1481 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 1575 ENTER_V8(isolate); | 1482 ENTER_V8(isolate); |
| 1576 i::HandleScope scope(isolate); | 1483 i::HandleScope scope(isolate); |
| 1577 EnsureConstructor(this); | 1484 EnsureConstructor(isolate, this); |
| 1578 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( | 1485 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( |
| 1579 Utils::OpenHandle(this)->constructor()); | 1486 Utils::OpenHandle(this)->constructor()); |
| 1580 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 1487 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
| 1581 i::Handle<i::Struct> struct_obj = | 1488 i::Handle<i::Struct> struct_obj = |
| 1582 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); | 1489 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); |
| 1583 i::Handle<i::InterceptorInfo> obj = | 1490 i::Handle<i::InterceptorInfo> obj = |
| 1584 i::Handle<i::InterceptorInfo>::cast(struct_obj); | 1491 i::Handle<i::InterceptorInfo>::cast(struct_obj); |
| 1585 | 1492 |
| 1586 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); | 1493 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); |
| 1587 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); | 1494 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); |
| 1588 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); | 1495 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); |
| 1589 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); | 1496 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); |
| 1590 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); | 1497 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); |
| 1591 | 1498 |
| 1592 if (data.IsEmpty()) { | 1499 if (data.IsEmpty()) { |
| 1593 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); | 1500 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); |
| 1594 } | 1501 } |
| 1595 obj->set_data(*Utils::OpenHandle(*data)); | 1502 obj->set_data(*Utils::OpenHandle(*data)); |
| 1596 cons->set_named_property_handler(*obj); | 1503 cons->set_named_property_handler(*obj); |
| 1597 } | 1504 } |
| 1598 | 1505 |
| 1599 | 1506 |
| 1600 void ObjectTemplate::MarkAsUndetectable() { | 1507 void ObjectTemplate::MarkAsUndetectable() { |
| 1601 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1508 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 1602 ENTER_V8(isolate); | 1509 ENTER_V8(isolate); |
| 1603 i::HandleScope scope(isolate); | 1510 i::HandleScope scope(isolate); |
| 1604 EnsureConstructor(this); | 1511 EnsureConstructor(isolate, this); |
| 1605 i::FunctionTemplateInfo* constructor = | 1512 i::FunctionTemplateInfo* constructor = |
| 1606 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); | 1513 i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); |
| 1607 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 1514 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
| 1608 cons->set_undetectable(true); | 1515 cons->set_undetectable(true); |
| 1609 } | 1516 } |
| 1610 | 1517 |
| 1611 | 1518 |
| 1612 void ObjectTemplate::SetAccessCheckCallbacks( | 1519 void ObjectTemplate::SetAccessCheckCallbacks( |
| 1613 NamedSecurityCallback named_callback, | 1520 NamedSecurityCallback named_callback, |
| 1614 IndexedSecurityCallback indexed_callback, | 1521 IndexedSecurityCallback indexed_callback, |
| 1615 Handle<Value> data, | 1522 Handle<Value> data, |
| 1616 bool turned_on_by_default) { | 1523 bool turned_on_by_default) { |
| 1617 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1524 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 1618 ENTER_V8(isolate); | 1525 ENTER_V8(isolate); |
| 1619 i::HandleScope scope(isolate); | 1526 i::HandleScope scope(isolate); |
| 1620 EnsureConstructor(this); | 1527 EnsureConstructor(isolate, this); |
| 1621 | 1528 |
| 1622 i::Handle<i::Struct> struct_info = | 1529 i::Handle<i::Struct> struct_info = |
| 1623 isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE); | 1530 isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE); |
| 1624 i::Handle<i::AccessCheckInfo> info = | 1531 i::Handle<i::AccessCheckInfo> info = |
| 1625 i::Handle<i::AccessCheckInfo>::cast(struct_info); | 1532 i::Handle<i::AccessCheckInfo>::cast(struct_info); |
| 1626 | 1533 |
| 1627 SET_FIELD_WRAPPED(info, set_named_callback, named_callback); | 1534 SET_FIELD_WRAPPED(info, set_named_callback, named_callback); |
| 1628 SET_FIELD_WRAPPED(info, set_indexed_callback, indexed_callback); | 1535 SET_FIELD_WRAPPED(info, set_indexed_callback, indexed_callback); |
| 1629 | 1536 |
| 1630 if (data.IsEmpty()) { | 1537 if (data.IsEmpty()) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1643 void ObjectTemplate::SetIndexedPropertyHandler( | 1550 void ObjectTemplate::SetIndexedPropertyHandler( |
| 1644 IndexedPropertyGetterCallback getter, | 1551 IndexedPropertyGetterCallback getter, |
| 1645 IndexedPropertySetterCallback setter, | 1552 IndexedPropertySetterCallback setter, |
| 1646 IndexedPropertyQueryCallback query, | 1553 IndexedPropertyQueryCallback query, |
| 1647 IndexedPropertyDeleterCallback remover, | 1554 IndexedPropertyDeleterCallback remover, |
| 1648 IndexedPropertyEnumeratorCallback enumerator, | 1555 IndexedPropertyEnumeratorCallback enumerator, |
| 1649 Handle<Value> data) { | 1556 Handle<Value> data) { |
| 1650 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1557 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 1651 ENTER_V8(isolate); | 1558 ENTER_V8(isolate); |
| 1652 i::HandleScope scope(isolate); | 1559 i::HandleScope scope(isolate); |
| 1653 EnsureConstructor(this); | 1560 EnsureConstructor(isolate, this); |
| 1654 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( | 1561 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( |
| 1655 Utils::OpenHandle(this)->constructor()); | 1562 Utils::OpenHandle(this)->constructor()); |
| 1656 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 1563 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
| 1657 i::Handle<i::Struct> struct_obj = | 1564 i::Handle<i::Struct> struct_obj = |
| 1658 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); | 1565 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE); |
| 1659 i::Handle<i::InterceptorInfo> obj = | 1566 i::Handle<i::InterceptorInfo> obj = |
| 1660 i::Handle<i::InterceptorInfo>::cast(struct_obj); | 1567 i::Handle<i::InterceptorInfo>::cast(struct_obj); |
| 1661 | 1568 |
| 1662 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); | 1569 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); |
| 1663 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); | 1570 if (setter != 0) SET_FIELD_WRAPPED(obj, set_setter, setter); |
| 1664 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); | 1571 if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); |
| 1665 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); | 1572 if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); |
| 1666 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); | 1573 if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); |
| 1667 | 1574 |
| 1668 if (data.IsEmpty()) { | 1575 if (data.IsEmpty()) { |
| 1669 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); | 1576 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); |
| 1670 } | 1577 } |
| 1671 obj->set_data(*Utils::OpenHandle(*data)); | 1578 obj->set_data(*Utils::OpenHandle(*data)); |
| 1672 cons->set_indexed_property_handler(*obj); | 1579 cons->set_indexed_property_handler(*obj); |
| 1673 } | 1580 } |
| 1674 | 1581 |
| 1675 | 1582 |
| 1676 void ObjectTemplate::SetCallAsFunctionHandler(FunctionCallback callback, | 1583 void ObjectTemplate::SetCallAsFunctionHandler(FunctionCallback callback, |
| 1677 Handle<Value> data) { | 1584 Handle<Value> data) { |
| 1678 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1585 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 1679 ENTER_V8(isolate); | 1586 ENTER_V8(isolate); |
| 1680 i::HandleScope scope(isolate); | 1587 i::HandleScope scope(isolate); |
| 1681 EnsureConstructor(this); | 1588 EnsureConstructor(isolate, this); |
| 1682 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( | 1589 i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast( |
| 1683 Utils::OpenHandle(this)->constructor()); | 1590 Utils::OpenHandle(this)->constructor()); |
| 1684 i::Handle<i::FunctionTemplateInfo> cons(constructor); | 1591 i::Handle<i::FunctionTemplateInfo> cons(constructor); |
| 1685 i::Handle<i::Struct> struct_obj = | 1592 i::Handle<i::Struct> struct_obj = |
| 1686 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); | 1593 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); |
| 1687 i::Handle<i::CallHandlerInfo> obj = | 1594 i::Handle<i::CallHandlerInfo> obj = |
| 1688 i::Handle<i::CallHandlerInfo>::cast(struct_obj); | 1595 i::Handle<i::CallHandlerInfo>::cast(struct_obj); |
| 1689 SET_FIELD_WRAPPED(obj, set_callback, callback); | 1596 SET_FIELD_WRAPPED(obj, set_callback, callback); |
| 1690 if (data.IsEmpty()) { | 1597 if (data.IsEmpty()) { |
| 1691 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); | 1598 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1705 if (!ApiCheck(i::Smi::IsValid(value), | 1612 if (!ApiCheck(i::Smi::IsValid(value), |
| 1706 "v8::ObjectTemplate::SetInternalFieldCount()", | 1613 "v8::ObjectTemplate::SetInternalFieldCount()", |
| 1707 "Invalid internal field count")) { | 1614 "Invalid internal field count")) { |
| 1708 return; | 1615 return; |
| 1709 } | 1616 } |
| 1710 ENTER_V8(isolate); | 1617 ENTER_V8(isolate); |
| 1711 if (value > 0) { | 1618 if (value > 0) { |
| 1712 // The internal field count is set by the constructor function's | 1619 // The internal field count is set by the constructor function's |
| 1713 // construct code, so we ensure that there is a constructor | 1620 // construct code, so we ensure that there is a constructor |
| 1714 // function to do the setting. | 1621 // function to do the setting. |
| 1715 EnsureConstructor(this); | 1622 EnsureConstructor(isolate, this); |
| 1716 } | 1623 } |
| 1717 Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value)); | 1624 Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value)); |
| 1718 } | 1625 } |
| 1719 | 1626 |
| 1720 | 1627 |
| 1721 // --- S c r i p t D a t a --- | 1628 // --- S c r i p t D a t a --- |
| 1722 | 1629 |
| 1723 | 1630 |
| 1724 ScriptData* ScriptData::PreCompile(v8::Isolate* isolate, | 1631 ScriptData* ScriptData::PreCompile(v8::Isolate* isolate, |
| 1725 const char* input, | 1632 const char* input, |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1806 i::ScriptDataImpl* pre_data_impl = | 1713 i::ScriptDataImpl* pre_data_impl = |
| 1807 static_cast<i::ScriptDataImpl*>(pre_data); | 1714 static_cast<i::ScriptDataImpl*>(pre_data); |
| 1808 // We assert that the pre-data is sane, even though we can actually | 1715 // We assert that the pre-data is sane, even though we can actually |
| 1809 // handle it if it turns out not to be in release mode. | 1716 // handle it if it turns out not to be in release mode. |
| 1810 ASSERT(pre_data_impl == NULL || pre_data_impl->SanityCheck()); | 1717 ASSERT(pre_data_impl == NULL || pre_data_impl->SanityCheck()); |
| 1811 // If the pre-data isn't sane we simply ignore it | 1718 // If the pre-data isn't sane we simply ignore it |
| 1812 if (pre_data_impl != NULL && !pre_data_impl->SanityCheck()) { | 1719 if (pre_data_impl != NULL && !pre_data_impl->SanityCheck()) { |
| 1813 pre_data_impl = NULL; | 1720 pre_data_impl = NULL; |
| 1814 } | 1721 } |
| 1815 i::Handle<i::SharedFunctionInfo> result = | 1722 i::Handle<i::SharedFunctionInfo> result = |
| 1816 i::Compiler::Compile(str, | 1723 i::Compiler::CompileScript(str, |
| 1817 name_obj, | 1724 name_obj, |
| 1818 line_offset, | 1725 line_offset, |
| 1819 column_offset, | 1726 column_offset, |
| 1820 is_shared_cross_origin, | 1727 is_shared_cross_origin, |
| 1821 isolate->global_context(), | 1728 isolate->global_context(), |
| 1822 NULL, | 1729 NULL, |
| 1823 pre_data_impl, | 1730 pre_data_impl, |
| 1824 Utils::OpenHandle(*script_data, true), | 1731 Utils::OpenHandle(*script_data, true), |
| 1825 i::NOT_NATIVES_CODE); | 1732 i::NOT_NATIVES_CODE); |
| 1826 has_pending_exception = result.is_null(); | 1733 has_pending_exception = result.is_null(); |
| 1827 EXCEPTION_BAILOUT_CHECK(isolate, Local<Script>()); | 1734 EXCEPTION_BAILOUT_CHECK(isolate, Local<Script>()); |
| 1828 raw_result = *result; | 1735 raw_result = *result; |
| 1829 } | 1736 } |
| 1830 i::Handle<i::SharedFunctionInfo> result(raw_result, isolate); | 1737 i::Handle<i::SharedFunctionInfo> result(raw_result, isolate); |
| 1831 return ToApiHandle<Script>(result); | 1738 return ToApiHandle<Script>(result); |
| 1832 } | 1739 } |
| 1833 | 1740 |
| 1834 | 1741 |
| 1835 Local<Script> Script::New(v8::Handle<String> source, | 1742 Local<Script> Script::New(v8::Handle<String> source, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1913 result = | 1820 result = |
| 1914 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj)); | 1821 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj)); |
| 1915 } else { | 1822 } else { |
| 1916 result = | 1823 result = |
| 1917 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared()); | 1824 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared()); |
| 1918 } | 1825 } |
| 1919 return result; | 1826 return result; |
| 1920 } | 1827 } |
| 1921 | 1828 |
| 1922 | 1829 |
| 1923 Local<Value> Script::Id() { | |
| 1924 i::Handle<i::HeapObject> obj = | |
| 1925 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this)); | |
| 1926 i::Isolate* isolate = obj->GetIsolate(); | |
| 1927 ON_BAILOUT(isolate, "v8::Script::Id()", return Local<Value>()); | |
| 1928 LOG_API(isolate, "Script::Id"); | |
| 1929 i::Object* raw_id = NULL; | |
| 1930 { | |
| 1931 i::HandleScope scope(isolate); | |
| 1932 i::Handle<i::SharedFunctionInfo> function_info = OpenScript(this); | |
| 1933 i::Handle<i::Script> script(i::Script::cast(function_info->script())); | |
| 1934 i::Handle<i::Object> id(script->id(), isolate); | |
| 1935 raw_id = *id; | |
| 1936 } | |
| 1937 i::Handle<i::Object> id(raw_id, isolate); | |
| 1938 return Utils::ToLocal(id); | |
| 1939 } | |
| 1940 | |
| 1941 | |
| 1942 int Script::GetId() { | 1830 int Script::GetId() { |
| 1943 i::Handle<i::HeapObject> obj = | 1831 i::Handle<i::HeapObject> obj = |
| 1944 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this)); | 1832 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this)); |
| 1945 i::Isolate* isolate = obj->GetIsolate(); | 1833 i::Isolate* isolate = obj->GetIsolate(); |
| 1946 ON_BAILOUT(isolate, "v8::Script::Id()", return -1); | 1834 ON_BAILOUT(isolate, "v8::Script::Id()", return -1); |
| 1947 LOG_API(isolate, "Script::Id"); | 1835 LOG_API(isolate, "Script::Id"); |
| 1948 { | 1836 { |
| 1949 i::HandleScope scope(isolate); | 1837 i::HandleScope scope(isolate); |
| 1950 i::Handle<i::SharedFunctionInfo> function_info = OpenScript(this); | 1838 i::Handle<i::SharedFunctionInfo> function_info = OpenScript(this); |
| 1951 i::Handle<i::Script> script(i::Script::cast(function_info->script())); | 1839 i::Handle<i::Script> script(i::Script::cast(function_info->script())); |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2314 } | 2202 } |
| 2315 | 2203 |
| 2316 | 2204 |
| 2317 void Message::PrintCurrentStackTrace(Isolate* isolate, FILE* out) { | 2205 void Message::PrintCurrentStackTrace(Isolate* isolate, FILE* out) { |
| 2318 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 2206 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 2319 ENTER_V8(i_isolate); | 2207 ENTER_V8(i_isolate); |
| 2320 i_isolate->PrintCurrentStackTrace(out); | 2208 i_isolate->PrintCurrentStackTrace(out); |
| 2321 } | 2209 } |
| 2322 | 2210 |
| 2323 | 2211 |
| 2324 void Message::PrintCurrentStackTrace(FILE* out) { | |
| 2325 PrintCurrentStackTrace(Isolate::GetCurrent(), out); | |
| 2326 } | |
| 2327 | |
| 2328 | |
| 2329 // --- S t a c k T r a c e --- | 2212 // --- S t a c k T r a c e --- |
| 2330 | 2213 |
| 2331 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const { | 2214 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const { |
| 2332 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2215 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 2333 ENTER_V8(isolate); | 2216 ENTER_V8(isolate); |
| 2334 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 2217 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
| 2335 i::Handle<i::JSArray> self = Utils::OpenHandle(this); | 2218 i::Handle<i::JSArray> self = Utils::OpenHandle(this); |
| 2336 i::Object* raw_object = self->GetElementNoExceptionThrown(isolate, index); | 2219 i::Object* raw_object = self->GetElementNoExceptionThrown(isolate, index); |
| 2337 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_object)); | 2220 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_object)); |
| 2338 return scope.Escape(Utils::StackFrameToLocal(obj)); | 2221 return scope.Escape(Utils::StackFrameToLocal(obj)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2358 int frame_limit, | 2241 int frame_limit, |
| 2359 StackTraceOptions options) { | 2242 StackTraceOptions options) { |
| 2360 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 2243 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 2361 ENTER_V8(i_isolate); | 2244 ENTER_V8(i_isolate); |
| 2362 i::Handle<i::JSArray> stackTrace = | 2245 i::Handle<i::JSArray> stackTrace = |
| 2363 i_isolate->CaptureCurrentStackTrace(frame_limit, options); | 2246 i_isolate->CaptureCurrentStackTrace(frame_limit, options); |
| 2364 return Utils::StackTraceToLocal(stackTrace); | 2247 return Utils::StackTraceToLocal(stackTrace); |
| 2365 } | 2248 } |
| 2366 | 2249 |
| 2367 | 2250 |
| 2368 Local<StackTrace> StackTrace::CurrentStackTrace(int frame_limit, | |
| 2369 StackTraceOptions options) { | |
| 2370 return CurrentStackTrace(Isolate::GetCurrent(), frame_limit, options); | |
| 2371 } | |
| 2372 | |
| 2373 | |
| 2374 // --- S t a c k F r a m e --- | 2251 // --- S t a c k F r a m e --- |
| 2375 | 2252 |
| 2376 int StackFrame::GetLineNumber() const { | 2253 int StackFrame::GetLineNumber() const { |
| 2377 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2254 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 2378 ENTER_V8(isolate); | 2255 ENTER_V8(isolate); |
| 2379 i::HandleScope scope(isolate); | 2256 i::HandleScope scope(isolate); |
| 2380 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2257 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| 2381 i::Handle<i::Object> line = GetProperty(self, "lineNumber"); | 2258 i::Handle<i::Object> line = GetProperty(self, "lineNumber"); |
| 2382 if (!line->IsSmi()) { | 2259 if (!line->IsSmi()) { |
| 2383 return Message::kNoLineNumberInfo; | 2260 return Message::kNoLineNumberInfo; |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2603 | 2480 |
| 2604 bool Value::IsExternal() const { | 2481 bool Value::IsExternal() const { |
| 2605 return Utils::OpenHandle(this)->IsExternal(); | 2482 return Utils::OpenHandle(this)->IsExternal(); |
| 2606 } | 2483 } |
| 2607 | 2484 |
| 2608 | 2485 |
| 2609 bool Value::IsInt32() const { | 2486 bool Value::IsInt32() const { |
| 2610 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2487 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 2611 if (obj->IsSmi()) return true; | 2488 if (obj->IsSmi()) return true; |
| 2612 if (obj->IsNumber()) { | 2489 if (obj->IsNumber()) { |
| 2613 double value = obj->Number(); | 2490 return i::IsInt32Double(obj->Number()); |
| 2614 static const i::DoubleRepresentation minus_zero(-0.0); | |
| 2615 i::DoubleRepresentation rep(value); | |
| 2616 if (rep.bits == minus_zero.bits) { | |
| 2617 return false; | |
| 2618 } | |
| 2619 return i::FastI2D(i::FastD2I(value)) == value; | |
| 2620 } | 2491 } |
| 2621 return false; | 2492 return false; |
| 2622 } | 2493 } |
| 2623 | 2494 |
| 2624 | 2495 |
| 2625 bool Value::IsUint32() const { | 2496 bool Value::IsUint32() const { |
| 2626 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2497 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 2627 if (obj->IsSmi()) return i::Smi::cast(*obj)->value() >= 0; | 2498 if (obj->IsSmi()) return i::Smi::cast(*obj)->value() >= 0; |
| 2628 if (obj->IsNumber()) { | 2499 if (obj->IsNumber()) { |
| 2629 double value = obj->Number(); | 2500 double value = obj->Number(); |
| 2630 static const i::DoubleRepresentation minus_zero(-0.0); | 2501 return !i::IsMinusZero(value) && |
| 2631 i::DoubleRepresentation rep(value); | 2502 value >= 0 && |
| 2632 if (rep.bits == minus_zero.bits) { | 2503 value <= i::kMaxUInt32 && |
| 2633 return false; | 2504 value == i::FastUI2D(i::FastD2UI(value)); |
| 2634 } | |
| 2635 return i::FastUI2D(i::FastD2UI(value)) == value; | |
| 2636 } | 2505 } |
| 2637 return false; | 2506 return false; |
| 2638 } | 2507 } |
| 2639 | 2508 |
| 2640 | 2509 |
| 2641 bool Value::IsDate() const { | 2510 bool Value::IsDate() const { |
| 2642 i::Isolate* isolate = i::Isolate::Current(); | 2511 i::Isolate* isolate = i::Isolate::Current(); |
| 2643 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2512 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 2644 return obj->HasSpecificClassOf(isolate->heap()->Date_string()); | 2513 return obj->HasSpecificClassOf(isolate->heap()->Date_string()); |
| 2645 } | 2514 } |
| (...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4279 return kLineOffsetNotFound; | 4148 return kLineOffsetNotFound; |
| 4280 } | 4149 } |
| 4281 | 4150 |
| 4282 | 4151 |
| 4283 bool Function::IsBuiltin() const { | 4152 bool Function::IsBuiltin() const { |
| 4284 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | 4153 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
| 4285 return func->IsBuiltin(); | 4154 return func->IsBuiltin(); |
| 4286 } | 4155 } |
| 4287 | 4156 |
| 4288 | 4157 |
| 4289 Handle<Value> Function::GetScriptId() const { | |
| 4290 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | |
| 4291 i::Isolate* isolate = func->GetIsolate(); | |
| 4292 if (!func->shared()->script()->IsScript()) { | |
| 4293 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); | |
| 4294 } | |
| 4295 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); | |
| 4296 return Utils::ToLocal(i::Handle<i::Object>(script->id(), isolate)); | |
| 4297 } | |
| 4298 | |
| 4299 | |
| 4300 int Function::ScriptId() const { | 4158 int Function::ScriptId() const { |
| 4301 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | 4159 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
| 4302 if (!func->shared()->script()->IsScript()) return v8::Script::kNoScriptId; | 4160 if (!func->shared()->script()->IsScript()) return v8::Script::kNoScriptId; |
| 4303 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); | 4161 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); |
| 4304 return script->id()->value(); | 4162 return script->id()->value(); |
| 4305 } | 4163 } |
| 4306 | 4164 |
| 4307 | 4165 |
| 4166 Local<v8::Value> Function::GetBoundFunction() const { |
| 4167 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
| 4168 if (!func->shared()->bound()) { |
| 4169 return v8::Undefined(reinterpret_cast<v8::Isolate*>(func->GetIsolate())); |
| 4170 } |
| 4171 i::Handle<i::FixedArray> bound_args = i::Handle<i::FixedArray>( |
| 4172 i::FixedArray::cast(func->function_bindings())); |
| 4173 i::Handle<i::Object> original( |
| 4174 bound_args->get(i::JSFunction::kBoundFunctionIndex), |
| 4175 func->GetIsolate()); |
| 4176 return Utils::ToLocal(i::Handle<i::JSFunction>::cast(original)); |
| 4177 } |
| 4178 |
| 4179 |
| 4308 int String::Length() const { | 4180 int String::Length() const { |
| 4309 i::Handle<i::String> str = Utils::OpenHandle(this); | 4181 i::Handle<i::String> str = Utils::OpenHandle(this); |
| 4310 return str->length(); | 4182 return str->length(); |
| 4311 } | 4183 } |
| 4312 | 4184 |
| 4313 | 4185 |
| 4314 bool String::IsOneByte() const { | 4186 bool String::IsOneByte() const { |
| 4315 i::Handle<i::String> str = Utils::OpenHandle(this); | 4187 i::Handle<i::String> str = Utils::OpenHandle(this); |
| 4316 return str->HasOnlyOneByteChars(); | 4188 return str->HasOnlyOneByteChars(); |
| 4317 } | 4189 } |
| (...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5271 | 5143 |
| 5272 // Enter V8 via an ENTER_V8 scope. | 5144 // Enter V8 via an ENTER_V8 scope. |
| 5273 { | 5145 { |
| 5274 ENTER_V8(isolate); | 5146 ENTER_V8(isolate); |
| 5275 v8::Handle<ObjectTemplate> proxy_template = global_template; | 5147 v8::Handle<ObjectTemplate> proxy_template = global_template; |
| 5276 i::Handle<i::FunctionTemplateInfo> proxy_constructor; | 5148 i::Handle<i::FunctionTemplateInfo> proxy_constructor; |
| 5277 i::Handle<i::FunctionTemplateInfo> global_constructor; | 5149 i::Handle<i::FunctionTemplateInfo> global_constructor; |
| 5278 | 5150 |
| 5279 if (!global_template.IsEmpty()) { | 5151 if (!global_template.IsEmpty()) { |
| 5280 // Make sure that the global_template has a constructor. | 5152 // Make sure that the global_template has a constructor. |
| 5281 global_constructor = EnsureConstructor(*global_template); | 5153 global_constructor = EnsureConstructor(isolate, *global_template); |
| 5282 | 5154 |
| 5283 // Create a fresh template for the global proxy object. | 5155 // Create a fresh template for the global proxy object. |
| 5284 proxy_template = ObjectTemplate::New(); | 5156 proxy_template = ObjectTemplate::New(); |
| 5285 proxy_constructor = EnsureConstructor(*proxy_template); | 5157 proxy_constructor = EnsureConstructor(isolate, *proxy_template); |
| 5286 | 5158 |
| 5287 // Set the global template to be the prototype template of | 5159 // Set the global template to be the prototype template of |
| 5288 // global proxy template. | 5160 // global proxy template. |
| 5289 proxy_constructor->set_prototype_template( | 5161 proxy_constructor->set_prototype_template( |
| 5290 *Utils::OpenHandle(*global_template)); | 5162 *Utils::OpenHandle(*global_template)); |
| 5291 | 5163 |
| 5292 // Migrate security handlers from global_template to | 5164 // Migrate security handlers from global_template to |
| 5293 // proxy_template. Temporarily removing access check | 5165 // proxy_template. Temporarily removing access check |
| 5294 // information from the global template. | 5166 // information from the global template. |
| 5295 if (!global_constructor->access_check_info()->IsUndefined()) { | 5167 if (!global_constructor->access_check_info()->IsUndefined()) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 5311 | 5183 |
| 5312 // Restore the access check info on the global template. | 5184 // Restore the access check info on the global template. |
| 5313 if (!global_template.IsEmpty()) { | 5185 if (!global_template.IsEmpty()) { |
| 5314 ASSERT(!global_constructor.is_null()); | 5186 ASSERT(!global_constructor.is_null()); |
| 5315 ASSERT(!proxy_constructor.is_null()); | 5187 ASSERT(!proxy_constructor.is_null()); |
| 5316 global_constructor->set_access_check_info( | 5188 global_constructor->set_access_check_info( |
| 5317 proxy_constructor->access_check_info()); | 5189 proxy_constructor->access_check_info()); |
| 5318 global_constructor->set_needs_access_check( | 5190 global_constructor->set_needs_access_check( |
| 5319 proxy_constructor->needs_access_check()); | 5191 proxy_constructor->needs_access_check()); |
| 5320 } | 5192 } |
| 5321 isolate->runtime_profiler()->Reset(); | |
| 5322 } | 5193 } |
| 5323 // Leave V8. | 5194 // Leave V8. |
| 5324 | 5195 |
| 5325 return env; | 5196 return env; |
| 5326 } | 5197 } |
| 5327 | 5198 |
| 5328 Local<Context> v8::Context::New( | 5199 Local<Context> v8::Context::New( |
| 5329 v8::Isolate* external_isolate, | 5200 v8::Isolate* external_isolate, |
| 5330 v8::ExtensionConfiguration* extensions, | 5201 v8::ExtensionConfiguration* extensions, |
| 5331 v8::Handle<ObjectTemplate> global_template, | 5202 v8::Handle<ObjectTemplate> global_template, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5367 return Utils::ToLocal(token_handle); | 5238 return Utils::ToLocal(token_handle); |
| 5368 } | 5239 } |
| 5369 | 5240 |
| 5370 | 5241 |
| 5371 bool Context::HasOutOfMemoryException() { | 5242 bool Context::HasOutOfMemoryException() { |
| 5372 i::Handle<i::Context> env = Utils::OpenHandle(this); | 5243 i::Handle<i::Context> env = Utils::OpenHandle(this); |
| 5373 return env->has_out_of_memory(); | 5244 return env->has_out_of_memory(); |
| 5374 } | 5245 } |
| 5375 | 5246 |
| 5376 | 5247 |
| 5377 bool Context::InContext() { | |
| 5378 return i::Isolate::Current()->context() != NULL; | |
| 5379 } | |
| 5380 | |
| 5381 | |
| 5382 v8::Isolate* Context::GetIsolate() { | 5248 v8::Isolate* Context::GetIsolate() { |
| 5383 i::Handle<i::Context> env = Utils::OpenHandle(this); | 5249 i::Handle<i::Context> env = Utils::OpenHandle(this); |
| 5384 return reinterpret_cast<Isolate*>(env->GetIsolate()); | 5250 return reinterpret_cast<Isolate*>(env->GetIsolate()); |
| 5385 } | 5251 } |
| 5386 | 5252 |
| 5387 | 5253 |
| 5388 v8::Local<v8::Context> Context::GetEntered() { | |
| 5389 i::Isolate* isolate = i::Isolate::Current(); | |
| 5390 if (!EnsureInitializedForIsolate(isolate, "v8::Context::GetEntered()")) { | |
| 5391 return Local<Context>(); | |
| 5392 } | |
| 5393 return reinterpret_cast<Isolate*>(isolate)->GetEnteredContext(); | |
| 5394 } | |
| 5395 | |
| 5396 | |
| 5397 v8::Local<v8::Context> Context::GetCurrent() { | |
| 5398 i::Isolate* isolate = i::Isolate::Current(); | |
| 5399 return reinterpret_cast<Isolate*>(isolate)->GetCurrentContext(); | |
| 5400 } | |
| 5401 | |
| 5402 | |
| 5403 v8::Local<v8::Context> Context::GetCalling() { | |
| 5404 i::Isolate* isolate = i::Isolate::Current(); | |
| 5405 return reinterpret_cast<Isolate*>(isolate)->GetCallingContext(); | |
| 5406 } | |
| 5407 | |
| 5408 | |
| 5409 v8::Local<v8::Object> Context::Global() { | 5254 v8::Local<v8::Object> Context::Global() { |
| 5410 i::Handle<i::Context> context = Utils::OpenHandle(this); | 5255 i::Handle<i::Context> context = Utils::OpenHandle(this); |
| 5411 i::Isolate* isolate = context->GetIsolate(); | 5256 i::Isolate* isolate = context->GetIsolate(); |
| 5412 i::Handle<i::Object> global(context->global_proxy(), isolate); | 5257 i::Handle<i::Object> global(context->global_proxy(), isolate); |
| 5258 // TODO(dcarney): This should always return the global proxy |
| 5259 // but can't presently as calls to GetProtoype will return the wrong result. |
| 5260 if (i::Handle<i::JSGlobalProxy>::cast( |
| 5261 global)->IsDetachedFrom(context->global_object())) { |
| 5262 global = i::Handle<i::Object>(context->global_object(), isolate); |
| 5263 } |
| 5413 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global)); | 5264 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global)); |
| 5414 } | 5265 } |
| 5415 | 5266 |
| 5416 | 5267 |
| 5417 void Context::DetachGlobal() { | 5268 void Context::DetachGlobal() { |
| 5418 i::Handle<i::Context> context = Utils::OpenHandle(this); | 5269 i::Handle<i::Context> context = Utils::OpenHandle(this); |
| 5419 i::Isolate* isolate = context->GetIsolate(); | 5270 i::Isolate* isolate = context->GetIsolate(); |
| 5420 ENTER_V8(isolate); | 5271 ENTER_V8(isolate); |
| 5421 isolate->bootstrapper()->DetachGlobal(context); | 5272 isolate->bootstrapper()->DetachGlobal(context); |
| 5422 } | 5273 } |
| 5423 | 5274 |
| 5424 | 5275 |
| 5425 void Context::ReattachGlobal(Handle<Object> global_object) { | |
| 5426 i::Handle<i::Context> context = Utils::OpenHandle(this); | |
| 5427 i::Isolate* isolate = context->GetIsolate(); | |
| 5428 ENTER_V8(isolate); | |
| 5429 i::Handle<i::JSGlobalProxy> global_proxy = | |
| 5430 i::Handle<i::JSGlobalProxy>::cast(Utils::OpenHandle(*global_object)); | |
| 5431 isolate->bootstrapper()->ReattachGlobal(context, global_proxy); | |
| 5432 } | |
| 5433 | |
| 5434 | |
| 5435 void Context::AllowCodeGenerationFromStrings(bool allow) { | 5276 void Context::AllowCodeGenerationFromStrings(bool allow) { |
| 5436 i::Handle<i::Context> context = Utils::OpenHandle(this); | 5277 i::Handle<i::Context> context = Utils::OpenHandle(this); |
| 5437 i::Isolate* isolate = context->GetIsolate(); | 5278 i::Isolate* isolate = context->GetIsolate(); |
| 5438 ENTER_V8(isolate); | 5279 ENTER_V8(isolate); |
| 5439 context->set_allow_code_gen_from_strings( | 5280 context->set_allow_code_gen_from_strings( |
| 5440 allow ? isolate->heap()->true_value() : isolate->heap()->false_value()); | 5281 allow ? isolate->heap()->true_value() : isolate->heap()->false_value()); |
| 5441 } | 5282 } |
| 5442 | 5283 |
| 5443 | 5284 |
| 5444 bool Context::IsCodeGenerationFromStringsAllowed() { | 5285 bool Context::IsCodeGenerationFromStringsAllowed() { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5497 STATIC_ASSERT(sizeof(value) == sizeof(i::Address)); | 5338 STATIC_ASSERT(sizeof(value) == sizeof(i::Address)); |
| 5498 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 5339 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 5499 EnsureInitializedForIsolate(i_isolate, "v8::External::New()"); | 5340 EnsureInitializedForIsolate(i_isolate, "v8::External::New()"); |
| 5500 LOG_API(i_isolate, "External::New"); | 5341 LOG_API(i_isolate, "External::New"); |
| 5501 ENTER_V8(i_isolate); | 5342 ENTER_V8(i_isolate); |
| 5502 i::Handle<i::JSObject> external = i_isolate->factory()->NewExternal(value); | 5343 i::Handle<i::JSObject> external = i_isolate->factory()->NewExternal(value); |
| 5503 return Utils::ExternalToLocal(external); | 5344 return Utils::ExternalToLocal(external); |
| 5504 } | 5345 } |
| 5505 | 5346 |
| 5506 | 5347 |
| 5507 Local<External> v8::External::New(void* value) { | |
| 5508 return v8::External::New(Isolate::GetCurrent(), value); | |
| 5509 } | |
| 5510 | |
| 5511 | |
| 5512 void* External::Value() const { | 5348 void* External::Value() const { |
| 5513 return ExternalValue(*Utils::OpenHandle(this)); | 5349 return ExternalValue(*Utils::OpenHandle(this)); |
| 5514 } | 5350 } |
| 5515 | 5351 |
| 5516 | 5352 |
| 5517 Local<String> v8::String::Empty() { | 5353 Local<String> v8::String::Empty() { |
| 5518 i::Isolate* isolate = i::Isolate::Current(); | 5354 i::Isolate* isolate = i::Isolate::Current(); |
| 5519 if (!EnsureInitializedForIsolate(isolate, "v8::String::Empty()")) { | 5355 if (!EnsureInitializedForIsolate(isolate, "v8::String::Empty()")) { |
| 5520 return v8::Local<String>(); | 5356 return v8::Local<String>(); |
| 5521 } | 5357 } |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5693 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()"); | 5529 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()"); |
| 5694 LOG_API(i_isolate, "String::NewExternal"); | 5530 LOG_API(i_isolate, "String::NewExternal"); |
| 5695 ENTER_V8(i_isolate); | 5531 ENTER_V8(i_isolate); |
| 5696 CHECK(resource && resource->data()); | 5532 CHECK(resource && resource->data()); |
| 5697 i::Handle<i::String> result = NewExternalStringHandle(i_isolate, resource); | 5533 i::Handle<i::String> result = NewExternalStringHandle(i_isolate, resource); |
| 5698 i_isolate->heap()->external_string_table()->AddString(*result); | 5534 i_isolate->heap()->external_string_table()->AddString(*result); |
| 5699 return Utils::ToLocal(result); | 5535 return Utils::ToLocal(result); |
| 5700 } | 5536 } |
| 5701 | 5537 |
| 5702 | 5538 |
| 5703 Local<String> v8::String::NewExternal( | |
| 5704 v8::String::ExternalStringResource* resource) { | |
| 5705 return NewExternal(Isolate::GetCurrent(), resource); | |
| 5706 } | |
| 5707 | |
| 5708 | |
| 5709 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { | 5539 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { |
| 5710 i::Handle<i::String> obj = Utils::OpenHandle(this); | 5540 i::Handle<i::String> obj = Utils::OpenHandle(this); |
| 5711 i::Isolate* isolate = obj->GetIsolate(); | 5541 i::Isolate* isolate = obj->GetIsolate(); |
| 5712 if (i::StringShape(*obj).IsExternalTwoByte()) { | 5542 if (i::StringShape(*obj).IsExternalTwoByte()) { |
| 5713 return false; // Already an external string. | 5543 return false; // Already an external string. |
| 5714 } | 5544 } |
| 5715 ENTER_V8(isolate); | 5545 ENTER_V8(isolate); |
| 5716 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { | 5546 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { |
| 5717 return false; | 5547 return false; |
| 5718 } | 5548 } |
| 5719 if (isolate->heap()->IsInGCPostProcessing()) { | 5549 if (isolate->heap()->IsInGCPostProcessing()) { |
| 5720 return false; | 5550 return false; |
| 5721 } | 5551 } |
| 5722 CHECK(resource && resource->data()); | 5552 CHECK(resource && resource->data()); |
| 5723 | 5553 |
| 5724 bool result; | 5554 bool result; |
| 5725 i::Handle<i::String> external; | 5555 i::Handle<i::String> external; |
| 5726 if (isolate->heap()->old_pointer_space()->Contains(*obj)) { | 5556 if (isolate->heap()->old_pointer_space()->Contains(*obj)) { |
| 5727 // We do not allow external strings in the old pointer space. Instead of | 5557 // We do not allow external strings in the old pointer space. Instead of |
| 5728 // converting the string in-place, we keep the cons/sliced string and | 5558 // converting the string in-place, we keep the cons/sliced string and |
| 5729 // point it to a newly-allocated external string. | 5559 // point it to a newly-allocated external string. |
| 5730 external = NewExternalStringHandle(isolate, resource); | 5560 external = NewExternalStringHandle(isolate, resource); |
| 5731 result = RedirectToExternalString(isolate, obj, external); | 5561 result = RedirectToExternalString(isolate, obj, external); |
| 5732 } else { | 5562 } else { |
| 5733 result = obj->MakeExternal(resource); | 5563 result = obj->MakeExternal(resource); |
| 5734 external = obj; | 5564 external = obj; |
| 5735 } | 5565 } |
| 5736 | 5566 |
| 5737 ASSERT(external->IsExternalString()); | 5567 if (result) { |
| 5738 if (result && !external->IsInternalizedString()) { | 5568 ASSERT(external->IsExternalString()); |
| 5739 isolate->heap()->external_string_table()->AddString(*external); | 5569 isolate->heap()->external_string_table()->AddString(*external); |
| 5740 } | 5570 } |
| 5741 return result; | 5571 return result; |
| 5742 } | 5572 } |
| 5743 | 5573 |
| 5744 | 5574 |
| 5745 Local<String> v8::String::NewExternal( | 5575 Local<String> v8::String::NewExternal( |
| 5746 Isolate* isolate, | 5576 Isolate* isolate, |
| 5747 v8::String::ExternalAsciiStringResource* resource) { | 5577 v8::String::ExternalAsciiStringResource* resource) { |
| 5748 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 5578 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 5749 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()"); | 5579 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()"); |
| 5750 LOG_API(i_isolate, "String::NewExternal"); | 5580 LOG_API(i_isolate, "String::NewExternal"); |
| 5751 ENTER_V8(i_isolate); | 5581 ENTER_V8(i_isolate); |
| 5752 CHECK(resource && resource->data()); | 5582 CHECK(resource && resource->data()); |
| 5753 i::Handle<i::String> result = | 5583 i::Handle<i::String> result = |
| 5754 NewExternalAsciiStringHandle(i_isolate, resource); | 5584 NewExternalAsciiStringHandle(i_isolate, resource); |
| 5755 i_isolate->heap()->external_string_table()->AddString(*result); | 5585 i_isolate->heap()->external_string_table()->AddString(*result); |
| 5756 return Utils::ToLocal(result); | 5586 return Utils::ToLocal(result); |
| 5757 } | 5587 } |
| 5758 | 5588 |
| 5759 | 5589 |
| 5760 Local<String> v8::String::NewExternal( | |
| 5761 v8::String::ExternalAsciiStringResource* resource) { | |
| 5762 return NewExternal(Isolate::GetCurrent(), resource); | |
| 5763 } | |
| 5764 | |
| 5765 | |
| 5766 bool v8::String::MakeExternal( | 5590 bool v8::String::MakeExternal( |
| 5767 v8::String::ExternalAsciiStringResource* resource) { | 5591 v8::String::ExternalAsciiStringResource* resource) { |
| 5768 i::Handle<i::String> obj = Utils::OpenHandle(this); | 5592 i::Handle<i::String> obj = Utils::OpenHandle(this); |
| 5769 i::Isolate* isolate = obj->GetIsolate(); | 5593 i::Isolate* isolate = obj->GetIsolate(); |
| 5770 if (i::StringShape(*obj).IsExternalTwoByte()) { | 5594 if (i::StringShape(*obj).IsExternalTwoByte()) { |
| 5771 return false; // Already an external string. | 5595 return false; // Already an external string. |
| 5772 } | 5596 } |
| 5773 ENTER_V8(isolate); | 5597 ENTER_V8(isolate); |
| 5774 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { | 5598 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { |
| 5775 return false; | 5599 return false; |
| 5776 } | 5600 } |
| 5777 if (isolate->heap()->IsInGCPostProcessing()) { | 5601 if (isolate->heap()->IsInGCPostProcessing()) { |
| 5778 return false; | 5602 return false; |
| 5779 } | 5603 } |
| 5780 CHECK(resource && resource->data()); | 5604 CHECK(resource && resource->data()); |
| 5781 | 5605 |
| 5782 bool result; | 5606 bool result; |
| 5783 i::Handle<i::String> external; | 5607 i::Handle<i::String> external; |
| 5784 if (isolate->heap()->old_pointer_space()->Contains(*obj)) { | 5608 if (isolate->heap()->old_pointer_space()->Contains(*obj)) { |
| 5785 // We do not allow external strings in the old pointer space. Instead of | 5609 // We do not allow external strings in the old pointer space. Instead of |
| 5786 // converting the string in-place, we keep the cons/sliced string and | 5610 // converting the string in-place, we keep the cons/sliced string and |
| 5787 // point it to a newly-allocated external string. | 5611 // point it to a newly-allocated external string. |
| 5788 external = NewExternalAsciiStringHandle(isolate, resource); | 5612 external = NewExternalAsciiStringHandle(isolate, resource); |
| 5789 result = RedirectToExternalString(isolate, obj, external); | 5613 result = RedirectToExternalString(isolate, obj, external); |
| 5790 } else { | 5614 } else { |
| 5791 result = obj->MakeExternal(resource); | 5615 result = obj->MakeExternal(resource); |
| 5792 external = obj; | 5616 external = obj; |
| 5793 } | 5617 } |
| 5794 | 5618 |
| 5795 ASSERT(external->IsExternalString()); | 5619 if (result) { |
| 5796 if (result && !external->IsInternalizedString()) { | 5620 ASSERT(external->IsExternalString()); |
| 5797 isolate->heap()->external_string_table()->AddString(*external); | 5621 isolate->heap()->external_string_table()->AddString(*external); |
| 5798 } | 5622 } |
| 5799 return result; | 5623 return result; |
| 5800 } | 5624 } |
| 5801 | 5625 |
| 5802 | 5626 |
| 5803 bool v8::String::CanMakeExternal() { | 5627 bool v8::String::CanMakeExternal() { |
| 5804 if (!internal::FLAG_clever_optimizations) return false; | 5628 if (!internal::FLAG_clever_optimizations) return false; |
| 5805 i::Handle<i::String> obj = Utils::OpenHandle(this); | 5629 i::Handle<i::String> obj = Utils::OpenHandle(this); |
| 5806 i::Isolate* isolate = obj->GetIsolate(); | 5630 i::Isolate* isolate = obj->GetIsolate(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5838 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 5662 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 5839 EnsureInitializedForIsolate(i_isolate, "v8::NumberObject::New()"); | 5663 EnsureInitializedForIsolate(i_isolate, "v8::NumberObject::New()"); |
| 5840 LOG_API(i_isolate, "NumberObject::New"); | 5664 LOG_API(i_isolate, "NumberObject::New"); |
| 5841 ENTER_V8(i_isolate); | 5665 ENTER_V8(i_isolate); |
| 5842 i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value); | 5666 i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value); |
| 5843 i::Handle<i::Object> obj = i_isolate->factory()->ToObject(number); | 5667 i::Handle<i::Object> obj = i_isolate->factory()->ToObject(number); |
| 5844 return Utils::ToLocal(obj); | 5668 return Utils::ToLocal(obj); |
| 5845 } | 5669 } |
| 5846 | 5670 |
| 5847 | 5671 |
| 5848 Local<v8::Value> v8::NumberObject::New(double value) { | |
| 5849 return New(Isolate::GetCurrent(), value); | |
| 5850 } | |
| 5851 | |
| 5852 | |
| 5853 double v8::NumberObject::ValueOf() const { | 5672 double v8::NumberObject::ValueOf() const { |
| 5854 i::Isolate* isolate = i::Isolate::Current(); | 5673 i::Isolate* isolate = i::Isolate::Current(); |
| 5855 LOG_API(isolate, "NumberObject::NumberValue"); | 5674 LOG_API(isolate, "NumberObject::NumberValue"); |
| 5856 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 5675 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 5857 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 5676 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
| 5858 return jsvalue->value()->Number(); | 5677 return jsvalue->value()->Number(); |
| 5859 } | 5678 } |
| 5860 | 5679 |
| 5861 | 5680 |
| 5862 Local<v8::Value> v8::BooleanObject::New(bool value) { | 5681 Local<v8::Value> v8::BooleanObject::New(bool value) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5934 } | 5753 } |
| 5935 ENTER_V8(i_isolate); | 5754 ENTER_V8(i_isolate); |
| 5936 EXCEPTION_PREAMBLE(i_isolate); | 5755 EXCEPTION_PREAMBLE(i_isolate); |
| 5937 i::Handle<i::Object> obj = | 5756 i::Handle<i::Object> obj = |
| 5938 i::Execution::NewDate(i_isolate, time, &has_pending_exception); | 5757 i::Execution::NewDate(i_isolate, time, &has_pending_exception); |
| 5939 EXCEPTION_BAILOUT_CHECK(i_isolate, Local<v8::Value>()); | 5758 EXCEPTION_BAILOUT_CHECK(i_isolate, Local<v8::Value>()); |
| 5940 return Utils::ToLocal(obj); | 5759 return Utils::ToLocal(obj); |
| 5941 } | 5760 } |
| 5942 | 5761 |
| 5943 | 5762 |
| 5944 Local<v8::Value> v8::Date::New(double time) { | |
| 5945 return New(Isolate::GetCurrent(), time); | |
| 5946 } | |
| 5947 | |
| 5948 | |
| 5949 double v8::Date::ValueOf() const { | 5763 double v8::Date::ValueOf() const { |
| 5950 i::Isolate* isolate = i::Isolate::Current(); | 5764 i::Isolate* isolate = i::Isolate::Current(); |
| 5951 LOG_API(isolate, "Date::NumberValue"); | 5765 LOG_API(isolate, "Date::NumberValue"); |
| 5952 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 5766 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 5953 i::Handle<i::JSDate> jsdate = i::Handle<i::JSDate>::cast(obj); | 5767 i::Handle<i::JSDate> jsdate = i::Handle<i::JSDate>::cast(obj); |
| 5954 return jsdate->value()->Number(); | 5768 return jsdate->value()->Number(); |
| 5955 } | 5769 } |
| 5956 | 5770 |
| 5957 | 5771 |
| 5958 void v8::Date::DateTimeConfigurationChangeNotification(Isolate* isolate) { | 5772 void v8::Date::DateTimeConfigurationChangeNotification(Isolate* isolate) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 5984 bool caught_exception = false; | 5798 bool caught_exception = false; |
| 5985 i::Execution::TryCall(func, | 5799 i::Execution::TryCall(func, |
| 5986 i_isolate->js_builtins_object(), | 5800 i_isolate->js_builtins_object(), |
| 5987 0, | 5801 0, |
| 5988 NULL, | 5802 NULL, |
| 5989 &caught_exception); | 5803 &caught_exception); |
| 5990 } | 5804 } |
| 5991 } | 5805 } |
| 5992 | 5806 |
| 5993 | 5807 |
| 5994 void v8::Date::DateTimeConfigurationChangeNotification() { | |
| 5995 DateTimeConfigurationChangeNotification(Isolate::GetCurrent()); | |
| 5996 } | |
| 5997 | |
| 5998 | |
| 5999 static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) { | 5808 static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) { |
| 6000 i::Isolate* isolate = i::Isolate::Current(); | 5809 i::Isolate* isolate = i::Isolate::Current(); |
| 6001 uint8_t flags_buf[3]; | 5810 uint8_t flags_buf[3]; |
| 6002 int num_flags = 0; | 5811 int num_flags = 0; |
| 6003 if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g'; | 5812 if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g'; |
| 6004 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm'; | 5813 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm'; |
| 6005 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; | 5814 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; |
| 6006 ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf))); | 5815 ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf))); |
| 6007 return isolate->factory()->InternalizeOneByteString( | 5816 return isolate->factory()->InternalizeOneByteString( |
| 6008 i::Vector<const uint8_t>(flags_buf, num_flags)); | 5817 i::Vector<const uint8_t>(flags_buf, num_flags)); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6054 ENTER_V8(i_isolate); | 5863 ENTER_V8(i_isolate); |
| 6055 int real_length = length > 0 ? length : 0; | 5864 int real_length = length > 0 ? length : 0; |
| 6056 i::Handle<i::JSArray> obj = i_isolate->factory()->NewJSArray(real_length); | 5865 i::Handle<i::JSArray> obj = i_isolate->factory()->NewJSArray(real_length); |
| 6057 i::Handle<i::Object> length_obj = | 5866 i::Handle<i::Object> length_obj = |
| 6058 i_isolate->factory()->NewNumberFromInt(real_length); | 5867 i_isolate->factory()->NewNumberFromInt(real_length); |
| 6059 obj->set_length(*length_obj); | 5868 obj->set_length(*length_obj); |
| 6060 return Utils::ToLocal(obj); | 5869 return Utils::ToLocal(obj); |
| 6061 } | 5870 } |
| 6062 | 5871 |
| 6063 | 5872 |
| 6064 Local<v8::Array> v8::Array::New(int length) { | |
| 6065 return New(Isolate::GetCurrent(), length); | |
| 6066 } | |
| 6067 | |
| 6068 | |
| 6069 uint32_t v8::Array::Length() const { | 5873 uint32_t v8::Array::Length() const { |
| 6070 i::Handle<i::JSArray> obj = Utils::OpenHandle(this); | 5874 i::Handle<i::JSArray> obj = Utils::OpenHandle(this); |
| 6071 i::Object* length = obj->length(); | 5875 i::Object* length = obj->length(); |
| 6072 if (length->IsSmi()) { | 5876 if (length->IsSmi()) { |
| 6073 return i::Smi::cast(length)->value(); | 5877 return i::Smi::cast(length)->value(); |
| 6074 } else { | 5878 } else { |
| 6075 return static_cast<uint32_t>(length->Number()); | 5879 return static_cast<uint32_t>(length->Number()); |
| 6076 } | 5880 } |
| 6077 } | 5881 } |
| 6078 | 5882 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6154 EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(size_t)"); | 5958 EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(size_t)"); |
| 6155 LOG_API(i_isolate, "v8::ArrayBuffer::New(size_t)"); | 5959 LOG_API(i_isolate, "v8::ArrayBuffer::New(size_t)"); |
| 6156 ENTER_V8(i_isolate); | 5960 ENTER_V8(i_isolate); |
| 6157 i::Handle<i::JSArrayBuffer> obj = | 5961 i::Handle<i::JSArrayBuffer> obj = |
| 6158 i_isolate->factory()->NewJSArrayBuffer(); | 5962 i_isolate->factory()->NewJSArrayBuffer(); |
| 6159 i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length); | 5963 i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length); |
| 6160 return Utils::ToLocal(obj); | 5964 return Utils::ToLocal(obj); |
| 6161 } | 5965 } |
| 6162 | 5966 |
| 6163 | 5967 |
| 6164 Local<ArrayBuffer> v8::ArrayBuffer::New(size_t byte_length) { | |
| 6165 return New(Isolate::GetCurrent(), byte_length); | |
| 6166 } | |
| 6167 | |
| 6168 | |
| 6169 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, | 5968 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, |
| 6170 size_t byte_length) { | 5969 size_t byte_length) { |
| 6171 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 5970 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6172 EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); | 5971 EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); |
| 6173 LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); | 5972 LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); |
| 6174 ENTER_V8(i_isolate); | 5973 ENTER_V8(i_isolate); |
| 6175 i::Handle<i::JSArrayBuffer> obj = | 5974 i::Handle<i::JSArrayBuffer> obj = |
| 6176 i_isolate->factory()->NewJSArrayBuffer(); | 5975 i_isolate->factory()->NewJSArrayBuffer(); |
| 6177 i::Runtime::SetupArrayBuffer(i_isolate, obj, true, data, byte_length); | 5976 i::Runtime::SetupArrayBuffer(i_isolate, obj, true, data, byte_length); |
| 6178 return Utils::ToLocal(obj); | 5977 return Utils::ToLocal(obj); |
| 6179 } | 5978 } |
| 6180 | 5979 |
| 6181 | 5980 |
| 6182 Local<ArrayBuffer> v8::ArrayBuffer::New(void* data, size_t byte_length) { | |
| 6183 return New(Isolate::GetCurrent(), data, byte_length); | |
| 6184 } | |
| 6185 | |
| 6186 | |
| 6187 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() { | 5981 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() { |
| 6188 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); | 5982 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); |
| 6189 ASSERT(obj->buffer()->IsJSArrayBuffer()); | 5983 ASSERT(obj->buffer()->IsJSArrayBuffer()); |
| 6190 i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(obj->buffer())); | 5984 i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(obj->buffer())); |
| 6191 return Utils::ToLocal(buffer); | 5985 return Utils::ToLocal(buffer); |
| 6192 } | 5986 } |
| 6193 | 5987 |
| 6194 | 5988 |
| 6195 size_t v8::ArrayBufferView::ByteOffset() { | 5989 size_t v8::ArrayBufferView::ByteOffset() { |
| 6196 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); | 5990 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6509 } | 6303 } |
| 6510 | 6304 |
| 6511 | 6305 |
| 6512 int64_t Isolate::AdjustAmountOfExternalAllocatedMemory( | 6306 int64_t Isolate::AdjustAmountOfExternalAllocatedMemory( |
| 6513 int64_t change_in_bytes) { | 6307 int64_t change_in_bytes) { |
| 6514 i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap(); | 6308 i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap(); |
| 6515 return heap->AdjustAmountOfExternalAllocatedMemory(change_in_bytes); | 6309 return heap->AdjustAmountOfExternalAllocatedMemory(change_in_bytes); |
| 6516 } | 6310 } |
| 6517 | 6311 |
| 6518 | 6312 |
| 6519 int64_t V8::AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes) { | |
| 6520 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); | |
| 6521 if (isolate == NULL || !isolate->IsInitialized()) { | |
| 6522 return 0; | |
| 6523 } | |
| 6524 Isolate* isolate_ext = reinterpret_cast<Isolate*>(isolate); | |
| 6525 return isolate_ext->AdjustAmountOfExternalAllocatedMemory(change_in_bytes); | |
| 6526 } | |
| 6527 | |
| 6528 | |
| 6529 HeapProfiler* Isolate::GetHeapProfiler() { | 6313 HeapProfiler* Isolate::GetHeapProfiler() { |
| 6530 i::HeapProfiler* heap_profiler = | 6314 i::HeapProfiler* heap_profiler = |
| 6531 reinterpret_cast<i::Isolate*>(this)->heap_profiler(); | 6315 reinterpret_cast<i::Isolate*>(this)->heap_profiler(); |
| 6532 return reinterpret_cast<HeapProfiler*>(heap_profiler); | 6316 return reinterpret_cast<HeapProfiler*>(heap_profiler); |
| 6533 } | 6317 } |
| 6534 | 6318 |
| 6535 | 6319 |
| 6536 CpuProfiler* Isolate::GetCpuProfiler() { | 6320 CpuProfiler* Isolate::GetCpuProfiler() { |
| 6537 i::CpuProfiler* cpu_profiler = | 6321 i::CpuProfiler* cpu_profiler = |
| 6538 reinterpret_cast<i::Isolate*>(this)->cpu_profiler(); | 6322 reinterpret_cast<i::Isolate*>(this)->cpu_profiler(); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6715 return IsExecutionTerminatingCheck(i_isolate); | 6499 return IsExecutionTerminatingCheck(i_isolate); |
| 6716 } | 6500 } |
| 6717 | 6501 |
| 6718 | 6502 |
| 6719 void V8::CancelTerminateExecution(Isolate* isolate) { | 6503 void V8::CancelTerminateExecution(Isolate* isolate) { |
| 6720 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6504 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6721 i_isolate->stack_guard()->CancelTerminateExecution(); | 6505 i_isolate->stack_guard()->CancelTerminateExecution(); |
| 6722 } | 6506 } |
| 6723 | 6507 |
| 6724 | 6508 |
| 6509 void Isolate::RequestInterrupt(InterruptCallback callback, void* data) { |
| 6510 reinterpret_cast<i::Isolate*>(this)->stack_guard()->RequestInterrupt( |
| 6511 callback, data); |
| 6512 } |
| 6513 |
| 6514 |
| 6515 void Isolate::ClearInterrupt() { |
| 6516 reinterpret_cast<i::Isolate*>(this)->stack_guard()->ClearInterrupt(); |
| 6517 } |
| 6518 |
| 6519 |
| 6725 Isolate* Isolate::GetCurrent() { | 6520 Isolate* Isolate::GetCurrent() { |
| 6726 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); | 6521 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); |
| 6727 return reinterpret_cast<Isolate*>(isolate); | 6522 return reinterpret_cast<Isolate*>(isolate); |
| 6728 } | 6523 } |
| 6729 | 6524 |
| 6730 | 6525 |
| 6731 Isolate* Isolate::New() { | 6526 Isolate* Isolate::New() { |
| 6732 i::Isolate* isolate = new i::Isolate(); | 6527 i::Isolate* isolate = new i::Isolate(); |
| 6733 return reinterpret_cast<Isolate*>(isolate); | 6528 return reinterpret_cast<Isolate*>(isolate); |
| 6734 } | 6529 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6791 str_ = i::NewArray<char>(length_ + 1); | 6586 str_ = i::NewArray<char>(length_ + 1); |
| 6792 str->WriteUtf8(str_); | 6587 str->WriteUtf8(str_); |
| 6793 } | 6588 } |
| 6794 | 6589 |
| 6795 | 6590 |
| 6796 String::Utf8Value::~Utf8Value() { | 6591 String::Utf8Value::~Utf8Value() { |
| 6797 i::DeleteArray(str_); | 6592 i::DeleteArray(str_); |
| 6798 } | 6593 } |
| 6799 | 6594 |
| 6800 | 6595 |
| 6801 String::AsciiValue::AsciiValue(v8::Handle<v8::Value> obj) | |
| 6802 : str_(NULL), length_(0) { | |
| 6803 i::Isolate* isolate = i::Isolate::Current(); | |
| 6804 if (obj.IsEmpty()) return; | |
| 6805 ENTER_V8(isolate); | |
| 6806 i::HandleScope scope(isolate); | |
| 6807 TryCatch try_catch; | |
| 6808 Handle<String> str = obj->ToString(); | |
| 6809 if (str.IsEmpty()) return; | |
| 6810 length_ = str->Utf8Length(); | |
| 6811 str_ = i::NewArray<char>(length_ + 1); | |
| 6812 str->WriteUtf8(str_); | |
| 6813 ASSERT(i::String::NonAsciiStart(str_, length_) >= length_); | |
| 6814 } | |
| 6815 | |
| 6816 | |
| 6817 String::AsciiValue::~AsciiValue() { | |
| 6818 i::DeleteArray(str_); | |
| 6819 } | |
| 6820 | |
| 6821 | |
| 6822 String::Value::Value(v8::Handle<v8::Value> obj) | 6596 String::Value::Value(v8::Handle<v8::Value> obj) |
| 6823 : str_(NULL), length_(0) { | 6597 : str_(NULL), length_(0) { |
| 6824 i::Isolate* isolate = i::Isolate::Current(); | 6598 i::Isolate* isolate = i::Isolate::Current(); |
| 6825 if (obj.IsEmpty()) return; | 6599 if (obj.IsEmpty()) return; |
| 6826 ENTER_V8(isolate); | 6600 ENTER_V8(isolate); |
| 6827 i::HandleScope scope(isolate); | 6601 i::HandleScope scope(isolate); |
| 6828 TryCatch try_catch; | 6602 TryCatch try_catch; |
| 6829 Handle<String> str = obj->ToString(); | 6603 Handle<String> str = obj->ToString(); |
| 6830 if (str.IsEmpty()) return; | 6604 if (str.IsEmpty()) return; |
| 6831 length_ = str->Length(); | 6605 length_ = str->Length(); |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7200 reinterpret_cast<const i::ProfileNode*>(this)->children()->at(index); | 6974 reinterpret_cast<const i::ProfileNode*>(this)->children()->at(index); |
| 7201 return reinterpret_cast<const CpuProfileNode*>(child); | 6975 return reinterpret_cast<const CpuProfileNode*>(child); |
| 7202 } | 6976 } |
| 7203 | 6977 |
| 7204 | 6978 |
| 7205 void CpuProfile::Delete() { | 6979 void CpuProfile::Delete() { |
| 7206 i::Isolate* isolate = i::Isolate::Current(); | 6980 i::Isolate* isolate = i::Isolate::Current(); |
| 7207 i::CpuProfiler* profiler = isolate->cpu_profiler(); | 6981 i::CpuProfiler* profiler = isolate->cpu_profiler(); |
| 7208 ASSERT(profiler != NULL); | 6982 ASSERT(profiler != NULL); |
| 7209 profiler->DeleteProfile(reinterpret_cast<i::CpuProfile*>(this)); | 6983 profiler->DeleteProfile(reinterpret_cast<i::CpuProfile*>(this)); |
| 7210 if (profiler->GetProfilesCount() == 0) { | |
| 7211 // If this was the last profile, clean up all accessory data as well. | |
| 7212 profiler->DeleteAllProfiles(); | |
| 7213 } | |
| 7214 } | 6984 } |
| 7215 | 6985 |
| 7216 | 6986 |
| 7217 unsigned CpuProfile::GetUid() const { | |
| 7218 return reinterpret_cast<const i::CpuProfile*>(this)->uid(); | |
| 7219 } | |
| 7220 | |
| 7221 | |
| 7222 Handle<String> CpuProfile::GetTitle() const { | 6987 Handle<String> CpuProfile::GetTitle() const { |
| 7223 i::Isolate* isolate = i::Isolate::Current(); | 6988 i::Isolate* isolate = i::Isolate::Current(); |
| 7224 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); | 6989 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); |
| 7225 return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String( | 6990 return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String( |
| 7226 profile->title())); | 6991 profile->title())); |
| 7227 } | 6992 } |
| 7228 | 6993 |
| 7229 | 6994 |
| 7230 const CpuProfileNode* CpuProfile::GetTopDownRoot() const { | 6995 const CpuProfileNode* CpuProfile::GetTopDownRoot() const { |
| 7231 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); | 6996 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 7249 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); | 7014 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); |
| 7250 return (profile->end_time() - i::Time::UnixEpoch()).InMicroseconds(); | 7015 return (profile->end_time() - i::Time::UnixEpoch()).InMicroseconds(); |
| 7251 } | 7016 } |
| 7252 | 7017 |
| 7253 | 7018 |
| 7254 int CpuProfile::GetSamplesCount() const { | 7019 int CpuProfile::GetSamplesCount() const { |
| 7255 return reinterpret_cast<const i::CpuProfile*>(this)->samples_count(); | 7020 return reinterpret_cast<const i::CpuProfile*>(this)->samples_count(); |
| 7256 } | 7021 } |
| 7257 | 7022 |
| 7258 | 7023 |
| 7259 int CpuProfiler::GetProfileCount() { | |
| 7260 return reinterpret_cast<i::CpuProfiler*>(this)->GetProfilesCount(); | |
| 7261 } | |
| 7262 | |
| 7263 | |
| 7264 void CpuProfiler::SetSamplingInterval(int us) { | 7024 void CpuProfiler::SetSamplingInterval(int us) { |
| 7265 ASSERT(us >= 0); | 7025 ASSERT(us >= 0); |
| 7266 return reinterpret_cast<i::CpuProfiler*>(this)->set_sampling_interval( | 7026 return reinterpret_cast<i::CpuProfiler*>(this)->set_sampling_interval( |
| 7267 i::TimeDelta::FromMicroseconds(us)); | 7027 i::TimeDelta::FromMicroseconds(us)); |
| 7268 } | 7028 } |
| 7269 | 7029 |
| 7270 | 7030 |
| 7271 const CpuProfile* CpuProfiler::GetCpuProfile(int index) { | |
| 7272 return reinterpret_cast<const CpuProfile*>( | |
| 7273 reinterpret_cast<i::CpuProfiler*>(this)->GetProfile(index)); | |
| 7274 } | |
| 7275 | |
| 7276 | |
| 7277 void CpuProfiler::StartCpuProfiling(Handle<String> title, bool record_samples) { | 7031 void CpuProfiler::StartCpuProfiling(Handle<String> title, bool record_samples) { |
| 7278 reinterpret_cast<i::CpuProfiler*>(this)->StartProfiling( | 7032 reinterpret_cast<i::CpuProfiler*>(this)->StartProfiling( |
| 7279 *Utils::OpenHandle(*title), record_samples); | 7033 *Utils::OpenHandle(*title), record_samples); |
| 7280 } | 7034 } |
| 7281 | 7035 |
| 7282 | 7036 |
| 7283 const CpuProfile* CpuProfiler::StopCpuProfiling(Handle<String> title) { | 7037 const CpuProfile* CpuProfiler::StopCpuProfiling(Handle<String> title) { |
| 7284 return reinterpret_cast<const CpuProfile*>( | 7038 return reinterpret_cast<const CpuProfile*>( |
| 7285 reinterpret_cast<i::CpuProfiler*>(this)->StopProfiling( | 7039 reinterpret_cast<i::CpuProfiler*>(this)->StopProfiling( |
| 7286 *Utils::OpenHandle(*title))); | 7040 *Utils::OpenHandle(*title))); |
| 7287 } | 7041 } |
| 7288 | 7042 |
| 7289 | 7043 |
| 7290 void CpuProfiler::DeleteAllCpuProfiles() { | |
| 7291 reinterpret_cast<i::CpuProfiler*>(this)->DeleteAllProfiles(); | |
| 7292 } | |
| 7293 | |
| 7294 | |
| 7295 void CpuProfiler::SetIdle(bool is_idle) { | 7044 void CpuProfiler::SetIdle(bool is_idle) { |
| 7296 i::Isolate* isolate = reinterpret_cast<i::CpuProfiler*>(this)->isolate(); | 7045 i::Isolate* isolate = reinterpret_cast<i::CpuProfiler*>(this)->isolate(); |
| 7297 i::StateTag state = isolate->current_vm_state(); | 7046 i::StateTag state = isolate->current_vm_state(); |
| 7298 ASSERT(state == i::EXTERNAL || state == i::IDLE); | 7047 ASSERT(state == i::EXTERNAL || state == i::IDLE); |
| 7299 if (isolate->js_entry_sp() != NULL) return; | 7048 if (isolate->js_entry_sp() != NULL) return; |
| 7300 if (is_idle) { | 7049 if (is_idle) { |
| 7301 isolate->set_current_vm_state(i::IDLE); | 7050 isolate->set_current_vm_state(i::IDLE); |
| 7302 } else if (state == i::IDLE) { | 7051 } else if (state == i::IDLE) { |
| 7303 isolate->set_current_vm_state(i::EXTERNAL); | 7052 isolate->set_current_vm_state(i::EXTERNAL); |
| 7304 } | 7053 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7381 return ToInternal(this)->children().length(); | 7130 return ToInternal(this)->children().length(); |
| 7382 } | 7131 } |
| 7383 | 7132 |
| 7384 | 7133 |
| 7385 const HeapGraphEdge* HeapGraphNode::GetChild(int index) const { | 7134 const HeapGraphEdge* HeapGraphNode::GetChild(int index) const { |
| 7386 return reinterpret_cast<const HeapGraphEdge*>( | 7135 return reinterpret_cast<const HeapGraphEdge*>( |
| 7387 ToInternal(this)->children()[index]); | 7136 ToInternal(this)->children()[index]); |
| 7388 } | 7137 } |
| 7389 | 7138 |
| 7390 | 7139 |
| 7391 v8::Handle<v8::Value> HeapGraphNode::GetHeapValue() const { | |
| 7392 i::Isolate* isolate = i::Isolate::Current(); | |
| 7393 i::Handle<i::HeapObject> object = ToInternal(this)->GetHeapObject(); | |
| 7394 return !object.is_null() ? | |
| 7395 ToApiHandle<Value>(object) : | |
| 7396 ToApiHandle<Value>(isolate->factory()->undefined_value()); | |
| 7397 } | |
| 7398 | |
| 7399 | |
| 7400 static i::HeapSnapshot* ToInternal(const HeapSnapshot* snapshot) { | 7140 static i::HeapSnapshot* ToInternal(const HeapSnapshot* snapshot) { |
| 7401 return const_cast<i::HeapSnapshot*>( | 7141 return const_cast<i::HeapSnapshot*>( |
| 7402 reinterpret_cast<const i::HeapSnapshot*>(snapshot)); | 7142 reinterpret_cast<const i::HeapSnapshot*>(snapshot)); |
| 7403 } | 7143 } |
| 7404 | 7144 |
| 7405 | 7145 |
| 7406 void HeapSnapshot::Delete() { | 7146 void HeapSnapshot::Delete() { |
| 7407 i::Isolate* isolate = i::Isolate::Current(); | 7147 i::Isolate* isolate = i::Isolate::Current(); |
| 7408 if (isolate->heap_profiler()->GetSnapshotsCount() > 1) { | 7148 if (isolate->heap_profiler()->GetSnapshotsCount() > 1) { |
| 7409 ToInternal(this)->Delete(); | 7149 ToInternal(this)->Delete(); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7479 reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshot(index)); | 7219 reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshot(index)); |
| 7480 } | 7220 } |
| 7481 | 7221 |
| 7482 | 7222 |
| 7483 SnapshotObjectId HeapProfiler::GetObjectId(Handle<Value> value) { | 7223 SnapshotObjectId HeapProfiler::GetObjectId(Handle<Value> value) { |
| 7484 i::Handle<i::Object> obj = Utils::OpenHandle(*value); | 7224 i::Handle<i::Object> obj = Utils::OpenHandle(*value); |
| 7485 return reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshotObjectId(obj); | 7225 return reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshotObjectId(obj); |
| 7486 } | 7226 } |
| 7487 | 7227 |
| 7488 | 7228 |
| 7229 Handle<Value> HeapProfiler::FindObjectById(SnapshotObjectId id) { |
| 7230 i::Handle<i::Object> obj = |
| 7231 reinterpret_cast<i::HeapProfiler*>(this)->FindHeapObjectById(id); |
| 7232 if (obj.is_null()) return Local<Value>(); |
| 7233 return Utils::ToLocal(obj); |
| 7234 } |
| 7235 |
| 7236 |
| 7237 void HeapProfiler::ClearObjectIds() { |
| 7238 reinterpret_cast<i::HeapProfiler*>(this)->ClearHeapObjectMap(); |
| 7239 } |
| 7240 |
| 7241 |
| 7489 const HeapSnapshot* HeapProfiler::TakeHeapSnapshot( | 7242 const HeapSnapshot* HeapProfiler::TakeHeapSnapshot( |
| 7490 Handle<String> title, | 7243 Handle<String> title, |
| 7491 ActivityControl* control, | 7244 ActivityControl* control, |
| 7492 ObjectNameResolver* resolver) { | 7245 ObjectNameResolver* resolver) { |
| 7493 return reinterpret_cast<const HeapSnapshot*>( | 7246 return reinterpret_cast<const HeapSnapshot*>( |
| 7494 reinterpret_cast<i::HeapProfiler*>(this)->TakeSnapshot( | 7247 reinterpret_cast<i::HeapProfiler*>(this)->TakeSnapshot( |
| 7495 *Utils::OpenHandle(*title), control, resolver)); | 7248 *Utils::OpenHandle(*title), control, resolver)); |
| 7496 } | 7249 } |
| 7497 | 7250 |
| 7498 | 7251 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 7529 GetMemorySizeUsedByProfiler(); | 7282 GetMemorySizeUsedByProfiler(); |
| 7530 } | 7283 } |
| 7531 | 7284 |
| 7532 | 7285 |
| 7533 void HeapProfiler::SetRetainedObjectInfo(UniqueId id, | 7286 void HeapProfiler::SetRetainedObjectInfo(UniqueId id, |
| 7534 RetainedObjectInfo* info) { | 7287 RetainedObjectInfo* info) { |
| 7535 reinterpret_cast<i::HeapProfiler*>(this)->SetRetainedObjectInfo(id, info); | 7288 reinterpret_cast<i::HeapProfiler*>(this)->SetRetainedObjectInfo(id, info); |
| 7536 } | 7289 } |
| 7537 | 7290 |
| 7538 | 7291 |
| 7539 void HeapProfiler::StartRecordingHeapAllocations() { | |
| 7540 reinterpret_cast<i::HeapProfiler*>(this)->StartHeapObjectsTracking(true); | |
| 7541 } | |
| 7542 | |
| 7543 | |
| 7544 void HeapProfiler::StopRecordingHeapAllocations() { | |
| 7545 reinterpret_cast<i::HeapProfiler*>(this)->StopHeapObjectsTracking(); | |
| 7546 } | |
| 7547 | |
| 7548 | |
| 7549 v8::Testing::StressType internal::Testing::stress_type_ = | 7292 v8::Testing::StressType internal::Testing::stress_type_ = |
| 7550 v8::Testing::kStressTypeOpt; | 7293 v8::Testing::kStressTypeOpt; |
| 7551 | 7294 |
| 7552 | 7295 |
| 7553 void Testing::SetStressRunType(Testing::StressType type) { | 7296 void Testing::SetStressRunType(Testing::StressType type) { |
| 7554 internal::Testing::set_stress_type(type); | 7297 internal::Testing::set_stress_type(type); |
| 7555 } | 7298 } |
| 7556 | 7299 |
| 7557 | 7300 |
| 7558 int Testing::GetStressRuns() { | 7301 int Testing::GetStressRuns() { |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7780 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7523 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 7781 Address callback_address = | 7524 Address callback_address = |
| 7782 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7525 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 7783 VMState<EXTERNAL> state(isolate); | 7526 VMState<EXTERNAL> state(isolate); |
| 7784 ExternalCallbackScope call_scope(isolate, callback_address); | 7527 ExternalCallbackScope call_scope(isolate, callback_address); |
| 7785 callback(info); | 7528 callback(info); |
| 7786 } | 7529 } |
| 7787 | 7530 |
| 7788 | 7531 |
| 7789 } } // namespace v8::internal | 7532 } } // namespace v8::internal |
| OLD | NEW |