| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 #include "snapshot.h" | 46 #include "snapshot.h" |
| 47 #include "v8threads.h" | 47 #include "v8threads.h" |
| 48 #include "version.h" | 48 #include "version.h" |
| 49 #include "vm-state-inl.h" | 49 #include "vm-state-inl.h" |
| 50 | 50 |
| 51 #include "../include/v8-profiler.h" | 51 #include "../include/v8-profiler.h" |
| 52 #include "../include/v8-testing.h" | 52 #include "../include/v8-testing.h" |
| 53 | 53 |
| 54 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) | 54 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) |
| 55 | 55 |
| 56 // TODO(isolates): avoid repeated TLS reads in function prologues. | |
| 57 #ifdef ENABLE_VMSTATE_TRACKING | 56 #ifdef ENABLE_VMSTATE_TRACKING |
| 58 #define ENTER_V8(isolate) \ | 57 #define ENTER_V8(isolate) \ |
| 59 ASSERT((isolate)->IsInitialized()); \ | 58 ASSERT((isolate)->IsInitialized()); \ |
| 60 i::VMState __state__((isolate), i::OTHER) | 59 i::VMState __state__((isolate), i::OTHER) |
| 61 #define LEAVE_V8(isolate) \ | 60 #define LEAVE_V8(isolate) \ |
| 62 i::VMState __state__((isolate), i::EXTERNAL) | 61 i::VMState __state__((isolate), i::EXTERNAL) |
| 63 #else | 62 #else |
| 64 #define ENTER_V8(isolate) ((void) 0) | 63 #define ENTER_V8(isolate) ((void) 0) |
| 65 #define LEAVE_V8(isolate) ((void) 0) | 64 #define LEAVE_V8(isolate) ((void) 0) |
| 66 #endif | 65 #endif |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 return i::V8::Initialize(NULL); | 282 return i::V8::Initialize(NULL); |
| 284 } | 283 } |
| 285 | 284 |
| 286 | 285 |
| 287 static inline bool EnsureInitializedForIsolate(i::Isolate* isolate, | 286 static inline bool EnsureInitializedForIsolate(i::Isolate* isolate, |
| 288 const char* location) { | 287 const char* location) { |
| 289 if (IsDeadCheck(isolate, location)) return false; | 288 if (IsDeadCheck(isolate, location)) return false; |
| 290 if (isolate != NULL) { | 289 if (isolate != NULL) { |
| 291 if (isolate->IsInitialized()) return true; | 290 if (isolate->IsInitialized()) return true; |
| 292 } | 291 } |
| 292 ASSERT(isolate == i::Isolate::Current()); |
| 293 return ApiCheck(InitializeHelper(), location, "Error initializing V8"); | 293 return ApiCheck(InitializeHelper(), location, "Error initializing V8"); |
| 294 } | 294 } |
| 295 | 295 |
| 296 // Some initializing API functions are called early and may be | 296 // Some initializing API functions are called early and may be |
| 297 // called on a thread different from static initializer thread. | 297 // called on a thread different from static initializer thread. |
| 298 // If Isolate API is used, Isolate::Enter() will initialize TLS so | 298 // If Isolate API is used, Isolate::Enter() will initialize TLS so |
| 299 // Isolate::Current() works. If it's a legacy case, then the thread | 299 // Isolate::Current() works. If it's a legacy case, then the thread |
| 300 // may not have TLS initialized yet. However, in initializing APIs it | 300 // may not have TLS initialized yet. However, in initializing APIs it |
| 301 // may be too early to call EnsureInitialized() - some pre-init | 301 // may be too early to call EnsureInitialized() - some pre-init |
| 302 // parameters still have to be configured. | 302 // parameters still have to be configured. |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 } | 532 } |
| 533 | 533 |
| 534 | 534 |
| 535 void V8::ClearWeak(i::Object** obj) { | 535 void V8::ClearWeak(i::Object** obj) { |
| 536 i::Isolate* isolate = i::Isolate::Current(); | 536 i::Isolate* isolate = i::Isolate::Current(); |
| 537 LOG_API(isolate, "ClearWeak"); | 537 LOG_API(isolate, "ClearWeak"); |
| 538 isolate->global_handles()->ClearWeakness(obj); | 538 isolate->global_handles()->ClearWeakness(obj); |
| 539 } | 539 } |
| 540 | 540 |
| 541 | 541 |
| 542 void V8::MarkIndependent(i::Object** object) { |
| 543 i::Isolate* isolate = i::Isolate::Current(); |
| 544 LOG_API(isolate, "MakeIndependent"); |
| 545 isolate->global_handles()->MarkIndependent(object); |
| 546 } |
| 547 |
| 548 |
| 542 bool V8::IsGlobalNearDeath(i::Object** obj) { | 549 bool V8::IsGlobalNearDeath(i::Object** obj) { |
| 543 i::Isolate* isolate = i::Isolate::Current(); | 550 i::Isolate* isolate = i::Isolate::Current(); |
| 544 LOG_API(isolate, "IsGlobalNearDeath"); | 551 LOG_API(isolate, "IsGlobalNearDeath"); |
| 545 if (!isolate->IsInitialized()) return false; | 552 if (!isolate->IsInitialized()) return false; |
| 546 return i::GlobalHandles::IsNearDeath(obj); | 553 return i::GlobalHandles::IsNearDeath(obj); |
| 547 } | 554 } |
| 548 | 555 |
| 549 | 556 |
| 550 bool V8::IsGlobalWeak(i::Object** obj) { | 557 bool V8::IsGlobalWeak(i::Object** obj) { |
| 551 i::Isolate* isolate = i::Isolate::Current(); | 558 i::Isolate* isolate = i::Isolate::Current(); |
| (...skipping 2696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3248 "v8::GetIndexedPropertiesExternalArrayDataLength()", | 3255 "v8::GetIndexedPropertiesExternalArrayDataLength()", |
| 3249 return 0); | 3256 return 0); |
| 3250 if (self->HasExternalArrayElements()) { | 3257 if (self->HasExternalArrayElements()) { |
| 3251 return i::ExternalArray::cast(self->elements())->length(); | 3258 return i::ExternalArray::cast(self->elements())->length(); |
| 3252 } else { | 3259 } else { |
| 3253 return -1; | 3260 return -1; |
| 3254 } | 3261 } |
| 3255 } | 3262 } |
| 3256 | 3263 |
| 3257 | 3264 |
| 3265 bool v8::Object::IsCallable() { |
| 3266 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3267 ON_BAILOUT(isolate, "v8::Object::IsCallable()", return false); |
| 3268 ENTER_V8(isolate); |
| 3269 i::HandleScope scope(isolate); |
| 3270 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
| 3271 if (obj->IsJSFunction()) return true; |
| 3272 return i::Execution::GetFunctionDelegate(obj)->IsJSFunction(); |
| 3273 } |
| 3274 |
| 3275 |
| 3258 Local<v8::Value> Object::CallAsFunction(v8::Handle<v8::Object> recv, int argc, | 3276 Local<v8::Value> Object::CallAsFunction(v8::Handle<v8::Object> recv, int argc, |
| 3259 v8::Handle<v8::Value> argv[]) { | 3277 v8::Handle<v8::Value> argv[]) { |
| 3260 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3278 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3261 ON_BAILOUT(isolate, "v8::Object::CallAsFunction()", | 3279 ON_BAILOUT(isolate, "v8::Object::CallAsFunction()", |
| 3262 return Local<v8::Value>()); | 3280 return Local<v8::Value>()); |
| 3263 LOG_API(isolate, "Object::CallAsFunction"); | 3281 LOG_API(isolate, "Object::CallAsFunction"); |
| 3264 ENTER_V8(isolate); | 3282 ENTER_V8(isolate); |
| 3265 HandleScope scope; | 3283 i::HandleScope scope(isolate); |
| 3266 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 3284 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
| 3267 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); | 3285 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); |
| 3268 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); | 3286 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); |
| 3269 i::Object*** args = reinterpret_cast<i::Object***>(argv); | 3287 i::Object*** args = reinterpret_cast<i::Object***>(argv); |
| 3270 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>(); | 3288 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>(); |
| 3271 if (obj->IsJSFunction()) { | 3289 if (obj->IsJSFunction()) { |
| 3272 fun = i::Handle<i::JSFunction>::cast(obj); | 3290 fun = i::Handle<i::JSFunction>::cast(obj); |
| 3273 } else { | 3291 } else { |
| 3274 EXCEPTION_PREAMBLE(isolate); | 3292 EXCEPTION_PREAMBLE(isolate); |
| 3275 i::Handle<i::Object> delegate = | 3293 i::Handle<i::Object> delegate = |
| 3276 i::Execution::TryGetFunctionDelegate(obj, &has_pending_exception); | 3294 i::Execution::TryGetFunctionDelegate(obj, &has_pending_exception); |
| 3277 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); | 3295 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); |
| 3278 fun = i::Handle<i::JSFunction>::cast(delegate); | 3296 fun = i::Handle<i::JSFunction>::cast(delegate); |
| 3279 recv_obj = obj; | 3297 recv_obj = obj; |
| 3280 } | 3298 } |
| 3281 EXCEPTION_PREAMBLE(isolate); | 3299 EXCEPTION_PREAMBLE(isolate); |
| 3282 i::Handle<i::Object> returned = | 3300 i::Handle<i::Object> returned = |
| 3283 i::Execution::Call(fun, recv_obj, argc, args, &has_pending_exception); | 3301 i::Execution::Call(fun, recv_obj, argc, args, &has_pending_exception); |
| 3284 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); | 3302 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); |
| 3285 return scope.Close(Utils::ToLocal(returned)); | 3303 return Utils::ToLocal(scope.CloseAndEscape(returned)); |
| 3304 } |
| 3305 |
| 3306 |
| 3307 Local<v8::Value> Object::CallAsConstructor(int argc, |
| 3308 v8::Handle<v8::Value> argv[]) { |
| 3309 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3310 ON_BAILOUT(isolate, "v8::Object::CallAsConstructor()", |
| 3311 return Local<v8::Object>()); |
| 3312 LOG_API(isolate, "Object::CallAsConstructor"); |
| 3313 ENTER_V8(isolate); |
| 3314 i::HandleScope scope(isolate); |
| 3315 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
| 3316 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); |
| 3317 i::Object*** args = reinterpret_cast<i::Object***>(argv); |
| 3318 if (obj->IsJSFunction()) { |
| 3319 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(obj); |
| 3320 EXCEPTION_PREAMBLE(isolate); |
| 3321 i::Handle<i::Object> returned = |
| 3322 i::Execution::New(fun, argc, args, &has_pending_exception); |
| 3323 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>()); |
| 3324 return Utils::ToLocal(scope.CloseAndEscape( |
| 3325 i::Handle<i::JSObject>::cast(returned))); |
| 3326 } |
| 3327 EXCEPTION_PREAMBLE(isolate); |
| 3328 i::Handle<i::Object> delegate = |
| 3329 i::Execution::TryGetConstructorDelegate(obj, &has_pending_exception); |
| 3330 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>()); |
| 3331 if (!delegate->IsUndefined()) { |
| 3332 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(delegate); |
| 3333 EXCEPTION_PREAMBLE(isolate); |
| 3334 i::Handle<i::Object> returned = |
| 3335 i::Execution::Call(fun, obj, argc, args, &has_pending_exception); |
| 3336 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>()); |
| 3337 ASSERT(!delegate->IsUndefined()); |
| 3338 return Utils::ToLocal(scope.CloseAndEscape(returned)); |
| 3339 } |
| 3340 return Local<v8::Object>(); |
| 3286 } | 3341 } |
| 3287 | 3342 |
| 3288 | 3343 |
| 3289 Local<v8::Object> Function::NewInstance() const { | 3344 Local<v8::Object> Function::NewInstance() const { |
| 3290 return NewInstance(0, NULL); | 3345 return NewInstance(0, NULL); |
| 3291 } | 3346 } |
| 3292 | 3347 |
| 3293 | 3348 |
| 3294 Local<v8::Object> Function::NewInstance(int argc, | 3349 Local<v8::Object> Function::NewInstance(int argc, |
| 3295 v8::Handle<v8::Value> argv[]) const { | 3350 v8::Handle<v8::Value> argv[]) const { |
| (...skipping 1512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4808 isolate->Enter(); | 4863 isolate->Enter(); |
| 4809 } | 4864 } |
| 4810 | 4865 |
| 4811 | 4866 |
| 4812 void Isolate::Exit() { | 4867 void Isolate::Exit() { |
| 4813 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 4868 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
| 4814 isolate->Exit(); | 4869 isolate->Exit(); |
| 4815 } | 4870 } |
| 4816 | 4871 |
| 4817 | 4872 |
| 4818 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) { | 4873 void Isolate::SetData(void* data) { |
| 4874 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
| 4875 isolate->SetData(data); |
| 4876 } |
| 4877 |
| 4878 void* Isolate::GetData() { |
| 4879 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
| 4880 return isolate->GetData(); |
| 4881 } |
| 4882 |
| 4883 |
| 4884 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) |
| 4885 : str_(NULL), length_(0) { |
| 4819 i::Isolate* isolate = i::Isolate::Current(); | 4886 i::Isolate* isolate = i::Isolate::Current(); |
| 4820 if (IsDeadCheck(isolate, "v8::String::Utf8Value::Utf8Value()")) return; | 4887 if (IsDeadCheck(isolate, "v8::String::Utf8Value::Utf8Value()")) return; |
| 4821 if (obj.IsEmpty()) { | 4888 if (obj.IsEmpty()) return; |
| 4822 str_ = NULL; | |
| 4823 length_ = 0; | |
| 4824 return; | |
| 4825 } | |
| 4826 ENTER_V8(isolate); | 4889 ENTER_V8(isolate); |
| 4827 i::HandleScope scope(isolate); | 4890 i::HandleScope scope(isolate); |
| 4828 TryCatch try_catch; | 4891 TryCatch try_catch; |
| 4829 Handle<String> str = obj->ToString(); | 4892 Handle<String> str = obj->ToString(); |
| 4830 if (str.IsEmpty()) { | 4893 if (str.IsEmpty()) return; |
| 4831 str_ = NULL; | 4894 length_ = str->Utf8Length(); |
| 4832 length_ = 0; | 4895 str_ = i::NewArray<char>(length_ + 1); |
| 4833 } else { | 4896 str->WriteUtf8(str_); |
| 4834 length_ = str->Utf8Length(); | |
| 4835 str_ = i::NewArray<char>(length_ + 1); | |
| 4836 str->WriteUtf8(str_); | |
| 4837 } | |
| 4838 } | 4897 } |
| 4839 | 4898 |
| 4840 | 4899 |
| 4841 String::Utf8Value::~Utf8Value() { | 4900 String::Utf8Value::~Utf8Value() { |
| 4842 i::DeleteArray(str_); | 4901 i::DeleteArray(str_); |
| 4843 } | 4902 } |
| 4844 | 4903 |
| 4845 | 4904 |
| 4846 String::AsciiValue::AsciiValue(v8::Handle<v8::Value> obj) { | 4905 String::AsciiValue::AsciiValue(v8::Handle<v8::Value> obj) |
| 4906 : str_(NULL), length_(0) { |
| 4847 i::Isolate* isolate = i::Isolate::Current(); | 4907 i::Isolate* isolate = i::Isolate::Current(); |
| 4848 if (IsDeadCheck(isolate, "v8::String::AsciiValue::AsciiValue()")) return; | 4908 if (IsDeadCheck(isolate, "v8::String::AsciiValue::AsciiValue()")) return; |
| 4849 if (obj.IsEmpty()) { | 4909 if (obj.IsEmpty()) return; |
| 4850 str_ = NULL; | |
| 4851 length_ = 0; | |
| 4852 return; | |
| 4853 } | |
| 4854 ENTER_V8(isolate); | 4910 ENTER_V8(isolate); |
| 4855 i::HandleScope scope(isolate); | 4911 i::HandleScope scope(isolate); |
| 4856 TryCatch try_catch; | 4912 TryCatch try_catch; |
| 4857 Handle<String> str = obj->ToString(); | 4913 Handle<String> str = obj->ToString(); |
| 4858 if (str.IsEmpty()) { | 4914 if (str.IsEmpty()) return; |
| 4859 str_ = NULL; | 4915 length_ = str->Length(); |
| 4860 length_ = 0; | 4916 str_ = i::NewArray<char>(length_ + 1); |
| 4861 } else { | 4917 str->WriteAscii(str_); |
| 4862 length_ = str->Length(); | |
| 4863 str_ = i::NewArray<char>(length_ + 1); | |
| 4864 str->WriteAscii(str_); | |
| 4865 } | |
| 4866 } | 4918 } |
| 4867 | 4919 |
| 4868 | 4920 |
| 4869 String::AsciiValue::~AsciiValue() { | 4921 String::AsciiValue::~AsciiValue() { |
| 4870 i::DeleteArray(str_); | 4922 i::DeleteArray(str_); |
| 4871 } | 4923 } |
| 4872 | 4924 |
| 4873 | 4925 |
| 4874 String::Value::Value(v8::Handle<v8::Value> obj) { | 4926 String::Value::Value(v8::Handle<v8::Value> obj) |
| 4927 : str_(NULL), length_(0) { |
| 4875 i::Isolate* isolate = i::Isolate::Current(); | 4928 i::Isolate* isolate = i::Isolate::Current(); |
| 4876 if (IsDeadCheck(isolate, "v8::String::Value::Value()")) return; | 4929 if (IsDeadCheck(isolate, "v8::String::Value::Value()")) return; |
| 4877 if (obj.IsEmpty()) { | 4930 if (obj.IsEmpty()) return; |
| 4878 str_ = NULL; | |
| 4879 length_ = 0; | |
| 4880 return; | |
| 4881 } | |
| 4882 ENTER_V8(isolate); | 4931 ENTER_V8(isolate); |
| 4883 i::HandleScope scope(isolate); | 4932 i::HandleScope scope(isolate); |
| 4884 TryCatch try_catch; | 4933 TryCatch try_catch; |
| 4885 Handle<String> str = obj->ToString(); | 4934 Handle<String> str = obj->ToString(); |
| 4886 if (str.IsEmpty()) { | 4935 if (str.IsEmpty()) return; |
| 4887 str_ = NULL; | 4936 length_ = str->Length(); |
| 4888 length_ = 0; | 4937 str_ = i::NewArray<uint16_t>(length_ + 1); |
| 4889 } else { | 4938 str->Write(str_); |
| 4890 length_ = str->Length(); | |
| 4891 str_ = i::NewArray<uint16_t>(length_ + 1); | |
| 4892 str->Write(str_); | |
| 4893 } | |
| 4894 } | 4939 } |
| 4895 | 4940 |
| 4896 | 4941 |
| 4897 String::Value::~Value() { | 4942 String::Value::~Value() { |
| 4898 i::DeleteArray(str_); | 4943 i::DeleteArray(str_); |
| 4899 } | 4944 } |
| 4900 | 4945 |
| 4901 Local<Value> Exception::RangeError(v8::Handle<v8::String> raw_message) { | 4946 Local<Value> Exception::RangeError(v8::Handle<v8::String> raw_message) { |
| 4902 i::Isolate* isolate = i::Isolate::Current(); | 4947 i::Isolate* isolate = i::Isolate::Current(); |
| 4903 LOG_API(isolate, "RangeError"); | 4948 LOG_API(isolate, "RangeError"); |
| (...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5732 | 5777 |
| 5733 namespace internal { | 5778 namespace internal { |
| 5734 | 5779 |
| 5735 | 5780 |
| 5736 void HandleScopeImplementer::FreeThreadResources() { | 5781 void HandleScopeImplementer::FreeThreadResources() { |
| 5737 Free(); | 5782 Free(); |
| 5738 } | 5783 } |
| 5739 | 5784 |
| 5740 | 5785 |
| 5741 char* HandleScopeImplementer::ArchiveThread(char* storage) { | 5786 char* HandleScopeImplementer::ArchiveThread(char* storage) { |
| 5742 Isolate* isolate = Isolate::Current(); | |
| 5743 v8::ImplementationUtilities::HandleScopeData* current = | 5787 v8::ImplementationUtilities::HandleScopeData* current = |
| 5744 isolate->handle_scope_data(); | 5788 isolate_->handle_scope_data(); |
| 5745 handle_scope_data_ = *current; | 5789 handle_scope_data_ = *current; |
| 5746 memcpy(storage, this, sizeof(*this)); | 5790 memcpy(storage, this, sizeof(*this)); |
| 5747 | 5791 |
| 5748 ResetAfterArchive(); | 5792 ResetAfterArchive(); |
| 5749 current->Initialize(); | 5793 current->Initialize(); |
| 5750 | 5794 |
| 5751 return storage + ArchiveSpacePerThread(); | 5795 return storage + ArchiveSpacePerThread(); |
| 5752 } | 5796 } |
| 5753 | 5797 |
| 5754 | 5798 |
| 5755 int HandleScopeImplementer::ArchiveSpacePerThread() { | 5799 int HandleScopeImplementer::ArchiveSpacePerThread() { |
| 5756 return sizeof(HandleScopeImplementer); | 5800 return sizeof(HandleScopeImplementer); |
| 5757 } | 5801 } |
| 5758 | 5802 |
| 5759 | 5803 |
| 5760 char* HandleScopeImplementer::RestoreThread(char* storage) { | 5804 char* HandleScopeImplementer::RestoreThread(char* storage) { |
| 5761 memcpy(this, storage, sizeof(*this)); | 5805 memcpy(this, storage, sizeof(*this)); |
| 5762 *Isolate::Current()->handle_scope_data() = handle_scope_data_; | 5806 *isolate_->handle_scope_data() = handle_scope_data_; |
| 5763 return storage + ArchiveSpacePerThread(); | 5807 return storage + ArchiveSpacePerThread(); |
| 5764 } | 5808 } |
| 5765 | 5809 |
| 5766 | 5810 |
| 5767 void HandleScopeImplementer::IterateThis(ObjectVisitor* v) { | 5811 void HandleScopeImplementer::IterateThis(ObjectVisitor* v) { |
| 5768 // Iterate over all handles in the blocks except for the last. | 5812 // Iterate over all handles in the blocks except for the last. |
| 5769 for (int i = blocks()->length() - 2; i >= 0; --i) { | 5813 for (int i = blocks()->length() - 2; i >= 0; --i) { |
| 5770 Object** block = blocks()->at(i); | 5814 Object** block = blocks()->at(i); |
| 5771 v->VisitPointers(block, &block[kHandleBlockSize]); | 5815 v->VisitPointers(block, &block[kHandleBlockSize]); |
| 5772 } | 5816 } |
| 5773 | 5817 |
| 5774 // Iterate over live handles in the last block (if any). | 5818 // Iterate over live handles in the last block (if any). |
| 5775 if (!blocks()->is_empty()) { | 5819 if (!blocks()->is_empty()) { |
| 5776 v->VisitPointers(blocks()->last(), handle_scope_data_.next); | 5820 v->VisitPointers(blocks()->last(), handle_scope_data_.next); |
| 5777 } | 5821 } |
| 5778 | 5822 |
| 5779 if (!saved_contexts_.is_empty()) { | 5823 if (!saved_contexts_.is_empty()) { |
| 5780 Object** start = reinterpret_cast<Object**>(&saved_contexts_.first()); | 5824 Object** start = reinterpret_cast<Object**>(&saved_contexts_.first()); |
| 5781 v->VisitPointers(start, start + saved_contexts_.length()); | 5825 v->VisitPointers(start, start + saved_contexts_.length()); |
| 5782 } | 5826 } |
| 5783 } | 5827 } |
| 5784 | 5828 |
| 5785 | 5829 |
| 5786 void HandleScopeImplementer::Iterate(ObjectVisitor* v) { | 5830 void HandleScopeImplementer::Iterate(ObjectVisitor* v) { |
| 5787 v8::ImplementationUtilities::HandleScopeData* current = | 5831 v8::ImplementationUtilities::HandleScopeData* current = |
| 5788 Isolate::Current()->handle_scope_data(); | 5832 isolate_->handle_scope_data(); |
| 5789 handle_scope_data_ = *current; | 5833 handle_scope_data_ = *current; |
| 5790 IterateThis(v); | 5834 IterateThis(v); |
| 5791 } | 5835 } |
| 5792 | 5836 |
| 5793 | 5837 |
| 5794 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 5838 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
| 5795 HandleScopeImplementer* scope_implementer = | 5839 HandleScopeImplementer* scope_implementer = |
| 5796 reinterpret_cast<HandleScopeImplementer*>(storage); | 5840 reinterpret_cast<HandleScopeImplementer*>(storage); |
| 5797 scope_implementer->IterateThis(v); | 5841 scope_implementer->IterateThis(v); |
| 5798 return storage + ArchiveSpacePerThread(); | 5842 return storage + ArchiveSpacePerThread(); |
| 5799 } | 5843 } |
| 5800 | 5844 |
| 5801 } } // namespace v8::internal | 5845 } } // namespace v8::internal |
| OLD | NEW |