Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(473)

Unified Diff: test/cctest/test-api.cc

Issue 13663: Make sure that the generic stubs for keyed load and store and for... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
===================================================================
--- test/cctest/test-api.cc (revision 941)
+++ test/cctest/test-api.cc (working copy)
@@ -3638,30 +3638,82 @@
v8::Handle<Value> value;
// Check that the named access-control function is called every time.
- value = v8_compile("for (var i = 0; i < 10; i++) obj.prop = 1;")->Run();
- value = v8_compile("for (var i = 0; i < 10; i++) obj.prop;"
- "obj.prop")->Run();
+ CompileRun("function testProp(obj) {"
+ " for (var i = 0; i < 10; i++) obj.prop = 1;"
+ " for (var j = 0; j < 10; j++) obj.prop;"
+ " return obj.prop"
+ "}");
+ value = CompileRun("testProp(obj)");
CHECK(value->IsNumber());
CHECK_EQ(1, value->Int32Value());
CHECK_EQ(21, named_access_count);
// Check that the named access-control function is called every time.
- value = v8_compile("var p = 'prop';")->Run();
- value = v8_compile("for (var i = 0; i < 10; i++) obj[p] = 1;")->Run();
- value = v8_compile("for (var i = 0; i < 10; i++) obj[p];"
- "obj[p]")->Run();
+ CompileRun("var p = 'prop';"
+ "function testKeyed(obj) {"
+ " for (var i = 0; i < 10; i++) obj[p] = 1;"
+ " for (var j = 0; j < 10; j++) obj[p];"
+ " return obj[p];"
+ "}");
+ // Use obj which requires access checks. No inline caching is used
+ // in that case.
+ value = CompileRun("testKeyed(obj)");
CHECK(value->IsNumber());
CHECK_EQ(1, value->Int32Value());
CHECK_EQ(42, named_access_count);
+ // Force the inline caches into generic state and try again.
+ CompileRun("testKeyed({ a: 0 })");
+ CompileRun("testKeyed({ b: 0 })");
+ value = CompileRun("testKeyed(obj)");
+ CHECK(value->IsNumber());
+ CHECK_EQ(1, value->Int32Value());
+ CHECK_EQ(63, named_access_count);
// Check that the indexed access-control function is called every time.
- value = v8_compile("for (var i = 0; i < 10; i++) obj[0] = 1;")->Run();
- value = v8_compile("for (var i = 0; i < 10; i++) obj[0];"
- "obj[0]")->Run();
+ CompileRun("function testIndexed(obj) {"
+ " for (var i = 0; i < 10; i++) obj[0] = 1;"
+ " for (var j = 0; j < 10; j++) obj[0];"
+ " return obj[0]"
+ "}");
+ value = CompileRun("testIndexed(obj)");
CHECK(value->IsNumber());
CHECK_EQ(1, value->Int32Value());
CHECK_EQ(21, indexed_access_count);
+ // Force the inline caches into generic state.
+ CompileRun("testIndexed(new Array(1))");
+ // Test that the indexed access check is called.
+ value = CompileRun("testIndexed(obj)");
+ CHECK(value->IsNumber());
+ CHECK_EQ(1, value->Int32Value());
+ CHECK_EQ(42, indexed_access_count);
+ // Check that the named access check is called when invoking
+ // functions on an object that requires access checks.
+ CompileRun("obj.f = function() {}");
+ CompileRun("function testCallNormal(obj) {"
+ " for (var i = 0; i < 10; i++) obj.f();"
+ "}");
+ CompileRun("testCallNormal(obj)");
+ CHECK_EQ(74, named_access_count);
+
+ // Force obj into slow case.
+ value = CompileRun("delete obj.prop");
+ CHECK(value->BooleanValue());
+ // Force inline caches into dictionary probing mode.
+ CompileRun("var o = { x: 0 }; delete o.x; testProp(o);");
+ // Test that the named access check is called.
+ value = CompileRun("testProp(obj);");
+ CHECK(value->IsNumber());
+ CHECK_EQ(1, value->Int32Value());
+ CHECK_EQ(96, named_access_count);
+
+ // Force the call inline cache into dictionary probing mode.
+ CompileRun("o.f = function() {}; testCallNormal(o)");
+ // Test that the named access check is still called for each
+ // invocation of the function.
+ value = CompileRun("testCallNormal(obj)");
+ CHECK_EQ(106, named_access_count);
+
context1->Exit();
context0->Exit();
context1.Dispose();
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698