| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 #include "platform.h" | 55 #include "platform.h" |
| 56 #include "platform/time.h" | 56 #include "platform/time.h" |
| 57 #include "profile-generator-inl.h" | 57 #include "profile-generator-inl.h" |
| 58 #include "property-details.h" | 58 #include "property-details.h" |
| 59 #include "property.h" | 59 #include "property.h" |
| 60 #include "runtime.h" | 60 #include "runtime.h" |
| 61 #include "runtime-profiler.h" | 61 #include "runtime-profiler.h" |
| 62 #include "scanner-character-streams.h" | 62 #include "scanner-character-streams.h" |
| 63 #include "snapshot.h" | 63 #include "snapshot.h" |
| 64 #include "unicode-inl.h" | 64 #include "unicode-inl.h" |
| 65 #include "utils/random-number-generator.h" |
| 65 #include "v8threads.h" | 66 #include "v8threads.h" |
| 66 #include "version.h" | 67 #include "version.h" |
| 67 #include "vm-state-inl.h" | 68 #include "vm-state-inl.h" |
| 68 | 69 |
| 69 | 70 |
| 70 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) | 71 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) |
| 71 | 72 |
| 72 #define ENTER_V8(isolate) \ | 73 #define ENTER_V8(isolate) \ |
| 73 ASSERT((isolate)->IsInitialized()); \ | 74 ASSERT((isolate)->IsInitialized()); \ |
| 74 i::VMState<i::OTHER> __state__((isolate)) | 75 i::VMState<i::OTHER> __state__((isolate)) |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 return v8::Handle<Boolean>(); | 618 return v8::Handle<Boolean>(); |
| 618 } | 619 } |
| 619 return ToApiHandle<Boolean>(isolate->factory()->false_value()); | 620 return ToApiHandle<Boolean>(isolate->factory()->false_value()); |
| 620 } | 621 } |
| 621 | 622 |
| 622 | 623 |
| 623 ResourceConstraints::ResourceConstraints() | 624 ResourceConstraints::ResourceConstraints() |
| 624 : max_young_space_size_(0), | 625 : max_young_space_size_(0), |
| 625 max_old_space_size_(0), | 626 max_old_space_size_(0), |
| 626 max_executable_size_(0), | 627 max_executable_size_(0), |
| 627 stack_limit_(NULL) { } | 628 stack_limit_(NULL), |
| 629 is_memory_constrained_() { } |
| 628 | 630 |
| 629 | 631 |
| 630 bool SetResourceConstraints(ResourceConstraints* constraints) { | 632 bool SetResourceConstraints(ResourceConstraints* constraints) { |
| 631 i::Isolate* isolate = EnterIsolateIfNeeded(); | 633 i::Isolate* isolate = EnterIsolateIfNeeded(); |
| 632 | 634 |
| 633 int young_space_size = constraints->max_young_space_size(); | 635 int young_space_size = constraints->max_young_space_size(); |
| 634 int old_gen_size = constraints->max_old_space_size(); | 636 int old_gen_size = constraints->max_old_space_size(); |
| 635 int max_executable_size = constraints->max_executable_size(); | 637 int max_executable_size = constraints->max_executable_size(); |
| 636 if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0) { | 638 if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0) { |
| 637 // After initialization it's too late to change Heap constraints. | 639 // After initialization it's too late to change Heap constraints. |
| 638 ASSERT(!isolate->IsInitialized()); | 640 ASSERT(!isolate->IsInitialized()); |
| 639 bool result = isolate->heap()->ConfigureHeap(young_space_size / 2, | 641 bool result = isolate->heap()->ConfigureHeap(young_space_size / 2, |
| 640 old_gen_size, | 642 old_gen_size, |
| 641 max_executable_size); | 643 max_executable_size); |
| 642 if (!result) return false; | 644 if (!result) return false; |
| 643 } | 645 } |
| 644 if (constraints->stack_limit() != NULL) { | 646 if (constraints->stack_limit() != NULL) { |
| 645 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit()); | 647 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints->stack_limit()); |
| 646 isolate->stack_guard()->SetStackLimit(limit); | 648 isolate->stack_guard()->SetStackLimit(limit); |
| 647 } | 649 } |
| 650 if (constraints->is_memory_constrained().has_value) { |
| 651 isolate->set_is_memory_constrained( |
| 652 constraints->is_memory_constrained().value); |
| 653 } |
| 648 return true; | 654 return true; |
| 649 } | 655 } |
| 650 | 656 |
| 651 | 657 |
| 652 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { | 658 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { |
| 653 if (IsDeadCheck(isolate, "V8::Persistent::New")) return NULL; | 659 if (IsDeadCheck(isolate, "V8::Persistent::New")) return NULL; |
| 654 LOG_API(isolate, "Persistent::New"); | 660 LOG_API(isolate, "Persistent::New"); |
| 655 i::Handle<i::Object> result = isolate->global_handles()->Create(*obj); | 661 i::Handle<i::Object> result = isolate->global_handles()->Create(*obj); |
| 656 #ifdef DEBUG | 662 #ifdef DEBUG |
| 657 (*obj)->Verify(); | 663 (*obj)->Verify(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 | 705 |
| 700 Local<Value> V8::GetEternal(Isolate* v8_isolate, int index) { | 706 Local<Value> V8::GetEternal(Isolate* v8_isolate, int index) { |
| 701 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 707 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
| 702 return Utils::ToLocal(isolate->eternal_handles()->Get(index)); | 708 return Utils::ToLocal(isolate->eternal_handles()->Get(index)); |
| 703 } | 709 } |
| 704 | 710 |
| 705 | 711 |
| 706 // --- H a n d l e s --- | 712 // --- H a n d l e s --- |
| 707 | 713 |
| 708 | 714 |
| 709 HandleScope::HandleScope() { | |
| 710 Initialize(reinterpret_cast<Isolate*>(i::Isolate::Current())); | |
| 711 } | |
| 712 | |
| 713 | |
| 714 HandleScope::HandleScope(Isolate* isolate) { | 715 HandleScope::HandleScope(Isolate* isolate) { |
| 715 Initialize(isolate); | 716 Initialize(isolate); |
| 716 } | 717 } |
| 717 | 718 |
| 718 | 719 |
| 719 void HandleScope::Initialize(Isolate* isolate) { | 720 void HandleScope::Initialize(Isolate* isolate) { |
| 720 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); | 721 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 721 API_ENTRY_CHECK(internal_isolate, "HandleScope::HandleScope"); | 722 API_ENTRY_CHECK(internal_isolate, "HandleScope::HandleScope"); |
| 722 v8::ImplementationUtilities::HandleScopeData* current = | 723 v8::ImplementationUtilities::HandleScopeData* current = |
| 723 internal_isolate->handle_scope_data(); | 724 internal_isolate->handle_scope_data(); |
| (...skipping 2256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2980 | 2981 |
| 2981 void v8::ArrayBuffer::CheckCast(Value* that) { | 2982 void v8::ArrayBuffer::CheckCast(Value* that) { |
| 2982 if (IsDeadCheck(i::Isolate::Current(), "v8::ArrayBuffer::Cast()")) return; | 2983 if (IsDeadCheck(i::Isolate::Current(), "v8::ArrayBuffer::Cast()")) return; |
| 2983 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2984 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
| 2984 ApiCheck(obj->IsJSArrayBuffer(), | 2985 ApiCheck(obj->IsJSArrayBuffer(), |
| 2985 "v8::ArrayBuffer::Cast()", | 2986 "v8::ArrayBuffer::Cast()", |
| 2986 "Could not convert to ArrayBuffer"); | 2987 "Could not convert to ArrayBuffer"); |
| 2987 } | 2988 } |
| 2988 | 2989 |
| 2989 | 2990 |
| 2990 void v8::ArrayBuffer::Allocator::Free(void* data) { | |
| 2991 API_Fatal("v8::ArrayBuffer::Allocator::Free", | |
| 2992 "Override Allocator::Free(void*, size_t)"); | |
| 2993 } | |
| 2994 | |
| 2995 | |
| 2996 void v8::ArrayBufferView::CheckCast(Value* that) { | 2991 void v8::ArrayBufferView::CheckCast(Value* that) { |
| 2997 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2992 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
| 2998 ApiCheck(obj->IsJSArrayBufferView(), | 2993 ApiCheck(obj->IsJSArrayBufferView(), |
| 2999 "v8::ArrayBufferView::Cast()", | 2994 "v8::ArrayBufferView::Cast()", |
| 3000 "Could not convert to ArrayBufferView"); | 2995 "Could not convert to ArrayBufferView"); |
| 3001 } | 2996 } |
| 3002 | 2997 |
| 3003 | 2998 |
| 3004 void v8::TypedArray::CheckCast(Value* that) { | 2999 void v8::TypedArray::CheckCast(Value* that) { |
| 3005 if (IsDeadCheck(i::Isolate::Current(), "v8::TypedArray::Cast()")) return; | 3000 if (IsDeadCheck(i::Isolate::Current(), "v8::TypedArray::Cast()")) return; |
| (...skipping 2195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5201 | 5196 |
| 5202 bool v8::V8::Initialize() { | 5197 bool v8::V8::Initialize() { |
| 5203 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); | 5198 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); |
| 5204 if (isolate != NULL && isolate->IsInitialized()) { | 5199 if (isolate != NULL && isolate->IsInitialized()) { |
| 5205 return true; | 5200 return true; |
| 5206 } | 5201 } |
| 5207 return InitializeHelper(isolate); | 5202 return InitializeHelper(isolate); |
| 5208 } | 5203 } |
| 5209 | 5204 |
| 5210 | 5205 |
| 5211 void v8::V8::SetEntropySource(EntropySource source) { | 5206 void v8::V8::SetEntropySource(EntropySource entropy_source) { |
| 5212 i::V8::SetEntropySource(source); | 5207 i::RandomNumberGenerator::SetEntropySource(entropy_source); |
| 5213 } | 5208 } |
| 5214 | 5209 |
| 5215 | 5210 |
| 5216 void v8::V8::SetReturnAddressLocationResolver( | 5211 void v8::V8::SetReturnAddressLocationResolver( |
| 5217 ReturnAddressLocationResolver return_address_resolver) { | 5212 ReturnAddressLocationResolver return_address_resolver) { |
| 5218 i::V8::SetReturnAddressLocationResolver(return_address_resolver); | 5213 i::V8::SetReturnAddressLocationResolver(return_address_resolver); |
| 5219 } | 5214 } |
| 5220 | 5215 |
| 5221 | 5216 |
| 5222 bool v8::V8::SetFunctionEntryHook(FunctionEntryHook entry_hook) { | 5217 bool v8::V8::SetFunctionEntryHook(FunctionEntryHook entry_hook) { |
| (...skipping 2669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7892 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7887 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 7893 Address callback_address = | 7888 Address callback_address = |
| 7894 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7889 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 7895 VMState<EXTERNAL> state(isolate); | 7890 VMState<EXTERNAL> state(isolate); |
| 7896 ExternalCallbackScope call_scope(isolate, callback_address); | 7891 ExternalCallbackScope call_scope(isolate, callback_address); |
| 7897 callback(info); | 7892 callback(info); |
| 7898 } | 7893 } |
| 7899 | 7894 |
| 7900 | 7895 |
| 7901 } } // namespace v8::internal | 7896 } } // namespace v8::internal |
| OLD | NEW |