| 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 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1913 result = | 1816 result = |
| 1914 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj)); | 1817 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj)); |
| 1915 } else { | 1818 } else { |
| 1916 result = | 1819 result = |
| 1917 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared()); | 1820 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared()); |
| 1918 } | 1821 } |
| 1919 return result; | 1822 return result; |
| 1920 } | 1823 } |
| 1921 | 1824 |
| 1922 | 1825 |
| 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() { | 1826 int Script::GetId() { |
| 1943 i::Handle<i::HeapObject> obj = | 1827 i::Handle<i::HeapObject> obj = |
| 1944 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this)); | 1828 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this)); |
| 1945 i::Isolate* isolate = obj->GetIsolate(); | 1829 i::Isolate* isolate = obj->GetIsolate(); |
| 1946 ON_BAILOUT(isolate, "v8::Script::Id()", return -1); | 1830 ON_BAILOUT(isolate, "v8::Script::Id()", return -1); |
| 1947 LOG_API(isolate, "Script::Id"); | 1831 LOG_API(isolate, "Script::Id"); |
| 1948 { | 1832 { |
| 1949 i::HandleScope scope(isolate); | 1833 i::HandleScope scope(isolate); |
| 1950 i::Handle<i::SharedFunctionInfo> function_info = OpenScript(this); | 1834 i::Handle<i::SharedFunctionInfo> function_info = OpenScript(this); |
| 1951 i::Handle<i::Script> script(i::Script::cast(function_info->script())); | 1835 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 } | 2198 } |
| 2315 | 2199 |
| 2316 | 2200 |
| 2317 void Message::PrintCurrentStackTrace(Isolate* isolate, FILE* out) { | 2201 void Message::PrintCurrentStackTrace(Isolate* isolate, FILE* out) { |
| 2318 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 2202 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 2319 ENTER_V8(i_isolate); | 2203 ENTER_V8(i_isolate); |
| 2320 i_isolate->PrintCurrentStackTrace(out); | 2204 i_isolate->PrintCurrentStackTrace(out); |
| 2321 } | 2205 } |
| 2322 | 2206 |
| 2323 | 2207 |
| 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 --- | 2208 // --- S t a c k T r a c e --- |
| 2330 | 2209 |
| 2331 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const { | 2210 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const { |
| 2332 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2211 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 2333 ENTER_V8(isolate); | 2212 ENTER_V8(isolate); |
| 2334 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 2213 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
| 2335 i::Handle<i::JSArray> self = Utils::OpenHandle(this); | 2214 i::Handle<i::JSArray> self = Utils::OpenHandle(this); |
| 2336 i::Object* raw_object = self->GetElementNoExceptionThrown(isolate, index); | 2215 i::Object* raw_object = self->GetElementNoExceptionThrown(isolate, index); |
| 2337 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_object)); | 2216 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_object)); |
| 2338 return scope.Escape(Utils::StackFrameToLocal(obj)); | 2217 return scope.Escape(Utils::StackFrameToLocal(obj)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2358 int frame_limit, | 2237 int frame_limit, |
| 2359 StackTraceOptions options) { | 2238 StackTraceOptions options) { |
| 2360 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 2239 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 2361 ENTER_V8(i_isolate); | 2240 ENTER_V8(i_isolate); |
| 2362 i::Handle<i::JSArray> stackTrace = | 2241 i::Handle<i::JSArray> stackTrace = |
| 2363 i_isolate->CaptureCurrentStackTrace(frame_limit, options); | 2242 i_isolate->CaptureCurrentStackTrace(frame_limit, options); |
| 2364 return Utils::StackTraceToLocal(stackTrace); | 2243 return Utils::StackTraceToLocal(stackTrace); |
| 2365 } | 2244 } |
| 2366 | 2245 |
| 2367 | 2246 |
| 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 --- | 2247 // --- S t a c k F r a m e --- |
| 2375 | 2248 |
| 2376 int StackFrame::GetLineNumber() const { | 2249 int StackFrame::GetLineNumber() const { |
| 2377 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2250 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 2378 ENTER_V8(isolate); | 2251 ENTER_V8(isolate); |
| 2379 i::HandleScope scope(isolate); | 2252 i::HandleScope scope(isolate); |
| 2380 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2253 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| 2381 i::Handle<i::Object> line = GetProperty(self, "lineNumber"); | 2254 i::Handle<i::Object> line = GetProperty(self, "lineNumber"); |
| 2382 if (!line->IsSmi()) { | 2255 if (!line->IsSmi()) { |
| 2383 return Message::kNoLineNumberInfo; | 2256 return Message::kNoLineNumberInfo; |
| (...skipping 1895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4279 return kLineOffsetNotFound; | 4152 return kLineOffsetNotFound; |
| 4280 } | 4153 } |
| 4281 | 4154 |
| 4282 | 4155 |
| 4283 bool Function::IsBuiltin() const { | 4156 bool Function::IsBuiltin() const { |
| 4284 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | 4157 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
| 4285 return func->IsBuiltin(); | 4158 return func->IsBuiltin(); |
| 4286 } | 4159 } |
| 4287 | 4160 |
| 4288 | 4161 |
| 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 { | 4162 int Function::ScriptId() const { |
| 4301 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | 4163 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
| 4302 if (!func->shared()->script()->IsScript()) return v8::Script::kNoScriptId; | 4164 if (!func->shared()->script()->IsScript()) return v8::Script::kNoScriptId; |
| 4303 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); | 4165 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); |
| 4304 return script->id()->value(); | 4166 return script->id()->value(); |
| 4305 } | 4167 } |
| 4306 | 4168 |
| 4307 | 4169 |
| 4308 int String::Length() const { | 4170 int String::Length() const { |
| 4309 i::Handle<i::String> str = Utils::OpenHandle(this); | 4171 i::Handle<i::String> str = Utils::OpenHandle(this); |
| (...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5366 return Utils::ToLocal(token_handle); | 5228 return Utils::ToLocal(token_handle); |
| 5367 } | 5229 } |
| 5368 | 5230 |
| 5369 | 5231 |
| 5370 bool Context::HasOutOfMemoryException() { | 5232 bool Context::HasOutOfMemoryException() { |
| 5371 i::Handle<i::Context> env = Utils::OpenHandle(this); | 5233 i::Handle<i::Context> env = Utils::OpenHandle(this); |
| 5372 return env->has_out_of_memory(); | 5234 return env->has_out_of_memory(); |
| 5373 } | 5235 } |
| 5374 | 5236 |
| 5375 | 5237 |
| 5376 bool Context::InContext() { | |
| 5377 return i::Isolate::Current()->context() != NULL; | |
| 5378 } | |
| 5379 | |
| 5380 | |
| 5381 v8::Isolate* Context::GetIsolate() { | 5238 v8::Isolate* Context::GetIsolate() { |
| 5382 i::Handle<i::Context> env = Utils::OpenHandle(this); | 5239 i::Handle<i::Context> env = Utils::OpenHandle(this); |
| 5383 return reinterpret_cast<Isolate*>(env->GetIsolate()); | 5240 return reinterpret_cast<Isolate*>(env->GetIsolate()); |
| 5384 } | 5241 } |
| 5385 | 5242 |
| 5386 | 5243 |
| 5387 v8::Local<v8::Context> Context::GetEntered() { | |
| 5388 i::Isolate* isolate = i::Isolate::Current(); | |
| 5389 if (!EnsureInitializedForIsolate(isolate, "v8::Context::GetEntered()")) { | |
| 5390 return Local<Context>(); | |
| 5391 } | |
| 5392 return reinterpret_cast<Isolate*>(isolate)->GetEnteredContext(); | |
| 5393 } | |
| 5394 | |
| 5395 | |
| 5396 v8::Local<v8::Context> Context::GetCurrent() { | |
| 5397 i::Isolate* isolate = i::Isolate::Current(); | |
| 5398 return reinterpret_cast<Isolate*>(isolate)->GetCurrentContext(); | |
| 5399 } | |
| 5400 | |
| 5401 | |
| 5402 v8::Local<v8::Context> Context::GetCalling() { | |
| 5403 i::Isolate* isolate = i::Isolate::Current(); | |
| 5404 return reinterpret_cast<Isolate*>(isolate)->GetCallingContext(); | |
| 5405 } | |
| 5406 | |
| 5407 | |
| 5408 v8::Local<v8::Object> Context::Global() { | 5244 v8::Local<v8::Object> Context::Global() { |
| 5409 i::Handle<i::Context> context = Utils::OpenHandle(this); | 5245 i::Handle<i::Context> context = Utils::OpenHandle(this); |
| 5410 i::Isolate* isolate = context->GetIsolate(); | 5246 i::Isolate* isolate = context->GetIsolate(); |
| 5411 i::Handle<i::Object> global(context->global_proxy(), isolate); | 5247 i::Handle<i::Object> global(context->global_proxy(), isolate); |
| 5412 // TODO(dcarney): This should always return the global proxy | 5248 // TODO(dcarney): This should always return the global proxy |
| 5413 // but can't presently as calls to GetProtoype will return the wrong result. | 5249 // but can't presently as calls to GetProtoype will return the wrong result. |
| 5414 if (i::Handle<i::JSGlobalProxy>::cast( | 5250 if (i::Handle<i::JSGlobalProxy>::cast( |
| 5415 global)->IsDetachedFrom(context->global_object())) { | 5251 global)->IsDetachedFrom(context->global_object())) { |
| 5416 global = i::Handle<i::Object>(context->global_object(), isolate); | 5252 global = i::Handle<i::Object>(context->global_object(), isolate); |
| 5417 } | 5253 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5492 STATIC_ASSERT(sizeof(value) == sizeof(i::Address)); | 5328 STATIC_ASSERT(sizeof(value) == sizeof(i::Address)); |
| 5493 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 5329 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 5494 EnsureInitializedForIsolate(i_isolate, "v8::External::New()"); | 5330 EnsureInitializedForIsolate(i_isolate, "v8::External::New()"); |
| 5495 LOG_API(i_isolate, "External::New"); | 5331 LOG_API(i_isolate, "External::New"); |
| 5496 ENTER_V8(i_isolate); | 5332 ENTER_V8(i_isolate); |
| 5497 i::Handle<i::JSObject> external = i_isolate->factory()->NewExternal(value); | 5333 i::Handle<i::JSObject> external = i_isolate->factory()->NewExternal(value); |
| 5498 return Utils::ExternalToLocal(external); | 5334 return Utils::ExternalToLocal(external); |
| 5499 } | 5335 } |
| 5500 | 5336 |
| 5501 | 5337 |
| 5502 Local<External> v8::External::New(void* value) { | |
| 5503 return v8::External::New(Isolate::GetCurrent(), value); | |
| 5504 } | |
| 5505 | |
| 5506 | |
| 5507 void* External::Value() const { | 5338 void* External::Value() const { |
| 5508 return ExternalValue(*Utils::OpenHandle(this)); | 5339 return ExternalValue(*Utils::OpenHandle(this)); |
| 5509 } | 5340 } |
| 5510 | 5341 |
| 5511 | 5342 |
| 5512 Local<String> v8::String::Empty() { | 5343 Local<String> v8::String::Empty() { |
| 5513 i::Isolate* isolate = i::Isolate::Current(); | 5344 i::Isolate* isolate = i::Isolate::Current(); |
| 5514 if (!EnsureInitializedForIsolate(isolate, "v8::String::Empty()")) { | 5345 if (!EnsureInitializedForIsolate(isolate, "v8::String::Empty()")) { |
| 5515 return v8::Local<String>(); | 5346 return v8::Local<String>(); |
| 5516 } | 5347 } |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5688 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()"); | 5519 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()"); |
| 5689 LOG_API(i_isolate, "String::NewExternal"); | 5520 LOG_API(i_isolate, "String::NewExternal"); |
| 5690 ENTER_V8(i_isolate); | 5521 ENTER_V8(i_isolate); |
| 5691 CHECK(resource && resource->data()); | 5522 CHECK(resource && resource->data()); |
| 5692 i::Handle<i::String> result = NewExternalStringHandle(i_isolate, resource); | 5523 i::Handle<i::String> result = NewExternalStringHandle(i_isolate, resource); |
| 5693 i_isolate->heap()->external_string_table()->AddString(*result); | 5524 i_isolate->heap()->external_string_table()->AddString(*result); |
| 5694 return Utils::ToLocal(result); | 5525 return Utils::ToLocal(result); |
| 5695 } | 5526 } |
| 5696 | 5527 |
| 5697 | 5528 |
| 5698 Local<String> v8::String::NewExternal( | |
| 5699 v8::String::ExternalStringResource* resource) { | |
| 5700 return NewExternal(Isolate::GetCurrent(), resource); | |
| 5701 } | |
| 5702 | |
| 5703 | |
| 5704 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { | 5529 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { |
| 5705 i::Handle<i::String> obj = Utils::OpenHandle(this); | 5530 i::Handle<i::String> obj = Utils::OpenHandle(this); |
| 5706 i::Isolate* isolate = obj->GetIsolate(); | 5531 i::Isolate* isolate = obj->GetIsolate(); |
| 5707 if (i::StringShape(*obj).IsExternalTwoByte()) { | 5532 if (i::StringShape(*obj).IsExternalTwoByte()) { |
| 5708 return false; // Already an external string. | 5533 return false; // Already an external string. |
| 5709 } | 5534 } |
| 5710 ENTER_V8(isolate); | 5535 ENTER_V8(isolate); |
| 5711 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { | 5536 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { |
| 5712 return false; | 5537 return false; |
| 5713 } | 5538 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5745 LOG_API(i_isolate, "String::NewExternal"); | 5570 LOG_API(i_isolate, "String::NewExternal"); |
| 5746 ENTER_V8(i_isolate); | 5571 ENTER_V8(i_isolate); |
| 5747 CHECK(resource && resource->data()); | 5572 CHECK(resource && resource->data()); |
| 5748 i::Handle<i::String> result = | 5573 i::Handle<i::String> result = |
| 5749 NewExternalAsciiStringHandle(i_isolate, resource); | 5574 NewExternalAsciiStringHandle(i_isolate, resource); |
| 5750 i_isolate->heap()->external_string_table()->AddString(*result); | 5575 i_isolate->heap()->external_string_table()->AddString(*result); |
| 5751 return Utils::ToLocal(result); | 5576 return Utils::ToLocal(result); |
| 5752 } | 5577 } |
| 5753 | 5578 |
| 5754 | 5579 |
| 5755 Local<String> v8::String::NewExternal( | |
| 5756 v8::String::ExternalAsciiStringResource* resource) { | |
| 5757 return NewExternal(Isolate::GetCurrent(), resource); | |
| 5758 } | |
| 5759 | |
| 5760 | |
| 5761 bool v8::String::MakeExternal( | 5580 bool v8::String::MakeExternal( |
| 5762 v8::String::ExternalAsciiStringResource* resource) { | 5581 v8::String::ExternalAsciiStringResource* resource) { |
| 5763 i::Handle<i::String> obj = Utils::OpenHandle(this); | 5582 i::Handle<i::String> obj = Utils::OpenHandle(this); |
| 5764 i::Isolate* isolate = obj->GetIsolate(); | 5583 i::Isolate* isolate = obj->GetIsolate(); |
| 5765 if (i::StringShape(*obj).IsExternalTwoByte()) { | 5584 if (i::StringShape(*obj).IsExternalTwoByte()) { |
| 5766 return false; // Already an external string. | 5585 return false; // Already an external string. |
| 5767 } | 5586 } |
| 5768 ENTER_V8(isolate); | 5587 ENTER_V8(isolate); |
| 5769 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { | 5588 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { |
| 5770 return false; | 5589 return false; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5833 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 5652 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 5834 EnsureInitializedForIsolate(i_isolate, "v8::NumberObject::New()"); | 5653 EnsureInitializedForIsolate(i_isolate, "v8::NumberObject::New()"); |
| 5835 LOG_API(i_isolate, "NumberObject::New"); | 5654 LOG_API(i_isolate, "NumberObject::New"); |
| 5836 ENTER_V8(i_isolate); | 5655 ENTER_V8(i_isolate); |
| 5837 i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value); | 5656 i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value); |
| 5838 i::Handle<i::Object> obj = i_isolate->factory()->ToObject(number); | 5657 i::Handle<i::Object> obj = i_isolate->factory()->ToObject(number); |
| 5839 return Utils::ToLocal(obj); | 5658 return Utils::ToLocal(obj); |
| 5840 } | 5659 } |
| 5841 | 5660 |
| 5842 | 5661 |
| 5843 Local<v8::Value> v8::NumberObject::New(double value) { | |
| 5844 return New(Isolate::GetCurrent(), value); | |
| 5845 } | |
| 5846 | |
| 5847 | |
| 5848 double v8::NumberObject::ValueOf() const { | 5662 double v8::NumberObject::ValueOf() const { |
| 5849 i::Isolate* isolate = i::Isolate::Current(); | 5663 i::Isolate* isolate = i::Isolate::Current(); |
| 5850 LOG_API(isolate, "NumberObject::NumberValue"); | 5664 LOG_API(isolate, "NumberObject::NumberValue"); |
| 5851 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 5665 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 5852 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 5666 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
| 5853 return jsvalue->value()->Number(); | 5667 return jsvalue->value()->Number(); |
| 5854 } | 5668 } |
| 5855 | 5669 |
| 5856 | 5670 |
| 5857 Local<v8::Value> v8::BooleanObject::New(bool value) { | 5671 Local<v8::Value> v8::BooleanObject::New(bool value) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5929 } | 5743 } |
| 5930 ENTER_V8(i_isolate); | 5744 ENTER_V8(i_isolate); |
| 5931 EXCEPTION_PREAMBLE(i_isolate); | 5745 EXCEPTION_PREAMBLE(i_isolate); |
| 5932 i::Handle<i::Object> obj = | 5746 i::Handle<i::Object> obj = |
| 5933 i::Execution::NewDate(i_isolate, time, &has_pending_exception); | 5747 i::Execution::NewDate(i_isolate, time, &has_pending_exception); |
| 5934 EXCEPTION_BAILOUT_CHECK(i_isolate, Local<v8::Value>()); | 5748 EXCEPTION_BAILOUT_CHECK(i_isolate, Local<v8::Value>()); |
| 5935 return Utils::ToLocal(obj); | 5749 return Utils::ToLocal(obj); |
| 5936 } | 5750 } |
| 5937 | 5751 |
| 5938 | 5752 |
| 5939 Local<v8::Value> v8::Date::New(double time) { | |
| 5940 return New(Isolate::GetCurrent(), time); | |
| 5941 } | |
| 5942 | |
| 5943 | |
| 5944 double v8::Date::ValueOf() const { | 5753 double v8::Date::ValueOf() const { |
| 5945 i::Isolate* isolate = i::Isolate::Current(); | 5754 i::Isolate* isolate = i::Isolate::Current(); |
| 5946 LOG_API(isolate, "Date::NumberValue"); | 5755 LOG_API(isolate, "Date::NumberValue"); |
| 5947 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 5756 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 5948 i::Handle<i::JSDate> jsdate = i::Handle<i::JSDate>::cast(obj); | 5757 i::Handle<i::JSDate> jsdate = i::Handle<i::JSDate>::cast(obj); |
| 5949 return jsdate->value()->Number(); | 5758 return jsdate->value()->Number(); |
| 5950 } | 5759 } |
| 5951 | 5760 |
| 5952 | 5761 |
| 5953 void v8::Date::DateTimeConfigurationChangeNotification(Isolate* isolate) { | 5762 void v8::Date::DateTimeConfigurationChangeNotification(Isolate* isolate) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 5979 bool caught_exception = false; | 5788 bool caught_exception = false; |
| 5980 i::Execution::TryCall(func, | 5789 i::Execution::TryCall(func, |
| 5981 i_isolate->js_builtins_object(), | 5790 i_isolate->js_builtins_object(), |
| 5982 0, | 5791 0, |
| 5983 NULL, | 5792 NULL, |
| 5984 &caught_exception); | 5793 &caught_exception); |
| 5985 } | 5794 } |
| 5986 } | 5795 } |
| 5987 | 5796 |
| 5988 | 5797 |
| 5989 void v8::Date::DateTimeConfigurationChangeNotification() { | |
| 5990 DateTimeConfigurationChangeNotification(Isolate::GetCurrent()); | |
| 5991 } | |
| 5992 | |
| 5993 | |
| 5994 static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) { | 5798 static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) { |
| 5995 i::Isolate* isolate = i::Isolate::Current(); | 5799 i::Isolate* isolate = i::Isolate::Current(); |
| 5996 uint8_t flags_buf[3]; | 5800 uint8_t flags_buf[3]; |
| 5997 int num_flags = 0; | 5801 int num_flags = 0; |
| 5998 if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g'; | 5802 if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g'; |
| 5999 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm'; | 5803 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm'; |
| 6000 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; | 5804 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; |
| 6001 ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf))); | 5805 ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf))); |
| 6002 return isolate->factory()->InternalizeOneByteString( | 5806 return isolate->factory()->InternalizeOneByteString( |
| 6003 i::Vector<const uint8_t>(flags_buf, num_flags)); | 5807 i::Vector<const uint8_t>(flags_buf, num_flags)); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6049 ENTER_V8(i_isolate); | 5853 ENTER_V8(i_isolate); |
| 6050 int real_length = length > 0 ? length : 0; | 5854 int real_length = length > 0 ? length : 0; |
| 6051 i::Handle<i::JSArray> obj = i_isolate->factory()->NewJSArray(real_length); | 5855 i::Handle<i::JSArray> obj = i_isolate->factory()->NewJSArray(real_length); |
| 6052 i::Handle<i::Object> length_obj = | 5856 i::Handle<i::Object> length_obj = |
| 6053 i_isolate->factory()->NewNumberFromInt(real_length); | 5857 i_isolate->factory()->NewNumberFromInt(real_length); |
| 6054 obj->set_length(*length_obj); | 5858 obj->set_length(*length_obj); |
| 6055 return Utils::ToLocal(obj); | 5859 return Utils::ToLocal(obj); |
| 6056 } | 5860 } |
| 6057 | 5861 |
| 6058 | 5862 |
| 6059 Local<v8::Array> v8::Array::New(int length) { | |
| 6060 return New(Isolate::GetCurrent(), length); | |
| 6061 } | |
| 6062 | |
| 6063 | |
| 6064 uint32_t v8::Array::Length() const { | 5863 uint32_t v8::Array::Length() const { |
| 6065 i::Handle<i::JSArray> obj = Utils::OpenHandle(this); | 5864 i::Handle<i::JSArray> obj = Utils::OpenHandle(this); |
| 6066 i::Object* length = obj->length(); | 5865 i::Object* length = obj->length(); |
| 6067 if (length->IsSmi()) { | 5866 if (length->IsSmi()) { |
| 6068 return i::Smi::cast(length)->value(); | 5867 return i::Smi::cast(length)->value(); |
| 6069 } else { | 5868 } else { |
| 6070 return static_cast<uint32_t>(length->Number()); | 5869 return static_cast<uint32_t>(length->Number()); |
| 6071 } | 5870 } |
| 6072 } | 5871 } |
| 6073 | 5872 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6149 EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(size_t)"); | 5948 EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(size_t)"); |
| 6150 LOG_API(i_isolate, "v8::ArrayBuffer::New(size_t)"); | 5949 LOG_API(i_isolate, "v8::ArrayBuffer::New(size_t)"); |
| 6151 ENTER_V8(i_isolate); | 5950 ENTER_V8(i_isolate); |
| 6152 i::Handle<i::JSArrayBuffer> obj = | 5951 i::Handle<i::JSArrayBuffer> obj = |
| 6153 i_isolate->factory()->NewJSArrayBuffer(); | 5952 i_isolate->factory()->NewJSArrayBuffer(); |
| 6154 i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length); | 5953 i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length); |
| 6155 return Utils::ToLocal(obj); | 5954 return Utils::ToLocal(obj); |
| 6156 } | 5955 } |
| 6157 | 5956 |
| 6158 | 5957 |
| 6159 Local<ArrayBuffer> v8::ArrayBuffer::New(size_t byte_length) { | |
| 6160 return New(Isolate::GetCurrent(), byte_length); | |
| 6161 } | |
| 6162 | |
| 6163 | |
| 6164 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, | 5958 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, |
| 6165 size_t byte_length) { | 5959 size_t byte_length) { |
| 6166 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 5960 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6167 EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); | 5961 EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); |
| 6168 LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); | 5962 LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); |
| 6169 ENTER_V8(i_isolate); | 5963 ENTER_V8(i_isolate); |
| 6170 i::Handle<i::JSArrayBuffer> obj = | 5964 i::Handle<i::JSArrayBuffer> obj = |
| 6171 i_isolate->factory()->NewJSArrayBuffer(); | 5965 i_isolate->factory()->NewJSArrayBuffer(); |
| 6172 i::Runtime::SetupArrayBuffer(i_isolate, obj, true, data, byte_length); | 5966 i::Runtime::SetupArrayBuffer(i_isolate, obj, true, data, byte_length); |
| 6173 return Utils::ToLocal(obj); | 5967 return Utils::ToLocal(obj); |
| 6174 } | 5968 } |
| 6175 | 5969 |
| 6176 | 5970 |
| 6177 Local<ArrayBuffer> v8::ArrayBuffer::New(void* data, size_t byte_length) { | |
| 6178 return New(Isolate::GetCurrent(), data, byte_length); | |
| 6179 } | |
| 6180 | |
| 6181 | |
| 6182 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() { | 5971 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() { |
| 6183 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); | 5972 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); |
| 6184 ASSERT(obj->buffer()->IsJSArrayBuffer()); | 5973 ASSERT(obj->buffer()->IsJSArrayBuffer()); |
| 6185 i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(obj->buffer())); | 5974 i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(obj->buffer())); |
| 6186 return Utils::ToLocal(buffer); | 5975 return Utils::ToLocal(buffer); |
| 6187 } | 5976 } |
| 6188 | 5977 |
| 6189 | 5978 |
| 6190 size_t v8::ArrayBufferView::ByteOffset() { | 5979 size_t v8::ArrayBufferView::ByteOffset() { |
| 6191 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); | 5980 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6504 } | 6293 } |
| 6505 | 6294 |
| 6506 | 6295 |
| 6507 int64_t Isolate::AdjustAmountOfExternalAllocatedMemory( | 6296 int64_t Isolate::AdjustAmountOfExternalAllocatedMemory( |
| 6508 int64_t change_in_bytes) { | 6297 int64_t change_in_bytes) { |
| 6509 i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap(); | 6298 i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap(); |
| 6510 return heap->AdjustAmountOfExternalAllocatedMemory(change_in_bytes); | 6299 return heap->AdjustAmountOfExternalAllocatedMemory(change_in_bytes); |
| 6511 } | 6300 } |
| 6512 | 6301 |
| 6513 | 6302 |
| 6514 int64_t V8::AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes) { | |
| 6515 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); | |
| 6516 if (isolate == NULL || !isolate->IsInitialized()) { | |
| 6517 return 0; | |
| 6518 } | |
| 6519 Isolate* isolate_ext = reinterpret_cast<Isolate*>(isolate); | |
| 6520 return isolate_ext->AdjustAmountOfExternalAllocatedMemory(change_in_bytes); | |
| 6521 } | |
| 6522 | |
| 6523 | |
| 6524 HeapProfiler* Isolate::GetHeapProfiler() { | 6303 HeapProfiler* Isolate::GetHeapProfiler() { |
| 6525 i::HeapProfiler* heap_profiler = | 6304 i::HeapProfiler* heap_profiler = |
| 6526 reinterpret_cast<i::Isolate*>(this)->heap_profiler(); | 6305 reinterpret_cast<i::Isolate*>(this)->heap_profiler(); |
| 6527 return reinterpret_cast<HeapProfiler*>(heap_profiler); | 6306 return reinterpret_cast<HeapProfiler*>(heap_profiler); |
| 6528 } | 6307 } |
| 6529 | 6308 |
| 6530 | 6309 |
| 6531 CpuProfiler* Isolate::GetCpuProfiler() { | 6310 CpuProfiler* Isolate::GetCpuProfiler() { |
| 6532 i::CpuProfiler* cpu_profiler = | 6311 i::CpuProfiler* cpu_profiler = |
| 6533 reinterpret_cast<i::Isolate*>(this)->cpu_profiler(); | 6312 reinterpret_cast<i::Isolate*>(this)->cpu_profiler(); |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6786 str_ = i::NewArray<char>(length_ + 1); | 6565 str_ = i::NewArray<char>(length_ + 1); |
| 6787 str->WriteUtf8(str_); | 6566 str->WriteUtf8(str_); |
| 6788 } | 6567 } |
| 6789 | 6568 |
| 6790 | 6569 |
| 6791 String::Utf8Value::~Utf8Value() { | 6570 String::Utf8Value::~Utf8Value() { |
| 6792 i::DeleteArray(str_); | 6571 i::DeleteArray(str_); |
| 6793 } | 6572 } |
| 6794 | 6573 |
| 6795 | 6574 |
| 6796 String::AsciiValue::AsciiValue(v8::Handle<v8::Value> obj) | |
| 6797 : str_(NULL), length_(0) { | |
| 6798 i::Isolate* isolate = i::Isolate::Current(); | |
| 6799 if (obj.IsEmpty()) return; | |
| 6800 ENTER_V8(isolate); | |
| 6801 i::HandleScope scope(isolate); | |
| 6802 TryCatch try_catch; | |
| 6803 Handle<String> str = obj->ToString(); | |
| 6804 if (str.IsEmpty()) return; | |
| 6805 length_ = str->Utf8Length(); | |
| 6806 str_ = i::NewArray<char>(length_ + 1); | |
| 6807 str->WriteUtf8(str_); | |
| 6808 ASSERT(i::String::NonAsciiStart(str_, length_) >= length_); | |
| 6809 } | |
| 6810 | |
| 6811 | |
| 6812 String::AsciiValue::~AsciiValue() { | |
| 6813 i::DeleteArray(str_); | |
| 6814 } | |
| 6815 | |
| 6816 | |
| 6817 String::Value::Value(v8::Handle<v8::Value> obj) | 6575 String::Value::Value(v8::Handle<v8::Value> obj) |
| 6818 : str_(NULL), length_(0) { | 6576 : str_(NULL), length_(0) { |
| 6819 i::Isolate* isolate = i::Isolate::Current(); | 6577 i::Isolate* isolate = i::Isolate::Current(); |
| 6820 if (obj.IsEmpty()) return; | 6578 if (obj.IsEmpty()) return; |
| 6821 ENTER_V8(isolate); | 6579 ENTER_V8(isolate); |
| 6822 i::HandleScope scope(isolate); | 6580 i::HandleScope scope(isolate); |
| 6823 TryCatch try_catch; | 6581 TryCatch try_catch; |
| 6824 Handle<String> str = obj->ToString(); | 6582 Handle<String> str = obj->ToString(); |
| 6825 if (str.IsEmpty()) return; | 6583 if (str.IsEmpty()) return; |
| 6826 length_ = str->Length(); | 6584 length_ = str->Length(); |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7520 GetMemorySizeUsedByProfiler(); | 7278 GetMemorySizeUsedByProfiler(); |
| 7521 } | 7279 } |
| 7522 | 7280 |
| 7523 | 7281 |
| 7524 void HeapProfiler::SetRetainedObjectInfo(UniqueId id, | 7282 void HeapProfiler::SetRetainedObjectInfo(UniqueId id, |
| 7525 RetainedObjectInfo* info) { | 7283 RetainedObjectInfo* info) { |
| 7526 reinterpret_cast<i::HeapProfiler*>(this)->SetRetainedObjectInfo(id, info); | 7284 reinterpret_cast<i::HeapProfiler*>(this)->SetRetainedObjectInfo(id, info); |
| 7527 } | 7285 } |
| 7528 | 7286 |
| 7529 | 7287 |
| 7530 void HeapProfiler::StartRecordingHeapAllocations() { | |
| 7531 reinterpret_cast<i::HeapProfiler*>(this)->StartHeapObjectsTracking(true); | |
| 7532 } | |
| 7533 | |
| 7534 | |
| 7535 void HeapProfiler::StopRecordingHeapAllocations() { | |
| 7536 reinterpret_cast<i::HeapProfiler*>(this)->StopHeapObjectsTracking(); | |
| 7537 } | |
| 7538 | |
| 7539 | |
| 7540 v8::Testing::StressType internal::Testing::stress_type_ = | 7288 v8::Testing::StressType internal::Testing::stress_type_ = |
| 7541 v8::Testing::kStressTypeOpt; | 7289 v8::Testing::kStressTypeOpt; |
| 7542 | 7290 |
| 7543 | 7291 |
| 7544 void Testing::SetStressRunType(Testing::StressType type) { | 7292 void Testing::SetStressRunType(Testing::StressType type) { |
| 7545 internal::Testing::set_stress_type(type); | 7293 internal::Testing::set_stress_type(type); |
| 7546 } | 7294 } |
| 7547 | 7295 |
| 7548 | 7296 |
| 7549 int Testing::GetStressRuns() { | 7297 int Testing::GetStressRuns() { |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7771 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7519 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 7772 Address callback_address = | 7520 Address callback_address = |
| 7773 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7521 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 7774 VMState<EXTERNAL> state(isolate); | 7522 VMState<EXTERNAL> state(isolate); |
| 7775 ExternalCallbackScope call_scope(isolate, callback_address); | 7523 ExternalCallbackScope call_scope(isolate, callback_address); |
| 7776 callback(info); | 7524 callback(info); |
| 7777 } | 7525 } |
| 7778 | 7526 |
| 7779 | 7527 |
| 7780 } } // namespace v8::internal | 7528 } } // namespace v8::internal |
| OLD | NEW |