Commit edd69196 authored by danno@chromium.org's avatar danno@chromium.org

Implement UnionOfKeys for NonStrictArguments

BUG=none
TEST=cctest/test-api/IndexedInterceptorNonStrictArgsWithIndexedAccessor

Review URL: http://codereview.chromium.org/7657011

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8963 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 3b82bc96
This diff is collapsed.
......@@ -41,10 +41,10 @@ class ElementsAccessor {
virtual ~ElementsAccessor() { }
virtual MaybeObject* GetWithReceiver(JSObject* obj,
Object* receiver,
uint32_t index) = 0;
uint32_t key) = 0;
virtual MaybeObject* Delete(JSObject* obj,
uint32_t index,
uint32_t key,
JSReceiver::DeleteMode mode) = 0;
virtual MaybeObject* AddElementsToFixedArray(FixedArrayBase* from,
......@@ -56,8 +56,33 @@ class ElementsAccessor {
return elements_accessors_[elements_kind];
}
static ElementsAccessor* ForArray(FixedArrayBase* array);
static void InitializeOncePerProcess();
protected:
friend class NonStrictArgumentsElementsAccessor;
// TODO(danno): GetElement should be merged with GetWithReceiver.
virtual MaybeObject* GetElement(FixedArrayBase* backing_store,
uint32_t key) = 0;
virtual uint32_t GetCapacity(FixedArrayBase* backing_store) = 0;
virtual bool HasElementAtIndex(FixedArrayBase* backing_store,
uint32_t index) = 0;
// Element handlers distinguish between indexes and keys when the manipulate
// elements. Indexes refer to elements in terms of their location in the
// underlying storage's backing store representation, and are between 0
// GetCapacity. Keys refer to elements in terms of the value that would be
// specific in JavaScript to access the element. In most implementations, keys
// are equivalent to indexes, and GetKeyForIndex returns the same value it is
// passed. In the NumberDictionary ElementsAccessor, GetKeyForIndex maps the
// index to a key using the KeyAt method on the NumberDictionary.
virtual uint32_t GetKeyForIndex(FixedArrayBase* backing_store,
uint32_t index) = 0;
private:
static ElementsAccessor** elements_accessors_;
......
......@@ -3617,6 +3617,52 @@ THREADED_TEST(IndexedInterceptorUnboxedDoubleWithIndexedAccessor) {
}
Handle<v8::Array> NonStrictArgsIndexedPropertyEnumerator(
const AccessorInfo& info) {
// Force the list of returned keys to be stored in a Arguments object.
Local<Script> indexed_property_names_script = Script::Compile(v8_str(
"function f(w,x) {"
" return arguments;"
"}"
"keys = f(0, 1, 2, 3);"
"keys;"));
Local<Value> result = indexed_property_names_script->Run();
return Local<v8::Array>(static_cast<v8::Array*>(::v8::Object::Cast(*result)));
}
static v8::Handle<Value> NonStrictIndexedPropertyGetter(
uint32_t index,
const AccessorInfo& info) {
ApiTestFuzzer::Fuzz();
if (index < 4) {
return v8::Handle<Value>(v8_num(index));
}
return v8::Handle<Value>();
}
// Make sure that the the interceptor code in the runtime properly handles
// merging property name lists for non-string arguments arrays.
THREADED_TEST(IndexedInterceptorNonStrictArgsWithIndexedAccessor) {
v8::HandleScope scope;
Local<ObjectTemplate> templ = ObjectTemplate::New();
templ->SetIndexedPropertyHandler(NonStrictIndexedPropertyGetter,
0,
0,
0,
NonStrictArgsIndexedPropertyEnumerator);
LocalContext context;
context->Global()->Set(v8_str("obj"), templ->NewInstance());
Local<Script> create_args_script =
Script::Compile(v8_str(
"var key_count = 0;"
"for (x in obj) {key_count++;} key_count;"));
Local<Value> result = create_args_script->Run();
CHECK_EQ(v8_num(4), result);
}
static v8::Handle<Value> IdentityIndexedPropertyGetter(
uint32_t index,
const AccessorInfo& info) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment