| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 | 337 |
| 338 v8::Handle<Value> ThrowException(v8::Handle<v8::Value> value) { | 338 v8::Handle<Value> ThrowException(v8::Handle<v8::Value> value) { |
| 339 i::Isolate* isolate = i::Isolate::Current(); | 339 i::Isolate* isolate = i::Isolate::Current(); |
| 340 if (IsDeadCheck(isolate, "v8::ThrowException()")) { | 340 if (IsDeadCheck(isolate, "v8::ThrowException()")) { |
| 341 return v8::Handle<Value>(); | 341 return v8::Handle<Value>(); |
| 342 } | 342 } |
| 343 ENTER_V8(isolate); | 343 ENTER_V8(isolate); |
| 344 // If we're passed an empty handle, we throw an undefined exception | 344 // If we're passed an empty handle, we throw an undefined exception |
| 345 // to deal more gracefully with out of memory situations. | 345 // to deal more gracefully with out of memory situations. |
| 346 if (value.IsEmpty()) { | 346 if (value.IsEmpty()) { |
| 347 isolate->ScheduleThrow(HEAP->undefined_value()); | 347 isolate->ScheduleThrow(isolate->heap()->undefined_value()); |
| 348 } else { | 348 } else { |
| 349 isolate->ScheduleThrow(*Utils::OpenHandle(*value)); | 349 isolate->ScheduleThrow(*Utils::OpenHandle(*value)); |
| 350 } | 350 } |
| 351 return v8::Undefined(); | 351 return v8::Undefined(); |
| 352 } | 352 } |
| 353 | 353 |
| 354 | 354 |
| 355 RegisteredExtension* RegisteredExtension::first_extension_ = NULL; | 355 RegisteredExtension* RegisteredExtension::first_extension_ = NULL; |
| 356 | 356 |
| 357 | 357 |
| (...skipping 1653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2011 if (obj->IsSmi()) return i::Smi::cast(*obj)->value() >= 0; | 2011 if (obj->IsSmi()) return i::Smi::cast(*obj)->value() >= 0; |
| 2012 if (obj->IsNumber()) { | 2012 if (obj->IsNumber()) { |
| 2013 double value = obj->Number(); | 2013 double value = obj->Number(); |
| 2014 return i::FastUI2D(i::FastD2UI(value)) == value; | 2014 return i::FastUI2D(i::FastD2UI(value)) == value; |
| 2015 } | 2015 } |
| 2016 return false; | 2016 return false; |
| 2017 } | 2017 } |
| 2018 | 2018 |
| 2019 | 2019 |
| 2020 bool Value::IsDate() const { | 2020 bool Value::IsDate() const { |
| 2021 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsDate()")) return false; | 2021 i::Isolate* isolate = i::Isolate::Current(); |
| 2022 if (IsDeadCheck(isolate, "v8::Value::IsDate()")) return false; |
| 2022 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2023 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 2023 return obj->HasSpecificClassOf(HEAP->Date_symbol()); | 2024 return obj->HasSpecificClassOf(isolate->heap()->Date_symbol()); |
| 2024 } | 2025 } |
| 2025 | 2026 |
| 2026 | 2027 |
| 2027 bool Value::IsRegExp() const { | 2028 bool Value::IsRegExp() const { |
| 2028 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsRegExp()")) return false; | 2029 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsRegExp()")) return false; |
| 2029 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2030 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 2030 return obj->IsJSRegExp(); | 2031 return obj->IsJSRegExp(); |
| 2031 } | 2032 } |
| 2032 | 2033 |
| 2033 | 2034 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2203 void v8::Array::CheckCast(Value* that) { | 2204 void v8::Array::CheckCast(Value* that) { |
| 2204 if (IsDeadCheck(i::Isolate::Current(), "v8::Array::Cast()")) return; | 2205 if (IsDeadCheck(i::Isolate::Current(), "v8::Array::Cast()")) return; |
| 2205 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2206 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
| 2206 ApiCheck(obj->IsJSArray(), | 2207 ApiCheck(obj->IsJSArray(), |
| 2207 "v8::Array::Cast()", | 2208 "v8::Array::Cast()", |
| 2208 "Could not convert to array"); | 2209 "Could not convert to array"); |
| 2209 } | 2210 } |
| 2210 | 2211 |
| 2211 | 2212 |
| 2212 void v8::Date::CheckCast(v8::Value* that) { | 2213 void v8::Date::CheckCast(v8::Value* that) { |
| 2213 if (IsDeadCheck(i::Isolate::Current(), "v8::Date::Cast()")) return; | 2214 i::Isolate* isolate = i::Isolate::Current(); |
| 2215 if (IsDeadCheck(isolate, "v8::Date::Cast()")) return; |
| 2214 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2216 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
| 2215 ApiCheck(obj->HasSpecificClassOf(HEAP->Date_symbol()), | 2217 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Date_symbol()), |
| 2216 "v8::Date::Cast()", | 2218 "v8::Date::Cast()", |
| 2217 "Could not convert to date"); | 2219 "Could not convert to date"); |
| 2218 } | 2220 } |
| 2219 | 2221 |
| 2220 | 2222 |
| 2221 void v8::RegExp::CheckCast(v8::Value* that) { | 2223 void v8::RegExp::CheckCast(v8::Value* that) { |
| 2222 if (IsDeadCheck(i::Isolate::Current(), "v8::RegExp::Cast()")) return; | 2224 if (IsDeadCheck(i::Isolate::Current(), "v8::RegExp::Cast()")) return; |
| 2223 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 2225 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
| 2224 ApiCheck(obj->IsJSRegExp(), | 2226 ApiCheck(obj->IsJSRegExp(), |
| 2225 "v8::RegExp::Cast()", | 2227 "v8::RegExp::Cast()", |
| (...skipping 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3570 } | 3572 } |
| 3571 | 3573 |
| 3572 | 3574 |
| 3573 HeapStatistics::HeapStatistics(): total_heap_size_(0), | 3575 HeapStatistics::HeapStatistics(): total_heap_size_(0), |
| 3574 total_heap_size_executable_(0), | 3576 total_heap_size_executable_(0), |
| 3575 used_heap_size_(0), | 3577 used_heap_size_(0), |
| 3576 heap_size_limit_(0) { } | 3578 heap_size_limit_(0) { } |
| 3577 | 3579 |
| 3578 | 3580 |
| 3579 void v8::V8::GetHeapStatistics(HeapStatistics* heap_statistics) { | 3581 void v8::V8::GetHeapStatistics(HeapStatistics* heap_statistics) { |
| 3580 heap_statistics->set_total_heap_size(HEAP->CommittedMemory()); | 3582 i::Heap* heap = i::Isolate::Current()->heap(); |
| 3583 heap_statistics->set_total_heap_size(heap->CommittedMemory()); |
| 3581 heap_statistics->set_total_heap_size_executable( | 3584 heap_statistics->set_total_heap_size_executable( |
| 3582 HEAP->CommittedMemoryExecutable()); | 3585 heap->CommittedMemoryExecutable()); |
| 3583 heap_statistics->set_used_heap_size(HEAP->SizeOfObjects()); | 3586 heap_statistics->set_used_heap_size(heap->SizeOfObjects()); |
| 3584 heap_statistics->set_heap_size_limit(HEAP->MaxReserved()); | 3587 heap_statistics->set_heap_size_limit(heap->MaxReserved()); |
| 3585 } | 3588 } |
| 3586 | 3589 |
| 3587 | 3590 |
| 3588 bool v8::V8::IdleNotification() { | 3591 bool v8::V8::IdleNotification() { |
| 3589 // Returning true tells the caller that it need not | 3592 // Returning true tells the caller that it need not |
| 3590 // continue to call IdleNotification. | 3593 // continue to call IdleNotification. |
| 3591 if (!i::Isolate::Current()->IsInitialized()) return true; | 3594 if (!i::Isolate::Current()->IsInitialized()) return true; |
| 3592 return i::V8::IdleNotification(); | 3595 return i::V8::IdleNotification(); |
| 3593 } | 3596 } |
| 3594 | 3597 |
| 3595 | 3598 |
| 3596 void v8::V8::LowMemoryNotification() { | 3599 void v8::V8::LowMemoryNotification() { |
| 3597 if (!i::Isolate::Current()->IsInitialized()) return; | 3600 i::Isolate* isolate = i::Isolate::Current(); |
| 3598 HEAP->CollectAllGarbage(true); | 3601 if (!isolate->IsInitialized()) return; |
| 3602 isolate->heap()->CollectAllGarbage(true); |
| 3599 } | 3603 } |
| 3600 | 3604 |
| 3601 | 3605 |
| 3602 int v8::V8::ContextDisposedNotification() { | 3606 int v8::V8::ContextDisposedNotification() { |
| 3603 if (!i::Isolate::Current()->IsInitialized()) return 0; | 3607 i::Isolate* isolate = i::Isolate::Current(); |
| 3604 return HEAP->NotifyContextDisposed(); | 3608 if (!isolate->IsInitialized()) return 0; |
| 3609 return isolate->heap()->NotifyContextDisposed(); |
| 3605 } | 3610 } |
| 3606 | 3611 |
| 3607 | 3612 |
| 3608 const char* v8::V8::GetVersion() { | 3613 const char* v8::V8::GetVersion() { |
| 3609 return i::Version::GetVersion(); | 3614 return i::Version::GetVersion(); |
| 3610 } | 3615 } |
| 3611 | 3616 |
| 3612 | 3617 |
| 3613 static i::Handle<i::FunctionTemplateInfo> | 3618 static i::Handle<i::FunctionTemplateInfo> |
| 3614 EnsureConstructor(i::Handle<i::ObjectTemplateInfo> templ) { | 3619 EnsureConstructor(i::Handle<i::ObjectTemplateInfo> templ) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3656 | 3661 |
| 3657 // Migrate security handlers from global_template to | 3662 // Migrate security handlers from global_template to |
| 3658 // proxy_template. Temporarily removing access check | 3663 // proxy_template. Temporarily removing access check |
| 3659 // information from the global template. | 3664 // information from the global template. |
| 3660 if (!global_constructor->access_check_info()->IsUndefined()) { | 3665 if (!global_constructor->access_check_info()->IsUndefined()) { |
| 3661 proxy_constructor->set_access_check_info( | 3666 proxy_constructor->set_access_check_info( |
| 3662 global_constructor->access_check_info()); | 3667 global_constructor->access_check_info()); |
| 3663 proxy_constructor->set_needs_access_check( | 3668 proxy_constructor->set_needs_access_check( |
| 3664 global_constructor->needs_access_check()); | 3669 global_constructor->needs_access_check()); |
| 3665 global_constructor->set_needs_access_check(false); | 3670 global_constructor->set_needs_access_check(false); |
| 3666 global_constructor->set_access_check_info(HEAP->undefined_value()); | 3671 global_constructor->set_access_check_info( |
| 3672 isolate->heap()->undefined_value()); |
| 3667 } | 3673 } |
| 3668 } | 3674 } |
| 3669 | 3675 |
| 3670 // Create the environment. | 3676 // Create the environment. |
| 3671 env = isolate->bootstrapper()->CreateEnvironment( | 3677 env = isolate->bootstrapper()->CreateEnvironment( |
| 3672 Utils::OpenHandle(*global_object), | 3678 Utils::OpenHandle(*global_object), |
| 3673 proxy_template, | 3679 proxy_template, |
| 3674 extensions); | 3680 extensions); |
| 3675 | 3681 |
| 3676 // Restore the access check info on the global template. | 3682 // Restore the access check info on the global template. |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4337 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) { | 4343 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) { |
| 4338 i::Isolate* isolate = i::Isolate::Current(); | 4344 i::Isolate* isolate = i::Isolate::Current(); |
| 4339 EnsureInitializedForIsolate(isolate, "v8::V8::AddMessageListener()"); | 4345 EnsureInitializedForIsolate(isolate, "v8::V8::AddMessageListener()"); |
| 4340 ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false); | 4346 ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false); |
| 4341 ENTER_V8(isolate); | 4347 ENTER_V8(isolate); |
| 4342 i::HandleScope scope(isolate); | 4348 i::HandleScope scope(isolate); |
| 4343 NeanderArray listeners(isolate->factory()->message_listeners()); | 4349 NeanderArray listeners(isolate->factory()->message_listeners()); |
| 4344 NeanderObject obj(2); | 4350 NeanderObject obj(2); |
| 4345 obj.set(0, *isolate->factory()->NewProxy(FUNCTION_ADDR(that))); | 4351 obj.set(0, *isolate->factory()->NewProxy(FUNCTION_ADDR(that))); |
| 4346 obj.set(1, data.IsEmpty() ? | 4352 obj.set(1, data.IsEmpty() ? |
| 4347 HEAP->undefined_value() : | 4353 isolate->heap()->undefined_value() : |
| 4348 *Utils::OpenHandle(*data)); | 4354 *Utils::OpenHandle(*data)); |
| 4349 listeners.add(obj.value()); | 4355 listeners.add(obj.value()); |
| 4350 return true; | 4356 return true; |
| 4351 } | 4357 } |
| 4352 | 4358 |
| 4353 | 4359 |
| 4354 void V8::RemoveMessageListeners(MessageCallback that) { | 4360 void V8::RemoveMessageListeners(MessageCallback that) { |
| 4355 i::Isolate* isolate = i::Isolate::Current(); | 4361 i::Isolate* isolate = i::Isolate::Current(); |
| 4356 EnsureInitializedForIsolate(isolate, "v8::V8::RemoveMessageListener()"); | 4362 EnsureInitializedForIsolate(isolate, "v8::V8::RemoveMessageListener()"); |
| 4357 ON_BAILOUT(isolate, "v8::V8::RemoveMessageListeners()", return); | 4363 ON_BAILOUT(isolate, "v8::V8::RemoveMessageListeners()", return); |
| 4358 ENTER_V8(isolate); | 4364 ENTER_V8(isolate); |
| 4359 i::HandleScope scope(isolate); | 4365 i::HandleScope scope(isolate); |
| 4360 NeanderArray listeners(isolate->factory()->message_listeners()); | 4366 NeanderArray listeners(isolate->factory()->message_listeners()); |
| 4361 for (int i = 0; i < listeners.length(); i++) { | 4367 for (int i = 0; i < listeners.length(); i++) { |
| 4362 if (listeners.get(i)->IsUndefined()) continue; // skip deleted ones | 4368 if (listeners.get(i)->IsUndefined()) continue; // skip deleted ones |
| 4363 | 4369 |
| 4364 NeanderObject listener(i::JSObject::cast(listeners.get(i))); | 4370 NeanderObject listener(i::JSObject::cast(listeners.get(i))); |
| 4365 i::Handle<i::Proxy> callback_obj(i::Proxy::cast(listener.get(0))); | 4371 i::Handle<i::Proxy> callback_obj(i::Proxy::cast(listener.get(0))); |
| 4366 if (callback_obj->proxy() == FUNCTION_ADDR(that)) { | 4372 if (callback_obj->proxy() == FUNCTION_ADDR(that)) { |
| 4367 listeners.set(i, HEAP->undefined_value()); | 4373 listeners.set(i, isolate->heap()->undefined_value()); |
| 4368 } | 4374 } |
| 4369 } | 4375 } |
| 4370 } | 4376 } |
| 4371 | 4377 |
| 4372 | 4378 |
| 4373 void V8::SetCaptureStackTraceForUncaughtExceptions( | 4379 void V8::SetCaptureStackTraceForUncaughtExceptions( |
| 4374 bool capture, | 4380 bool capture, |
| 4375 int frame_limit, | 4381 int frame_limit, |
| 4376 StackTrace::StackTraceOptions options) { | 4382 StackTrace::StackTraceOptions options) { |
| 4377 i::Isolate::Current()->SetCaptureStackTraceForUncaughtExceptions( | 4383 i::Isolate::Current()->SetCaptureStackTraceForUncaughtExceptions( |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4527 #ifdef ENABLE_LOGGING_AND_PROFILING | 4533 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 4528 return LOGGER->GetActiveProfilerModules() & PROFILER_MODULE_CPU; | 4534 return LOGGER->GetActiveProfilerModules() & PROFILER_MODULE_CPU; |
| 4529 #else | 4535 #else |
| 4530 return true; | 4536 return true; |
| 4531 #endif | 4537 #endif |
| 4532 } | 4538 } |
| 4533 | 4539 |
| 4534 | 4540 |
| 4535 void V8::ResumeProfilerEx(int flags, int tag) { | 4541 void V8::ResumeProfilerEx(int flags, int tag) { |
| 4536 #ifdef ENABLE_LOGGING_AND_PROFILING | 4542 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 4543 i::Isolate* isolate = i::Isolate::Current(); |
| 4537 if (flags & PROFILER_MODULE_HEAP_SNAPSHOT) { | 4544 if (flags & PROFILER_MODULE_HEAP_SNAPSHOT) { |
| 4538 // Snapshot mode: resume modules, perform GC, then pause only | 4545 // Snapshot mode: resume modules, perform GC, then pause only |
| 4539 // those modules which haven't been started prior to making a | 4546 // those modules which haven't been started prior to making a |
| 4540 // snapshot. | 4547 // snapshot. |
| 4541 | 4548 |
| 4542 // Make a GC prior to taking a snapshot. | 4549 // Make a GC prior to taking a snapshot. |
| 4543 HEAP->CollectAllGarbage(false); | 4550 isolate->heap()->CollectAllGarbage(false); |
| 4544 // Reset snapshot flag and CPU module flags. | 4551 // Reset snapshot flag and CPU module flags. |
| 4545 flags &= ~(PROFILER_MODULE_HEAP_SNAPSHOT | PROFILER_MODULE_CPU); | 4552 flags &= ~(PROFILER_MODULE_HEAP_SNAPSHOT | PROFILER_MODULE_CPU); |
| 4546 const int current_flags = LOGGER->GetActiveProfilerModules(); | 4553 const int current_flags = isolate->logger()->GetActiveProfilerModules(); |
| 4547 LOGGER->ResumeProfiler(flags, tag); | 4554 isolate->logger()->ResumeProfiler(flags, tag); |
| 4548 HEAP->CollectAllGarbage(false); | 4555 isolate->heap()->CollectAllGarbage(false); |
| 4549 LOGGER->PauseProfiler(~current_flags & flags, tag); | 4556 isolate->logger()->PauseProfiler(~current_flags & flags, tag); |
| 4550 } else { | 4557 } else { |
| 4551 LOGGER->ResumeProfiler(flags, tag); | 4558 isolate->logger()->ResumeProfiler(flags, tag); |
| 4552 } | 4559 } |
| 4553 #endif | 4560 #endif |
| 4554 } | 4561 } |
| 4555 | 4562 |
| 4556 | 4563 |
| 4557 void V8::PauseProfilerEx(int flags, int tag) { | 4564 void V8::PauseProfilerEx(int flags, int tag) { |
| 4558 #ifdef ENABLE_LOGGING_AND_PROFILING | 4565 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 4559 LOGGER->PauseProfiler(flags, tag); | 4566 LOGGER->PauseProfiler(flags, tag); |
| 4560 #endif | 4567 #endif |
| 4561 } | 4568 } |
| (...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5701 | 5708 |
| 5702 | 5709 |
| 5703 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 5710 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
| 5704 HandleScopeImplementer* thread_local = | 5711 HandleScopeImplementer* thread_local = |
| 5705 reinterpret_cast<HandleScopeImplementer*>(storage); | 5712 reinterpret_cast<HandleScopeImplementer*>(storage); |
| 5706 thread_local->IterateThis(v); | 5713 thread_local->IterateThis(v); |
| 5707 return storage + ArchiveSpacePerThread(); | 5714 return storage + ArchiveSpacePerThread(); |
| 5708 } | 5715 } |
| 5709 | 5716 |
| 5710 } } // namespace v8::internal | 5717 } } // namespace v8::internal |
| OLD | NEW |