*/
static int NumberOfHandles(Isolate* isolate);
- private:
- /**
- * Creates a new handle with the given value.
- */
+ V8_INLINE Isolate* GetIsolate() const {
+ return reinterpret_cast<Isolate*>(isolate_);
+ }
+
+ protected:
+ V8_INLINE HandleScope() {}
+
+ void Initialize(Isolate* isolate);
+
static internal::Object** CreateHandle(internal::Isolate* isolate,
internal::Object* value);
- // Uses HeapObject to obtain the current Isolate.
+
+ private:
+ // Uses heap_object to obtain the current Isolate.
static internal::Object** CreateHandle(internal::HeapObject* heap_object,
internal::Object* value);
- V8_INLINE HandleScope() {}
- void Initialize(Isolate* isolate);
-
// Make it hard to create heap-allocated or illegal handle scopes by
// disallowing certain operations.
HandleScope(const HandleScope&);
void* operator new(size_t size);
void operator delete(void*, size_t);
- // This Data class is accessible internally as HandleScopeData through a
- // typedef in the ImplementationUtilities class.
- class V8_EXPORT Data {
- public:
- internal::Object** next;
- internal::Object** limit;
- int level;
- V8_INLINE void Initialize() {
- next = limit = NULL;
- level = 0;
- }
- };
-
internal::Isolate* isolate_;
internal::Object** prev_next_;
internal::Object** prev_limit_;
- friend class ImplementationUtilities;
- friend class EscapableHandleScope;
- template<class F> friend class Handle;
+ // Local::New uses CreateHandle with an Isolate* parameter.
template<class F> friend class Local;
+
+ // Object::GetInternalField and Context::GetEmbedderData use CreateHandle with
+ // a HeapObject* in their shortcuts.
friend class Object;
friend class Context;
};
/**
- * Ignore
+ * A container for extension names.
*/
class V8_EXPORT ExtensionConfiguration {
public:
+ ExtensionConfiguration() : name_count_(0), names_(NULL) { }
ExtensionConfiguration(int name_count, const char* names[])
: name_count_(name_count), names_(names) { }
+
+ const char** begin() const { return &names_[0]; }
+ const char** end() const { return &names_[name_count_]; }
+
private:
- friend class ImplementationUtilities;
- int name_count_;
+ const int name_count_;
const char** names_;
};
internal_isolate->thread_manager()->IsLockedByCurrentThread(),
"HandleScope::HandleScope",
"Entering the V8 API without proper locking in place");
- v8::ImplementationUtilities::HandleScopeData* current =
- internal_isolate->handle_scope_data();
+ i::HandleScopeData* current = internal_isolate->handle_scope_data();
isolate_ = internal_isolate;
prev_next_ = current->next;
prev_limit_ = current->limit;
i::Object** EscapableHandleScope::Escape(i::Object** escape_value) {
- Utils::ApiCheck(*escape_slot_ == isolate_->heap()->the_hole_value(),
+ i::Heap* heap = reinterpret_cast<i::Isolate*>(GetIsolate())->heap();
+ Utils::ApiCheck(*escape_slot_ == heap->the_hole_value(),
"EscapeableHandleScope::Escape",
"Escape value set twice");
if (escape_value == NULL) {
- *escape_slot_ = isolate_->heap()->undefined_value();
+ *escape_slot_ = heap->undefined_value();
return NULL;
}
*escape_slot_ = *escape_value;
LOG_API(isolate, "Context::New");
ON_BAILOUT(isolate, "v8::Context::New()", return Local<Context>());
i::HandleScope scope(isolate);
+ ExtensionConfiguration no_extensions;
+ if (extensions == NULL) extensions = &no_extensions;
i::Handle<i::Context> env =
CreateEnvironment(isolate, extensions, global_template, global_object);
if (env.is_null()) return Local<Context>();
char* HandleScopeImplementer::ArchiveThread(char* storage) {
- v8::ImplementationUtilities::HandleScopeData* current =
- isolate_->handle_scope_data();
+ HandleScopeData* current = isolate_->handle_scope_data();
handle_scope_data_ = *current;
OS::MemCopy(storage, this, sizeof(*this));
void HandleScopeImplementer::Iterate(ObjectVisitor* v) {
- v8::ImplementationUtilities::HandleScopeData* current =
- isolate_->handle_scope_data();
+ HandleScopeData* current = isolate_->handle_scope_data();
handle_scope_data_ = *current;
IterateThis(v);
}
#include "v8.h"
#include "../include/v8-testing.h"
-#include "apiutils.h"
#include "contexts.h"
#include "factory.h"
#include "isolate.h"
int call_depth_;
Object** last_handle_before_deferred_block_;
// This is only used for threading support.
- v8::ImplementationUtilities::HandleScopeData handle_scope_data_;
+ HandleScopeData handle_scope_data_;
void IterateThis(ObjectVisitor* v);
char* RestoreThreadHelper(char* from);
+++ /dev/null
-// Copyright 2012 the V8 project authors. All rights reserved.
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following
-// disclaimer in the documentation and/or other materials provided
-// with the distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived
-// from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#ifndef V8_APIUTILS_H_
-#define V8_APIUTILS_H_
-
-namespace v8 {
-class ImplementationUtilities {
- public:
- static int GetNameCount(ExtensionConfiguration* that) {
- return that->name_count_;
- }
-
- static const char** GetNames(ExtensionConfiguration* that) {
- return that->names_;
- }
-
- // Introduce an alias for the handle scope data to allow non-friends
- // to access the HandleScope data.
- typedef v8::HandleScope::Data HandleScopeData;
-};
-
-} // namespace v8
-
-#endif // V8_APIUTILS_H_
InstallExtension(isolate, "v8/trigger-failure", &extension_states);
}
- if (extensions == NULL) return true;
- // Install required extensions
- int count = v8::ImplementationUtilities::GetNameCount(extensions);
- const char** names = v8::ImplementationUtilities::GetNames(extensions);
- for (int i = 0; i < count; i++) {
- if (!InstallExtension(isolate, names[i], &extension_states))
- return false;
+ for (const char** it = extensions->begin(); it != extensions->end(); ++it) {
+ if (!InstallExtension(isolate, *it, &extension_states)) return false;
}
return true;
// Create the debugger context.
HandleScope scope(isolate_);
+ ExtensionConfiguration no_extensions;
Handle<Context> context =
isolate_->bootstrapper()->CreateEnvironment(
Handle<Object>::null(),
v8::Handle<ObjectTemplate>(),
- NULL);
+ &no_extensions);
// Fail if no context could be created.
if (context.is_null()) return false;
#define V8_HANDLES_INL_H_
#include "api.h"
-#include "apiutils.h"
#include "handles.h"
#include "heap.h"
#include "isolate.h"
HandleScope::HandleScope(Isolate* isolate) {
- v8::ImplementationUtilities::HandleScopeData* current =
- isolate->handle_scope_data();
+ HandleScopeData* current = isolate->handle_scope_data();
isolate_ = isolate;
prev_next_ = current->next;
prev_limit_ = current->limit;
void HandleScope::CloseScope(Isolate* isolate,
Object** prev_next,
Object** prev_limit) {
- v8::ImplementationUtilities::HandleScopeData* current =
- isolate->handle_scope_data();
+ HandleScopeData* current = isolate->handle_scope_data();
std::swap(current->next, prev_next);
current->level--;
template <typename T>
Handle<T> HandleScope::CloseAndEscape(Handle<T> handle_value) {
- v8::ImplementationUtilities::HandleScopeData* current =
- isolate_->handle_scope_data();
+ HandleScopeData* current = isolate_->handle_scope_data();
T* value = *handle_value;
// Throw away all handles in the current scope.
template <typename T>
T** HandleScope::CreateHandle(Isolate* isolate, T* value) {
ASSERT(AllowHandleAllocation::IsAllowed());
- v8::ImplementationUtilities::HandleScopeData* current =
- isolate->handle_scope_data();
+ HandleScopeData* current = isolate->handle_scope_data();
internal::Object** cur = current->next;
if (cur == current->limit) cur = Extend(isolate);
inline SealHandleScope::SealHandleScope(Isolate* isolate) : isolate_(isolate) {
// Make sure the current thread is allowed to create handles to begin with.
CHECK(AllowHandleAllocation::IsAllowed());
- v8::ImplementationUtilities::HandleScopeData* current =
- isolate_->handle_scope_data();
+ HandleScopeData* current = isolate_->handle_scope_data();
// Shrink the current handle scope to make it impossible to do
// handle allocations without an explicit handle scope.
limit_ = current->limit;
inline SealHandleScope::~SealHandleScope() {
// Restore state in current handle scope to re-enable handle
// allocations.
- v8::ImplementationUtilities::HandleScopeData* current =
- isolate_->handle_scope_data();
+ HandleScopeData* current = isolate_->handle_scope_data();
ASSERT_EQ(0, current->level);
current->level = level_;
ASSERT_EQ(current->next, current->limit);
Object** HandleScope::Extend(Isolate* isolate) {
- v8::ImplementationUtilities::HandleScopeData* current =
- isolate->handle_scope_data();
+ HandleScopeData* current = isolate->handle_scope_data();
Object** result = current->next;
void HandleScope::DeleteExtensions(Isolate* isolate) {
- v8::ImplementationUtilities::HandleScopeData* current =
- isolate->handle_scope_data();
+ HandleScopeData* current = isolate->handle_scope_data();
isolate->handle_scope_implementer()->DeleteExtensions(current->limit);
}
DeferredHandleScope::DeferredHandleScope(Isolate* isolate)
: impl_(isolate->handle_scope_implementer()) {
impl_->BeginDeferredScope();
- v8::ImplementationUtilities::HandleScopeData* data =
- impl_->isolate()->handle_scope_data();
+ HandleScopeData* data = impl_->isolate()->handle_scope_data();
Object** new_next = impl_->GetSpareOrNewBlock();
Object** new_limit = &new_next[kHandleBlockSize];
ASSERT(data->limit == &impl_->blocks()->last()[kHandleBlockSize]);
DeferredHandles* DeferredHandleScope::Detach() {
DeferredHandles* deferred = impl_->Detach(prev_limit_);
- v8::ImplementationUtilities::HandleScopeData* data =
- impl_->isolate()->handle_scope_data();
+ HandleScopeData* data = impl_->isolate()->handle_scope_data();
data->next = prev_next_;
data->limit = prev_limit_;
#ifdef DEBUG
#define V8_HANDLES_H_
#include "allocation.h"
-#include "apiutils.h"
#include "objects.h"
namespace v8 {
#endif
};
+struct HandleScopeData {
+ internal::Object** next;
+ internal::Object** limit;
+ int level;
+
+ void Initialize() {
+ next = limit = NULL;
+ level = 0;
+ }
+};
+
} } // namespace v8::internal
#endif // V8_HANDLES_H_
#include "../include/v8-debug.h"
#include "allocation.h"
-#include "apiutils.h"
#include "assert-scope.h"
#include "atomicops.h"
#include "builtins.h"
return descriptor_lookup_cache_;
}
- v8::ImplementationUtilities::HandleScopeData* handle_scope_data() {
- return &handle_scope_data_;
- }
+ HandleScopeData* handle_scope_data() { return &handle_scope_data_; }
+
HandleScopeImplementer* handle_scope_implementer() {
ASSERT(handle_scope_implementer_);
return handle_scope_implementer_;
KeyedLookupCache* keyed_lookup_cache_;
ContextSlotCache* context_slot_cache_;
DescriptorLookupCache* descriptor_lookup_cache_;
- v8::ImplementationUtilities::HandleScopeData handle_scope_data_;
+ HandleScopeData handle_scope_data_;
HandleScopeImplementer* handle_scope_implementer_;
UnicodeCache* unicode_cache_;
Zone runtime_zone_;
Isolate* isolate = CcTest::i_isolate();
Heap* heap = isolate->heap();
v8::HandleScope scope(reinterpret_cast<v8::Isolate*>(isolate));
- v8::ImplementationUtilities::HandleScopeData* data =
- isolate->handle_scope_data();
+ HandleScopeData* data = isolate->handle_scope_data();
Handle<Object> init(heap->empty_string(), isolate);
while (data->next < data->limit) {
Handle<Object> obj(heap->empty_string(), isolate);
'../../src/allocation-tracker.h',
'../../src/api.cc',
'../../src/api.h',
- '../../src/apiutils.h',
'../../src/arguments.cc',
'../../src/arguments.h',
'../../src/assembler.cc',