Commit f7d56eb6 authored by rossberg@chromium.org's avatar rossberg@chromium.org

Handle proxies in KeyedStoreIC::Store, instead of just ignoring them.

R=mstarzinger@chromium.org
BUG=v8:1543
TEST=

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9787 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 0a896072
......@@ -1612,6 +1612,12 @@ MaybeObject* KeyedStoreIC::Store(State state,
if (key->IsSymbol()) {
Handle<String> name = Handle<String>::cast(key);
// Handle proxies.
if (object->IsJSProxy()) {
return JSProxy::cast(*object)->SetProperty(
*name, *value, NONE, strict_mode);
}
// If the object is undefined or null it's illegal to try to set any
// properties on it; throw a TypeError in that case.
if (object->IsUndefined() || object->IsNull()) {
......
......@@ -135,6 +135,10 @@ function TestGet2(create, handler) {
assertEquals("b", key)
assertEquals(42, p[99])
assertEquals("99", key)
assertEquals(42, (function(n) { return p[n] })("c"))
assertEquals("c", key)
assertEquals(42, (function(n) { return p[n] })(101))
assertEquals("101", key)
var o = Object.create(p, {x: {value: 88}})
assertEquals(42, o.a)
......@@ -145,6 +149,11 @@ function TestGet2(create, handler) {
assertEquals("99", key)
assertEquals(88, o.x)
assertEquals(88, o["x"])
assertEquals(42, (function(n) { return o[n] })("c"))
assertEquals("c", key)
assertEquals(42, (function(n) { return o[n] })(101))
assertEquals("101", key)
assertEquals(88, (function(n) { return o[n] })("x"))
}
TestGet({
......@@ -198,6 +207,10 @@ function TestGetCall2(create, handler) {
assertEquals(55, p[101].call(p))
assertEquals(55, p.withargs(45, 5))
assertEquals(55, p.withargs.call(p, 11, 22))
assertEquals(55, (function(n) { return p[n]() })("f"))
assertEquals(55, (function(n) { return p[n].call(p) })("f"))
assertEquals(55, (function(n) { return p[n](15, 20) })("withargs"))
assertEquals(55, (function(n) { return p[n].call(p, 13, 21) })("withargs"))
assertEquals("6655", "66" + p) // calls p.toString
var o = Object.create(p, {g: {value: function(x) { return x + 88 }}})
......@@ -213,6 +226,13 @@ function TestGetCall2(create, handler) {
assertEquals(90, o.g(2))
assertEquals(91, o.g.call(o, 3))
assertEquals(92, o.g.call(p, 4))
assertEquals(55, (function(n) { return o[n]() })("f"))
assertEquals(55, (function(n) { return o[n].call(o) })("f"))
assertEquals(55, (function(n) { return o[n](15, 20) })("withargs"))
assertEquals(55, (function(n) { return o[n].call(o, 13, 21) })("withargs"))
assertEquals(93, (function(n) { return o[n](5) })("g"))
assertEquals(94, (function(n) { return o[n].call(o, 6) })("g"))
assertEquals(95, (function(n) { return o[n].call(p, 7) })("g"))
assertEquals("6655", "66" + o) // calls o.toString
}
......@@ -279,14 +299,15 @@ function TestGetThrow2(create, handler) {
assertThrows(function(){ p.a }, "myexn")
assertThrows(function(){ p["b"] }, "myexn")
assertThrows(function(){ p[3] }, "myexn")
assertThrows(function(){ (function(n) { p[n] })("c") }, "myexn")
assertThrows(function(){ (function(n) { p[n] })(99) }, "myexn")
var o = Object.create(p, {x: {value: 88}, '4': {value: 89}})
assertThrows(function(){ o.a }, "myexn")
assertThrows(function(){ o["b"] }, "myexn")
assertThrows(function(){ o[3] }, "myexn")
assertEquals(88, o.x)
assertEquals(88, o["x"])
assertEquals(89, o[4])
assertThrows(function(){ (function(n) { o[n] })("c") }, "myexn")
assertThrows(function(){ (function(n) { o[n] })(99) }, "myexn")
}
TestGetThrow({
......@@ -350,6 +371,13 @@ function TestSet2(create, handler) {
assertEquals(44, p[77] = 44)
assertEquals("77", key)
assertEquals(44, val)
assertEquals(45, (function(n) { return p[n] = 45 })("c"))
assertEquals("c", key)
assertEquals(45, val)
assertEquals(46, (function(n) { return p[n] = 46 })(99))
assertEquals("99", key)
assertEquals(46, val)
}
TestSet({
......@@ -431,6 +459,8 @@ function TestSetThrow2(create, handler) {
assertThrows(function(){ p.a = 42 }, "myexn")
assertThrows(function(){ p["b"] = 42 }, "myexn")
assertThrows(function(){ p[22] = 42 }, "myexn")
assertThrows(function(){ (function(n) { p[n] = 45 })("c") }, "myexn")
assertThrows(function(){ (function(n) { p[n] = 46 })(99) }, "myexn")
}
TestSetThrow({
......
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