Rename static methods to avoid shadowing virtual methods

and fix Clang C++11 compile error.

Review URL: https://chromiumcodereview.appspot.com/9420049

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10739 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
ulan@chromium.org 2012-02-17 12:59:58 +00:00
parent 9e87728572
commit fd2d480fb0
3 changed files with 76 additions and 82 deletions

View File

@ -306,7 +306,7 @@
}],
['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd"', {
'cflags': [ '-Wall', '<(werror)', '-W', '-Wno-unused-parameter',
'-Wnon-virtual-dtor' ],
'-Wnon-virtual-dtor', '-Woverloaded-virtual' ],
}],
],
}, # Debug

View File

@ -109,30 +109,29 @@ class ElementsAccessorBase : public ElementsAccessor {
uint32_t key,
JSObject* obj,
Object* receiver) {
return ElementsAccessorSubclass::Get(
return ElementsAccessorSubclass::GetImpl(
BackingStoreClass::cast(backing_store), key, obj, receiver);
}
static MaybeObject* Get(BackingStoreClass* backing_store,
uint32_t key,
JSObject* obj,
Object* receiver) {
if (key < ElementsAccessorSubclass::GetCapacity(backing_store)) {
return backing_store->get(key);
}
return backing_store->GetHeap()->the_hole_value();
static MaybeObject* GetImpl(BackingStoreClass* backing_store,
uint32_t key,
JSObject* obj,
Object* receiver) {
return (key < ElementsAccessorSubclass::GetCapacityImpl(backing_store))
? backing_store->get(key)
: backing_store->GetHeap()->the_hole_value();
}
virtual MaybeObject* SetLength(JSObject* obj,
Object* length) {
ASSERT(obj->IsJSArray());
return ElementsAccessorSubclass::SetLength(
return ElementsAccessorSubclass::SetLengthImpl(
BackingStoreClass::cast(obj->elements()), obj, length);
}
static MaybeObject* SetLength(BackingStoreClass* backing_store,
JSObject* obj,
Object* length);
static MaybeObject* SetLengthImpl(BackingStoreClass* backing_store,
JSObject* obj,
Object* length);
virtual MaybeObject* SetCapacityAndLength(JSArray* array,
int capacity,
@ -167,7 +166,7 @@ class ElementsAccessorBase : public ElementsAccessor {
}
#endif
BackingStoreClass* backing_store = BackingStoreClass::cast(from);
uint32_t len1 = ElementsAccessorSubclass::GetCapacity(backing_store);
uint32_t len1 = ElementsAccessorSubclass::GetCapacityImpl(backing_store);
// Optimize if 'other' is empty.
// We cannot optimize if 'this' is empty, as other may have holes.
@ -176,14 +175,13 @@ class ElementsAccessorBase : public ElementsAccessor {
// Compute how many elements are not in other.
int extra = 0;
for (uint32_t y = 0; y < len1; y++) {
if (ElementsAccessorSubclass::HasElementAtIndex(backing_store,
y,
holder,
receiver)) {
if (ElementsAccessorSubclass::HasElementAtIndexImpl(
backing_store, y, holder, receiver)) {
uint32_t key =
ElementsAccessorSubclass::GetKeyForIndex(backing_store, y);
ElementsAccessorSubclass::GetKeyForIndexImpl(backing_store, y);
MaybeObject* maybe_value =
ElementsAccessorSubclass::Get(backing_store, key, holder, receiver);
ElementsAccessorSubclass::GetImpl(backing_store, key,
holder, receiver);
Object* value;
if (!maybe_value->ToObject(&value)) return maybe_value;
ASSERT(!value->IsTheHole());
@ -214,14 +212,13 @@ class ElementsAccessorBase : public ElementsAccessor {
// Fill in the extra values.
int index = 0;
for (uint32_t y = 0; y < len1; y++) {
if (ElementsAccessorSubclass::HasElementAtIndex(backing_store,
y,
holder,
receiver)) {
if (ElementsAccessorSubclass::HasElementAtIndexImpl(
backing_store, y, holder, receiver)) {
uint32_t key =
ElementsAccessorSubclass::GetKeyForIndex(backing_store, y);
ElementsAccessorSubclass::GetKeyForIndexImpl(backing_store, y);
MaybeObject* maybe_value =
ElementsAccessorSubclass::Get(backing_store, key, holder, receiver);
ElementsAccessorSubclass::GetImpl(backing_store, key,
holder, receiver);
Object* value;
if (!maybe_value->ToObject(&value)) return maybe_value;
if (!value->IsTheHole() && !HasKey(to, value)) {
@ -235,25 +232,23 @@ class ElementsAccessorBase : public ElementsAccessor {
}
protected:
static uint32_t GetCapacity(BackingStoreClass* backing_store) {
static uint32_t GetCapacityImpl(BackingStoreClass* backing_store) {
return backing_store->length();
}
virtual uint32_t GetCapacity(FixedArrayBase* backing_store) {
return ElementsAccessorSubclass::GetCapacity(
return ElementsAccessorSubclass::GetCapacityImpl(
BackingStoreClass::cast(backing_store));
}
static bool HasElementAtIndex(BackingStoreClass* backing_store,
uint32_t index,
JSObject* holder,
Object* receiver) {
static bool HasElementAtIndexImpl(BackingStoreClass* backing_store,
uint32_t index,
JSObject* holder,
Object* receiver) {
uint32_t key =
ElementsAccessorSubclass::GetKeyForIndex(backing_store, index);
MaybeObject* element = ElementsAccessorSubclass::Get(backing_store,
key,
holder,
receiver);
ElementsAccessorSubclass::GetKeyForIndexImpl(backing_store, index);
MaybeObject* element =
ElementsAccessorSubclass::GetImpl(backing_store, key, holder, receiver);
return !element->IsTheHole();
}
@ -261,18 +256,18 @@ class ElementsAccessorBase : public ElementsAccessor {
uint32_t index,
JSObject* holder,
Object* receiver) {
return ElementsAccessorSubclass::HasElementAtIndex(
return ElementsAccessorSubclass::HasElementAtIndexImpl(
BackingStoreClass::cast(backing_store), index, holder, receiver);
}
static uint32_t GetKeyForIndex(BackingStoreClass* backing_store,
uint32_t index) {
static uint32_t GetKeyForIndexImpl(BackingStoreClass* backing_store,
uint32_t index) {
return index;
}
virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store,
uint32_t index) {
return ElementsAccessorSubclass::GetKeyForIndex(
return ElementsAccessorSubclass::GetKeyForIndexImpl(
BackingStoreClass::cast(backing_store), index);
}
@ -446,10 +441,10 @@ class FastDoubleElementsAccessor
return obj->GetHeap()->true_value();
}
static bool HasElementAtIndex(FixedDoubleArray* backing_store,
uint32_t index,
JSObject* holder,
Object* receiver) {
static bool HasElementAtIndexImpl(FixedDoubleArray* backing_store,
uint32_t index,
JSObject* holder,
Object* receiver) {
return !backing_store->is_the_hole(index);
}
};
@ -465,20 +460,19 @@ class ExternalElementsAccessor
friend class ElementsAccessorBase<ExternalElementsAccessorSubclass,
ExternalArray>;
static MaybeObject* Get(ExternalArray* backing_store,
uint32_t key,
JSObject* obj,
Object* receiver) {
if (key < ExternalElementsAccessorSubclass::GetCapacity(backing_store)) {
return backing_store->get(key);
} else {
return backing_store->GetHeap()->undefined_value();
}
static MaybeObject* GetImpl(ExternalArray* backing_store,
uint32_t key,
JSObject* obj,
Object* receiver) {
return
key < ExternalElementsAccessorSubclass::GetCapacityImpl(backing_store)
? backing_store->get(key)
: backing_store->GetHeap()->undefined_value();
}
static MaybeObject* SetLength(ExternalArray* backing_store,
JSObject* obj,
Object* length) {
static MaybeObject* SetLengthImpl(ExternalArray* backing_store,
JSObject* obj,
Object* length) {
// External arrays do not support changing their length.
UNREACHABLE();
return obj;
@ -663,10 +657,10 @@ class DictionaryElementsAccessor
return DeleteCommon(obj, key, mode);
}
static MaybeObject* Get(SeededNumberDictionary* backing_store,
uint32_t key,
JSObject* obj,
Object* receiver) {
static MaybeObject* GetImpl(SeededNumberDictionary* backing_store,
uint32_t key,
JSObject* obj,
Object* receiver) {
int entry = backing_store->FindEntry(key);
if (entry != SeededNumberDictionary::kNotFound) {
Object* element = backing_store->ValueAt(entry);
@ -683,8 +677,8 @@ class DictionaryElementsAccessor
return obj->GetHeap()->the_hole_value();
}
static uint32_t GetKeyForIndex(SeededNumberDictionary* dict,
uint32_t index) {
static uint32_t GetKeyForIndexImpl(SeededNumberDictionary* dict,
uint32_t index) {
Object* key = dict->KeyAt(index);
return Smi::cast(key)->value();
}
@ -698,10 +692,10 @@ class NonStrictArgumentsElementsAccessor
friend class ElementsAccessorBase<NonStrictArgumentsElementsAccessor,
FixedArray>;
static MaybeObject* Get(FixedArray* parameter_map,
uint32_t key,
JSObject* obj,
Object* receiver) {
static MaybeObject* GetImpl(FixedArray* parameter_map,
uint32_t key,
JSObject* obj,
Object* receiver) {
Object* probe = GetParameterMapArg(parameter_map, key);
if (!probe->IsTheHole()) {
Context* context = Context::cast(parameter_map->get(0));
@ -718,9 +712,9 @@ class NonStrictArgumentsElementsAccessor
}
}
static MaybeObject* SetLength(FixedArray* parameter_map,
JSObject* obj,
Object* length) {
static MaybeObject* SetLengthImpl(FixedArray* parameter_map,
JSObject* obj,
Object* length) {
// TODO(mstarzinger): This was never implemented but will be used once we
// correctly implement [[DefineOwnProperty]] on arrays.
UNIMPLEMENTED();
@ -748,21 +742,21 @@ class NonStrictArgumentsElementsAccessor
return obj->GetHeap()->true_value();
}
static uint32_t GetCapacity(FixedArray* parameter_map) {
static uint32_t GetCapacityImpl(FixedArray* parameter_map) {
FixedArrayBase* arguments = FixedArrayBase::cast(parameter_map->get(1));
return Max(static_cast<uint32_t>(parameter_map->length() - 2),
ForArray(arguments)->GetCapacity(arguments));
}
static uint32_t GetKeyForIndex(FixedArray* dict,
uint32_t index) {
static uint32_t GetKeyForIndexImpl(FixedArray* dict,
uint32_t index) {
return index;
}
static bool HasElementAtIndex(FixedArray* parameter_map,
uint32_t index,
JSObject* holder,
Object* receiver) {
static bool HasElementAtIndexImpl(FixedArray* parameter_map,
uint32_t index,
JSObject* holder,
Object* receiver) {
Object* probe = GetParameterMapArg(parameter_map, index);
if (!probe->IsTheHole()) {
return true;
@ -866,9 +860,9 @@ void ElementsAccessor::InitializeOncePerProcess() {
template <typename ElementsAccessorSubclass, typename BackingStoreClass>
MaybeObject* ElementsAccessorBase<ElementsAccessorSubclass, BackingStoreClass>::
SetLength(BackingStoreClass* backing_store,
JSObject* obj,
Object* length) {
SetLengthImpl(BackingStoreClass* backing_store,
JSObject* obj,
Object* length) {
JSArray* array = JSArray::cast(obj);
// Fast case: The new length fits into a Smi.

View File

@ -1011,7 +1011,7 @@ class Smi: public Object {
void SmiVerify();
#endif
static const int kMinValue = (-1 << (kSmiValueSize - 1));
static const int kMinValue = (-1U << (kSmiValueSize - 1));
static const int kMaxValue = -(kMinValue + 1);
private: