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 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5367 return Utils::ToLocal(token_handle); | 5229 return Utils::ToLocal(token_handle); |
5368 } | 5230 } |
5369 | 5231 |
5370 | 5232 |
5371 bool Context::HasOutOfMemoryException() { | 5233 bool Context::HasOutOfMemoryException() { |
5372 i::Handle<i::Context> env = Utils::OpenHandle(this); | 5234 i::Handle<i::Context> env = Utils::OpenHandle(this); |
5373 return env->has_out_of_memory(); | 5235 return env->has_out_of_memory(); |
5374 } | 5236 } |
5375 | 5237 |
5376 | 5238 |
5377 bool Context::InContext() { | |
5378 return i::Isolate::Current()->context() != NULL; | |
5379 } | |
5380 | |
5381 | |
5382 v8::Isolate* Context::GetIsolate() { | 5239 v8::Isolate* Context::GetIsolate() { |
5383 i::Handle<i::Context> env = Utils::OpenHandle(this); | 5240 i::Handle<i::Context> env = Utils::OpenHandle(this); |
5384 return reinterpret_cast<Isolate*>(env->GetIsolate()); | 5241 return reinterpret_cast<Isolate*>(env->GetIsolate()); |
5385 } | 5242 } |
5386 | 5243 |
5387 | 5244 |
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() { | 5245 v8::Local<v8::Object> Context::Global() { |
5410 i::Handle<i::Context> context = Utils::OpenHandle(this); | 5246 i::Handle<i::Context> context = Utils::OpenHandle(this); |
5411 i::Isolate* isolate = context->GetIsolate(); | 5247 i::Isolate* isolate = context->GetIsolate(); |
5412 i::Handle<i::Object> global(context->global_proxy(), isolate); | 5248 i::Handle<i::Object> global(context->global_proxy(), isolate); |
5413 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global)); | 5249 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global)); |
5414 } | 5250 } |
5415 | 5251 |
5416 | 5252 |
5417 void Context::DetachGlobal() { | 5253 void Context::DetachGlobal() { |
5418 i::Handle<i::Context> context = Utils::OpenHandle(this); | 5254 i::Handle<i::Context> context = Utils::OpenHandle(this); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5497 STATIC_ASSERT(sizeof(value) == sizeof(i::Address)); | 5333 STATIC_ASSERT(sizeof(value) == sizeof(i::Address)); |
5498 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 5334 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
5499 EnsureInitializedForIsolate(i_isolate, "v8::External::New()"); | 5335 EnsureInitializedForIsolate(i_isolate, "v8::External::New()"); |
5500 LOG_API(i_isolate, "External::New"); | 5336 LOG_API(i_isolate, "External::New"); |
5501 ENTER_V8(i_isolate); | 5337 ENTER_V8(i_isolate); |
5502 i::Handle<i::JSObject> external = i_isolate->factory()->NewExternal(value); | 5338 i::Handle<i::JSObject> external = i_isolate->factory()->NewExternal(value); |
5503 return Utils::ExternalToLocal(external); | 5339 return Utils::ExternalToLocal(external); |
5504 } | 5340 } |
5505 | 5341 |
5506 | 5342 |
5507 Local<External> v8::External::New(void* value) { | |
5508 return v8::External::New(Isolate::GetCurrent(), value); | |
5509 } | |
5510 | |
5511 | |
5512 void* External::Value() const { | 5343 void* External::Value() const { |
5513 return ExternalValue(*Utils::OpenHandle(this)); | 5344 return ExternalValue(*Utils::OpenHandle(this)); |
5514 } | 5345 } |
5515 | 5346 |
5516 | 5347 |
5517 Local<String> v8::String::Empty() { | 5348 Local<String> v8::String::Empty() { |
5518 i::Isolate* isolate = i::Isolate::Current(); | 5349 i::Isolate* isolate = i::Isolate::Current(); |
5519 if (!EnsureInitializedForIsolate(isolate, "v8::String::Empty()")) { | 5350 if (!EnsureInitializedForIsolate(isolate, "v8::String::Empty()")) { |
5520 return v8::Local<String>(); | 5351 return v8::Local<String>(); |
5521 } | 5352 } |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5693 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()"); | 5524 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()"); |
5694 LOG_API(i_isolate, "String::NewExternal"); | 5525 LOG_API(i_isolate, "String::NewExternal"); |
5695 ENTER_V8(i_isolate); | 5526 ENTER_V8(i_isolate); |
5696 CHECK(resource && resource->data()); | 5527 CHECK(resource && resource->data()); |
5697 i::Handle<i::String> result = NewExternalStringHandle(i_isolate, resource); | 5528 i::Handle<i::String> result = NewExternalStringHandle(i_isolate, resource); |
5698 i_isolate->heap()->external_string_table()->AddString(*result); | 5529 i_isolate->heap()->external_string_table()->AddString(*result); |
5699 return Utils::ToLocal(result); | 5530 return Utils::ToLocal(result); |
5700 } | 5531 } |
5701 | 5532 |
5702 | 5533 |
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) { | 5534 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { |
5710 i::Handle<i::String> obj = Utils::OpenHandle(this); | 5535 i::Handle<i::String> obj = Utils::OpenHandle(this); |
5711 i::Isolate* isolate = obj->GetIsolate(); | 5536 i::Isolate* isolate = obj->GetIsolate(); |
5712 if (i::StringShape(*obj).IsExternalTwoByte()) { | 5537 if (i::StringShape(*obj).IsExternalTwoByte()) { |
5713 return false; // Already an external string. | 5538 return false; // Already an external string. |
5714 } | 5539 } |
5715 ENTER_V8(isolate); | 5540 ENTER_V8(isolate); |
5716 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { | 5541 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { |
5717 return false; | 5542 return false; |
5718 } | 5543 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5750 LOG_API(i_isolate, "String::NewExternal"); | 5575 LOG_API(i_isolate, "String::NewExternal"); |
5751 ENTER_V8(i_isolate); | 5576 ENTER_V8(i_isolate); |
5752 CHECK(resource && resource->data()); | 5577 CHECK(resource && resource->data()); |
5753 i::Handle<i::String> result = | 5578 i::Handle<i::String> result = |
5754 NewExternalAsciiStringHandle(i_isolate, resource); | 5579 NewExternalAsciiStringHandle(i_isolate, resource); |
5755 i_isolate->heap()->external_string_table()->AddString(*result); | 5580 i_isolate->heap()->external_string_table()->AddString(*result); |
5756 return Utils::ToLocal(result); | 5581 return Utils::ToLocal(result); |
5757 } | 5582 } |
5758 | 5583 |
5759 | 5584 |
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( | 5585 bool v8::String::MakeExternal( |
5767 v8::String::ExternalAsciiStringResource* resource) { | 5586 v8::String::ExternalAsciiStringResource* resource) { |
5768 i::Handle<i::String> obj = Utils::OpenHandle(this); | 5587 i::Handle<i::String> obj = Utils::OpenHandle(this); |
5769 i::Isolate* isolate = obj->GetIsolate(); | 5588 i::Isolate* isolate = obj->GetIsolate(); |
5770 if (i::StringShape(*obj).IsExternalTwoByte()) { | 5589 if (i::StringShape(*obj).IsExternalTwoByte()) { |
5771 return false; // Already an external string. | 5590 return false; // Already an external string. |
5772 } | 5591 } |
5773 ENTER_V8(isolate); | 5592 ENTER_V8(isolate); |
5774 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { | 5593 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { |
5775 return false; | 5594 return false; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5838 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 5657 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
5839 EnsureInitializedForIsolate(i_isolate, "v8::NumberObject::New()"); | 5658 EnsureInitializedForIsolate(i_isolate, "v8::NumberObject::New()"); |
5840 LOG_API(i_isolate, "NumberObject::New"); | 5659 LOG_API(i_isolate, "NumberObject::New"); |
5841 ENTER_V8(i_isolate); | 5660 ENTER_V8(i_isolate); |
5842 i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value); | 5661 i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value); |
5843 i::Handle<i::Object> obj = i_isolate->factory()->ToObject(number); | 5662 i::Handle<i::Object> obj = i_isolate->factory()->ToObject(number); |
5844 return Utils::ToLocal(obj); | 5663 return Utils::ToLocal(obj); |
5845 } | 5664 } |
5846 | 5665 |
5847 | 5666 |
5848 Local<v8::Value> v8::NumberObject::New(double value) { | |
5849 return New(Isolate::GetCurrent(), value); | |
5850 } | |
5851 | |
5852 | |
5853 double v8::NumberObject::ValueOf() const { | 5667 double v8::NumberObject::ValueOf() const { |
5854 i::Isolate* isolate = i::Isolate::Current(); | 5668 i::Isolate* isolate = i::Isolate::Current(); |
5855 LOG_API(isolate, "NumberObject::NumberValue"); | 5669 LOG_API(isolate, "NumberObject::NumberValue"); |
5856 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 5670 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
5857 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 5671 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
5858 return jsvalue->value()->Number(); | 5672 return jsvalue->value()->Number(); |
5859 } | 5673 } |
5860 | 5674 |
5861 | 5675 |
5862 Local<v8::Value> v8::BooleanObject::New(bool value) { | 5676 Local<v8::Value> v8::BooleanObject::New(bool value) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5934 } | 5748 } |
5935 ENTER_V8(i_isolate); | 5749 ENTER_V8(i_isolate); |
5936 EXCEPTION_PREAMBLE(i_isolate); | 5750 EXCEPTION_PREAMBLE(i_isolate); |
5937 i::Handle<i::Object> obj = | 5751 i::Handle<i::Object> obj = |
5938 i::Execution::NewDate(i_isolate, time, &has_pending_exception); | 5752 i::Execution::NewDate(i_isolate, time, &has_pending_exception); |
5939 EXCEPTION_BAILOUT_CHECK(i_isolate, Local<v8::Value>()); | 5753 EXCEPTION_BAILOUT_CHECK(i_isolate, Local<v8::Value>()); |
5940 return Utils::ToLocal(obj); | 5754 return Utils::ToLocal(obj); |
5941 } | 5755 } |
5942 | 5756 |
5943 | 5757 |
5944 Local<v8::Value> v8::Date::New(double time) { | |
5945 return New(Isolate::GetCurrent(), time); | |
5946 } | |
5947 | |
5948 | |
5949 double v8::Date::ValueOf() const { | 5758 double v8::Date::ValueOf() const { |
5950 i::Isolate* isolate = i::Isolate::Current(); | 5759 i::Isolate* isolate = i::Isolate::Current(); |
5951 LOG_API(isolate, "Date::NumberValue"); | 5760 LOG_API(isolate, "Date::NumberValue"); |
5952 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 5761 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
5953 i::Handle<i::JSDate> jsdate = i::Handle<i::JSDate>::cast(obj); | 5762 i::Handle<i::JSDate> jsdate = i::Handle<i::JSDate>::cast(obj); |
5954 return jsdate->value()->Number(); | 5763 return jsdate->value()->Number(); |
5955 } | 5764 } |
5956 | 5765 |
5957 | 5766 |
5958 void v8::Date::DateTimeConfigurationChangeNotification(Isolate* isolate) { | 5767 void v8::Date::DateTimeConfigurationChangeNotification(Isolate* isolate) { |
(...skipping 25 matching lines...) Expand all Loading... |
5984 bool caught_exception = false; | 5793 bool caught_exception = false; |
5985 i::Execution::TryCall(func, | 5794 i::Execution::TryCall(func, |
5986 i_isolate->js_builtins_object(), | 5795 i_isolate->js_builtins_object(), |
5987 0, | 5796 0, |
5988 NULL, | 5797 NULL, |
5989 &caught_exception); | 5798 &caught_exception); |
5990 } | 5799 } |
5991 } | 5800 } |
5992 | 5801 |
5993 | 5802 |
5994 void v8::Date::DateTimeConfigurationChangeNotification() { | |
5995 DateTimeConfigurationChangeNotification(Isolate::GetCurrent()); | |
5996 } | |
5997 | |
5998 | |
5999 static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) { | 5803 static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) { |
6000 i::Isolate* isolate = i::Isolate::Current(); | 5804 i::Isolate* isolate = i::Isolate::Current(); |
6001 uint8_t flags_buf[3]; | 5805 uint8_t flags_buf[3]; |
6002 int num_flags = 0; | 5806 int num_flags = 0; |
6003 if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g'; | 5807 if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g'; |
6004 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm'; | 5808 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm'; |
6005 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; | 5809 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; |
6006 ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf))); | 5810 ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf))); |
6007 return isolate->factory()->InternalizeOneByteString( | 5811 return isolate->factory()->InternalizeOneByteString( |
6008 i::Vector<const uint8_t>(flags_buf, num_flags)); | 5812 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); | 5858 ENTER_V8(i_isolate); |
6055 int real_length = length > 0 ? length : 0; | 5859 int real_length = length > 0 ? length : 0; |
6056 i::Handle<i::JSArray> obj = i_isolate->factory()->NewJSArray(real_length); | 5860 i::Handle<i::JSArray> obj = i_isolate->factory()->NewJSArray(real_length); |
6057 i::Handle<i::Object> length_obj = | 5861 i::Handle<i::Object> length_obj = |
6058 i_isolate->factory()->NewNumberFromInt(real_length); | 5862 i_isolate->factory()->NewNumberFromInt(real_length); |
6059 obj->set_length(*length_obj); | 5863 obj->set_length(*length_obj); |
6060 return Utils::ToLocal(obj); | 5864 return Utils::ToLocal(obj); |
6061 } | 5865 } |
6062 | 5866 |
6063 | 5867 |
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 { | 5868 uint32_t v8::Array::Length() const { |
6070 i::Handle<i::JSArray> obj = Utils::OpenHandle(this); | 5869 i::Handle<i::JSArray> obj = Utils::OpenHandle(this); |
6071 i::Object* length = obj->length(); | 5870 i::Object* length = obj->length(); |
6072 if (length->IsSmi()) { | 5871 if (length->IsSmi()) { |
6073 return i::Smi::cast(length)->value(); | 5872 return i::Smi::cast(length)->value(); |
6074 } else { | 5873 } else { |
6075 return static_cast<uint32_t>(length->Number()); | 5874 return static_cast<uint32_t>(length->Number()); |
6076 } | 5875 } |
6077 } | 5876 } |
6078 | 5877 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6154 EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(size_t)"); | 5953 EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(size_t)"); |
6155 LOG_API(i_isolate, "v8::ArrayBuffer::New(size_t)"); | 5954 LOG_API(i_isolate, "v8::ArrayBuffer::New(size_t)"); |
6156 ENTER_V8(i_isolate); | 5955 ENTER_V8(i_isolate); |
6157 i::Handle<i::JSArrayBuffer> obj = | 5956 i::Handle<i::JSArrayBuffer> obj = |
6158 i_isolate->factory()->NewJSArrayBuffer(); | 5957 i_isolate->factory()->NewJSArrayBuffer(); |
6159 i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length); | 5958 i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length); |
6160 return Utils::ToLocal(obj); | 5959 return Utils::ToLocal(obj); |
6161 } | 5960 } |
6162 | 5961 |
6163 | 5962 |
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, | 5963 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, |
6170 size_t byte_length) { | 5964 size_t byte_length) { |
6171 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 5965 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6172 EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); | 5966 EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); |
6173 LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); | 5967 LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); |
6174 ENTER_V8(i_isolate); | 5968 ENTER_V8(i_isolate); |
6175 i::Handle<i::JSArrayBuffer> obj = | 5969 i::Handle<i::JSArrayBuffer> obj = |
6176 i_isolate->factory()->NewJSArrayBuffer(); | 5970 i_isolate->factory()->NewJSArrayBuffer(); |
6177 i::Runtime::SetupArrayBuffer(i_isolate, obj, true, data, byte_length); | 5971 i::Runtime::SetupArrayBuffer(i_isolate, obj, true, data, byte_length); |
6178 return Utils::ToLocal(obj); | 5972 return Utils::ToLocal(obj); |
6179 } | 5973 } |
6180 | 5974 |
6181 | 5975 |
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() { | 5976 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() { |
6188 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); | 5977 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); |
6189 ASSERT(obj->buffer()->IsJSArrayBuffer()); | 5978 ASSERT(obj->buffer()->IsJSArrayBuffer()); |
6190 i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(obj->buffer())); | 5979 i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(obj->buffer())); |
6191 return Utils::ToLocal(buffer); | 5980 return Utils::ToLocal(buffer); |
6192 } | 5981 } |
6193 | 5982 |
6194 | 5983 |
6195 size_t v8::ArrayBufferView::ByteOffset() { | 5984 size_t v8::ArrayBufferView::ByteOffset() { |
6196 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); | 5985 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6509 } | 6298 } |
6510 | 6299 |
6511 | 6300 |
6512 int64_t Isolate::AdjustAmountOfExternalAllocatedMemory( | 6301 int64_t Isolate::AdjustAmountOfExternalAllocatedMemory( |
6513 int64_t change_in_bytes) { | 6302 int64_t change_in_bytes) { |
6514 i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap(); | 6303 i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap(); |
6515 return heap->AdjustAmountOfExternalAllocatedMemory(change_in_bytes); | 6304 return heap->AdjustAmountOfExternalAllocatedMemory(change_in_bytes); |
6516 } | 6305 } |
6517 | 6306 |
6518 | 6307 |
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() { | 6308 HeapProfiler* Isolate::GetHeapProfiler() { |
6530 i::HeapProfiler* heap_profiler = | 6309 i::HeapProfiler* heap_profiler = |
6531 reinterpret_cast<i::Isolate*>(this)->heap_profiler(); | 6310 reinterpret_cast<i::Isolate*>(this)->heap_profiler(); |
6532 return reinterpret_cast<HeapProfiler*>(heap_profiler); | 6311 return reinterpret_cast<HeapProfiler*>(heap_profiler); |
6533 } | 6312 } |
6534 | 6313 |
6535 | 6314 |
6536 CpuProfiler* Isolate::GetCpuProfiler() { | 6315 CpuProfiler* Isolate::GetCpuProfiler() { |
6537 i::CpuProfiler* cpu_profiler = | 6316 i::CpuProfiler* cpu_profiler = |
6538 reinterpret_cast<i::Isolate*>(this)->cpu_profiler(); | 6317 reinterpret_cast<i::Isolate*>(this)->cpu_profiler(); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6791 str_ = i::NewArray<char>(length_ + 1); | 6570 str_ = i::NewArray<char>(length_ + 1); |
6792 str->WriteUtf8(str_); | 6571 str->WriteUtf8(str_); |
6793 } | 6572 } |
6794 | 6573 |
6795 | 6574 |
6796 String::Utf8Value::~Utf8Value() { | 6575 String::Utf8Value::~Utf8Value() { |
6797 i::DeleteArray(str_); | 6576 i::DeleteArray(str_); |
6798 } | 6577 } |
6799 | 6578 |
6800 | 6579 |
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) | 6580 String::Value::Value(v8::Handle<v8::Value> obj) |
6823 : str_(NULL), length_(0) { | 6581 : str_(NULL), length_(0) { |
6824 i::Isolate* isolate = i::Isolate::Current(); | 6582 i::Isolate* isolate = i::Isolate::Current(); |
6825 if (obj.IsEmpty()) return; | 6583 if (obj.IsEmpty()) return; |
6826 ENTER_V8(isolate); | 6584 ENTER_V8(isolate); |
6827 i::HandleScope scope(isolate); | 6585 i::HandleScope scope(isolate); |
6828 TryCatch try_catch; | 6586 TryCatch try_catch; |
6829 Handle<String> str = obj->ToString(); | 6587 Handle<String> str = obj->ToString(); |
6830 if (str.IsEmpty()) return; | 6588 if (str.IsEmpty()) return; |
6831 length_ = str->Length(); | 6589 length_ = str->Length(); |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7529 GetMemorySizeUsedByProfiler(); | 7287 GetMemorySizeUsedByProfiler(); |
7530 } | 7288 } |
7531 | 7289 |
7532 | 7290 |
7533 void HeapProfiler::SetRetainedObjectInfo(UniqueId id, | 7291 void HeapProfiler::SetRetainedObjectInfo(UniqueId id, |
7534 RetainedObjectInfo* info) { | 7292 RetainedObjectInfo* info) { |
7535 reinterpret_cast<i::HeapProfiler*>(this)->SetRetainedObjectInfo(id, info); | 7293 reinterpret_cast<i::HeapProfiler*>(this)->SetRetainedObjectInfo(id, info); |
7536 } | 7294 } |
7537 | 7295 |
7538 | 7296 |
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_ = | 7297 v8::Testing::StressType internal::Testing::stress_type_ = |
7550 v8::Testing::kStressTypeOpt; | 7298 v8::Testing::kStressTypeOpt; |
7551 | 7299 |
7552 | 7300 |
7553 void Testing::SetStressRunType(Testing::StressType type) { | 7301 void Testing::SetStressRunType(Testing::StressType type) { |
7554 internal::Testing::set_stress_type(type); | 7302 internal::Testing::set_stress_type(type); |
7555 } | 7303 } |
7556 | 7304 |
7557 | 7305 |
7558 int Testing::GetStressRuns() { | 7306 int Testing::GetStressRuns() { |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7780 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7528 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7781 Address callback_address = | 7529 Address callback_address = |
7782 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7530 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7783 VMState<EXTERNAL> state(isolate); | 7531 VMState<EXTERNAL> state(isolate); |
7784 ExternalCallbackScope call_scope(isolate, callback_address); | 7532 ExternalCallbackScope call_scope(isolate, callback_address); |
7785 callback(info); | 7533 callback(info); |
7786 } | 7534 } |
7787 | 7535 |
7788 | 7536 |
7789 } } // namespace v8::internal | 7537 } } // namespace v8::internal |
OLD | NEW |