Revision: 18632
Author: [email protected]
Date: Thu Jan 16 08:17:40 2014 UTC
Log: Removed apiutils.h and related cleanup.
ExtensionConfiguration is just a simple container for extension names
(in a perfect world we would use vector<string> and range-based for
loops), and HandleScopeData was in the totally wrong place. Some
additional cleanup on the way, e.g. using the null pattern behind our
external API.
[email protected]
Review URL: https://codereview.chromium.org/139393002
http://code.google.com/p/v8/source/detail?r=18632
Deleted:
/branches/bleeding_edge/src/apiutils.h
Modified:
/branches/bleeding_edge/include/v8.h
/branches/bleeding_edge/src/api.cc
/branches/bleeding_edge/src/api.h
/branches/bleeding_edge/src/bootstrapper.cc
/branches/bleeding_edge/src/debug.cc
/branches/bleeding_edge/src/handles-inl.h
/branches/bleeding_edge/src/handles.cc
/branches/bleeding_edge/src/handles.h
/branches/bleeding_edge/src/isolate.h
/branches/bleeding_edge/test/cctest/test-heap.cc
/branches/bleeding_edge/tools/gyp/v8.gyp
=======================================
--- /branches/bleeding_edge/src/apiutils.h Tue May 21 06:36:24 2013 UTC
+++ /dev/null
@@ -1,49 +0,0 @@
-// 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_
=======================================
--- /branches/bleeding_edge/include/v8.h Wed Jan 15 11:42:19 2014 UTC
+++ /branches/bleeding_edge/include/v8.h Thu Jan 16 08:17:40 2014 UTC
@@ -825,19 +825,23 @@
*/
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&);
@@ -845,27 +849,15 @@
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;
};
@@ -4923,15 +4915,19 @@
/**
- * 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_;
};
=======================================
--- /branches/bleeding_edge/src/api.cc Tue Jan 14 09:37:45 2014 UTC
+++ /branches/bleeding_edge/src/api.cc Thu Jan 16 08:17:40 2014 UTC
@@ -600,8 +600,7 @@
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;
@@ -640,11 +639,12 @@
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;
@@ -5151,6 +5151,8 @@
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>();
@@ -7267,8 +7269,7 @@
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));
@@ -7329,8 +7330,7 @@
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);
}
=======================================
--- /branches/bleeding_edge/src/api.h Tue Jan 14 09:37:45 2014 UTC
+++ /branches/bleeding_edge/src/api.h Thu Jan 16 08:17:40 2014 UTC
@@ -31,7 +31,6 @@
#include "v8.h"
#include "../include/v8-testing.h"
-#include "apiutils.h"
#include "contexts.h"
#include "factory.h"
#include "isolate.h"
@@ -608,7 +607,7 @@
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);
=======================================
--- /branches/bleeding_edge/src/bootstrapper.cc Mon Jan 13 09:42:23 2014 UTC
+++ /branches/bleeding_edge/src/bootstrapper.cc Thu Jan 16 08:17:40 2014 UTC
@@ -2268,13 +2268,8 @@
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;
=======================================
--- /branches/bleeding_edge/src/debug.cc Tue Dec 24 08:03:03 2013 UTC
+++ /branches/bleeding_edge/src/debug.cc Thu Jan 16 08:17:40 2014 UTC
@@ -854,11 +854,12 @@
// 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;
=======================================
--- /branches/bleeding_edge/src/handles-inl.h Mon Sep 30 11:56:52 2013 UTC
+++ /branches/bleeding_edge/src/handles-inl.h Thu Jan 16 08:17:40 2014 UTC
@@ -30,7 +30,6 @@
#define V8_HANDLES_INL_H_
#include "api.h"
-#include "apiutils.h"
#include "handles.h"
#include "heap.h"
#include "isolate.h"
@@ -110,8 +109,7 @@
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;
@@ -127,8 +125,7 @@
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--;
@@ -146,8 +143,7 @@
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.
@@ -167,8 +163,7 @@
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);
@@ -187,8 +182,7 @@
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;
@@ -201,8 +195,7 @@
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);
=======================================
--- /branches/bleeding_edge/src/handles.cc Mon Jan 13 09:42:23 2014 UTC
+++ /branches/bleeding_edge/src/handles.cc Thu Jan 16 08:17:40 2014 UTC
@@ -55,8 +55,7 @@
Object** HandleScope::Extend(Isolate* isolate) {
- v8::ImplementationUtilities::HandleScopeData* current =
- isolate->handle_scope_data();
+ HandleScopeData* current = isolate->handle_scope_data();
Object** result = current->next;
@@ -95,8 +94,7 @@
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);
}
@@ -751,8 +749,7 @@
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]);
@@ -778,8 +775,7 @@
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
=======================================
--- /branches/bleeding_edge/src/handles.h Mon Dec 23 12:37:56 2013 UTC
+++ /branches/bleeding_edge/src/handles.h Thu Jan 16 08:17:40 2014 UTC
@@ -29,7 +29,6 @@
#define V8_HANDLES_H_
#include "allocation.h"
-#include "apiutils.h"
#include "objects.h"
namespace v8 {
@@ -317,6 +316,17 @@
#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_
=======================================
--- /branches/bleeding_edge/src/isolate.h Wed Jan 15 17:00:35 2014 UTC
+++ /branches/bleeding_edge/src/isolate.h Thu Jan 16 08:17:40 2014 UTC
@@ -30,7 +30,6 @@
#include "../include/v8-debug.h"
#include "allocation.h"
-#include "apiutils.h"
#include "assert-scope.h"
#include "atomicops.h"
#include "builtins.h"
@@ -887,9 +886,8 @@
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_;
@@ -1284,7 +1282,7 @@
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_;
=======================================
--- /branches/bleeding_edge/test/cctest/test-heap.cc Wed Jan 15 11:42:19
2014 UTC
+++ /branches/bleeding_edge/test/cctest/test-heap.cc Thu Jan 16 08:17:40
2014 UTC
@@ -3532,8 +3532,7 @@
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);
=======================================
--- /branches/bleeding_edge/tools/gyp/v8.gyp Thu Jan 2 07:04:05 2014 UTC
+++ /branches/bleeding_edge/tools/gyp/v8.gyp Thu Jan 16 08:17:40 2014 UTC
@@ -253,7 +253,6 @@
'../../src/allocation-tracker.h',
'../../src/api.cc',
'../../src/api.h',
- '../../src/apiutils.h',
'../../src/arguments.cc',
'../../src/arguments.h',
'../../src/assembler.cc',
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.