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

Side by Side Diff: test/cctest/test-api.cc

Issue 8386072: Fix gcc-4.6 warnings. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/test-compiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 THREADED_TEST(GlobalPrototype) { 1182 THREADED_TEST(GlobalPrototype) {
1183 v8::HandleScope scope; 1183 v8::HandleScope scope;
1184 v8::Handle<v8::FunctionTemplate> func_templ = v8::FunctionTemplate::New(); 1184 v8::Handle<v8::FunctionTemplate> func_templ = v8::FunctionTemplate::New();
1185 func_templ->PrototypeTemplate()->Set( 1185 func_templ->PrototypeTemplate()->Set(
1186 "dummy", 1186 "dummy",
1187 v8::FunctionTemplate::New(DummyCallHandler)); 1187 v8::FunctionTemplate::New(DummyCallHandler));
1188 v8::Handle<ObjectTemplate> templ = func_templ->InstanceTemplate(); 1188 v8::Handle<ObjectTemplate> templ = func_templ->InstanceTemplate();
1189 templ->Set("x", v8_num(200)); 1189 templ->Set("x", v8_num(200));
1190 templ->SetAccessor(v8_str("m"), GetM); 1190 templ->SetAccessor(v8_str("m"), GetM);
1191 LocalContext env(0, templ); 1191 LocalContext env(0, templ);
1192 v8::Handle<v8::Object> obj = env->Global(); 1192 v8::Handle<v8::Object> obj(env->Global());
1193 v8::Handle<Script> script = v8_compile("dummy()"); 1193 v8::Handle<Script> script(v8_compile("dummy()"));
1194 v8::Handle<Value> result = script->Run(); 1194 v8::Handle<Value> result(script->Run());
1195 CHECK_EQ(13.4, result->NumberValue()); 1195 CHECK_EQ(13.4, result->NumberValue());
1196 CHECK_EQ(200, v8_compile("x")->Run()->Int32Value()); 1196 CHECK_EQ(200, v8_compile("x")->Run()->Int32Value());
1197 CHECK_EQ(876, v8_compile("m")->Run()->Int32Value()); 1197 CHECK_EQ(876, v8_compile("m")->Run()->Int32Value());
1198 } 1198 }
1199 1199
1200 1200
1201 THREADED_TEST(ObjectTemplate) { 1201 THREADED_TEST(ObjectTemplate) {
1202 v8::HandleScope scope; 1202 v8::HandleScope scope;
1203 Local<ObjectTemplate> templ1 = ObjectTemplate::New(); 1203 Local<ObjectTemplate> templ1 = ObjectTemplate::New();
1204 templ1->Set("x", v8_num(10)); 1204 templ1->Set("x", v8_num(10));
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
1758 v8::HandleScope scope; 1758 v8::HandleScope scope;
1759 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(); 1759 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New();
1760 global->Set(v8_str("callScriptRecursively"), 1760 global->Set(v8_str("callScriptRecursively"),
1761 v8::FunctionTemplate::New(CallScriptRecursivelyCall)); 1761 v8::FunctionTemplate::New(CallScriptRecursivelyCall));
1762 global->Set(v8_str("callFunctionRecursively"), 1762 global->Set(v8_str("callFunctionRecursively"),
1763 v8::FunctionTemplate::New(CallFunctionRecursivelyCall)); 1763 v8::FunctionTemplate::New(CallFunctionRecursivelyCall));
1764 LocalContext env(NULL, global); 1764 LocalContext env(NULL, global);
1765 1765
1766 env->Global()->Set(v8_str("depth"), v8::Integer::New(0)); 1766 env->Global()->Set(v8_str("depth"), v8::Integer::New(0));
1767 call_recursively_script = v8_compile("callScriptRecursively()"); 1767 call_recursively_script = v8_compile("callScriptRecursively()");
1768 v8::Handle<Value> result = call_recursively_script->Run(); 1768 v8::Handle<Value> result(call_recursively_script->Run());
1769 call_recursively_script = v8::Handle<Script>(); 1769 call_recursively_script = v8::Handle<Script>();
1770 1770
1771 env->Global()->Set(v8_str("depth"), v8::Integer::New(0)); 1771 env->Global()->Set(v8_str("depth"), v8::Integer::New(0));
1772 Script::Compile(v8_str("callFunctionRecursively()"))->Run(); 1772 Script::Compile(v8_str("callFunctionRecursively()"))->Run();
1773 } 1773 }
1774 1774
1775 1775
1776 static v8::Handle<Value> 1776 static v8::Handle<Value>
1777 ThrowingPropertyHandlerGet(Local<String> key, const AccessorInfo&) { 1777 ThrowingPropertyHandlerGet(Local<String> key, const AccessorInfo&) {
1778 ApiTestFuzzer::Fuzz(); 1778 ApiTestFuzzer::Fuzz();
(...skipping 2598 matching lines...) Expand 10 before | Expand all | Expand 10 after
4377 4377
4378 ExpectBoolean("Object.isExtensible(undetectable)", true); 4378 ExpectBoolean("Object.isExtensible(undetectable)", true);
4379 4379
4380 source = v8_str("Object.preventExtensions(undetectable);"); 4380 source = v8_str("Object.preventExtensions(undetectable);");
4381 script = Script::Compile(source); 4381 script = Script::Compile(source);
4382 script->Run(); 4382 script->Run();
4383 ExpectBoolean("Object.isExtensible(undetectable)", false); 4383 ExpectBoolean("Object.isExtensible(undetectable)", false);
4384 4384
4385 source = v8_str("undetectable.y = 2000;"); 4385 source = v8_str("undetectable.y = 2000;");
4386 script = Script::Compile(source); 4386 script = Script::Compile(source);
4387 Local<Value> result = script->Run(); 4387 Local<Value> result(script->Run());
4388 ExpectBoolean("undetectable.y == undefined", true); 4388 ExpectBoolean("undetectable.y == undefined", true);
4389 } 4389 }
4390 4390
4391 4391
4392 4392
4393 THREADED_TEST(UndetectableString) { 4393 THREADED_TEST(UndetectableString) {
4394 v8::HandleScope scope; 4394 v8::HandleScope scope;
4395 LocalContext env; 4395 LocalContext env;
4396 4396
4397 Local<String> obj = String::NewUndetectable("foo"); 4397 Local<String> obj = String::NewUndetectable("foo");
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
4729 4729
4730 4730
4731 THREADED_TEST(NativeFunctionDeclarationError) { 4731 THREADED_TEST(NativeFunctionDeclarationError) {
4732 v8::HandleScope handle_scope; 4732 v8::HandleScope handle_scope;
4733 const char* name = "nativedeclerr"; 4733 const char* name = "nativedeclerr";
4734 // Syntax error in extension code. 4734 // Syntax error in extension code.
4735 v8::RegisterExtension(new NativeFunctionExtension(name, 4735 v8::RegisterExtension(new NativeFunctionExtension(name,
4736 "native\nfunction foo();")); 4736 "native\nfunction foo();"));
4737 const char* extension_names[] = { name }; 4737 const char* extension_names[] = { name };
4738 v8::ExtensionConfiguration extensions(1, extension_names); 4738 v8::ExtensionConfiguration extensions(1, extension_names);
4739 v8::Handle<Context> context = Context::New(&extensions); 4739 v8::Handle<Context> context(Context::New(&extensions));
4740 ASSERT(context.IsEmpty()); 4740 ASSERT(context.IsEmpty());
4741 } 4741 }
4742 4742
4743 THREADED_TEST(NativeFunctionDeclarationErrorEscape) { 4743 THREADED_TEST(NativeFunctionDeclarationErrorEscape) {
4744 v8::HandleScope handle_scope; 4744 v8::HandleScope handle_scope;
4745 const char* name = "nativedeclerresc"; 4745 const char* name = "nativedeclerresc";
4746 // Syntax error in extension code - escape code in "native" means that 4746 // Syntax error in extension code - escape code in "native" means that
4747 // it's not treated as a keyword. 4747 // it's not treated as a keyword.
4748 v8::RegisterExtension(new NativeFunctionExtension( 4748 v8::RegisterExtension(new NativeFunctionExtension(
4749 name, 4749 name,
4750 "nativ\\u0065 function foo();")); 4750 "nativ\\u0065 function foo();"));
4751 const char* extension_names[] = { name }; 4751 const char* extension_names[] = { name };
4752 v8::ExtensionConfiguration extensions(1, extension_names); 4752 v8::ExtensionConfiguration extensions(1, extension_names);
4753 v8::Handle<Context> context = Context::New(&extensions); 4753 v8::Handle<Context> context(Context::New(&extensions));
4754 ASSERT(context.IsEmpty()); 4754 ASSERT(context.IsEmpty());
4755 } 4755 }
4756 4756
4757 4757
4758 static void CheckDependencies(const char* name, const char* expected) { 4758 static void CheckDependencies(const char* name, const char* expected) {
4759 v8::HandleScope handle_scope; 4759 v8::HandleScope handle_scope;
4760 v8::ExtensionConfiguration config(1, &name); 4760 v8::ExtensionConfiguration config(1, &name);
4761 LocalContext context(&config); 4761 LocalContext context(&config);
4762 CHECK_EQ(String::New(expected), context->Global()->Get(v8_str("loaded"))); 4762 CHECK_EQ(String::New(expected), context->Global()->Get(v8_str("loaded")));
4763 } 4763 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
4910 4910
4911 4911
4912 TEST(RegexpOutOfMemory) { 4912 TEST(RegexpOutOfMemory) {
4913 // Execute a script that causes out of memory when flattening a string. 4913 // Execute a script that causes out of memory when flattening a string.
4914 v8::HandleScope scope; 4914 v8::HandleScope scope;
4915 v8::V8::SetFatalErrorHandler(OOMCallback); 4915 v8::V8::SetFatalErrorHandler(OOMCallback);
4916 LocalContext context; 4916 LocalContext context;
4917 Local<Script> script = 4917 Local<Script> script =
4918 Script::Compile(String::New(js_code_causing_huge_string_flattening)); 4918 Script::Compile(String::New(js_code_causing_huge_string_flattening));
4919 last_location = NULL; 4919 last_location = NULL;
4920 Local<Value> result = script->Run(); 4920 Local<Value> result(script->Run());
4921 4921
4922 CHECK(false); // Should not return. 4922 CHECK(false); // Should not return.
4923 } 4923 }
4924 4924
4925 4925
4926 static void MissingScriptInfoMessageListener(v8::Handle<v8::Message> message, 4926 static void MissingScriptInfoMessageListener(v8::Handle<v8::Message> message,
4927 v8::Handle<Value> data) { 4927 v8::Handle<Value> data) {
4928 CHECK_EQ(v8::Undefined(), data); 4928 CHECK_EQ(v8::Undefined(), data);
4929 CHECK(message->GetScriptResourceName()->IsUndefined()); 4929 CHECK(message->GetScriptResourceName()->IsUndefined());
4930 CHECK_EQ(v8::Undefined(), message->GetScriptResourceName()); 4930 CHECK_EQ(v8::Undefined(), message->GetScriptResourceName());
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
5688 5688
5689 5689
5690 THREADED_TEST(ErrorConstruction) { 5690 THREADED_TEST(ErrorConstruction) {
5691 v8::HandleScope scope; 5691 v8::HandleScope scope;
5692 LocalContext context; 5692 LocalContext context;
5693 5693
5694 v8::Handle<String> foo = v8_str("foo"); 5694 v8::Handle<String> foo = v8_str("foo");
5695 v8::Handle<String> message = v8_str("message"); 5695 v8::Handle<String> message = v8_str("message");
5696 v8::Handle<Value> range_error = v8::Exception::RangeError(foo); 5696 v8::Handle<Value> range_error = v8::Exception::RangeError(foo);
5697 CHECK(range_error->IsObject()); 5697 CHECK(range_error->IsObject());
5698 v8::Handle<v8::Object> range_obj = range_error.As<v8::Object>(); 5698 v8::Handle<v8::Object> range_obj(range_error.As<v8::Object>());
5699 CHECK(range_error.As<v8::Object>()->Get(message)->Equals(foo)); 5699 CHECK(range_error.As<v8::Object>()->Get(message)->Equals(foo));
5700 v8::Handle<Value> reference_error = v8::Exception::ReferenceError(foo); 5700 v8::Handle<Value> reference_error = v8::Exception::ReferenceError(foo);
5701 CHECK(reference_error->IsObject()); 5701 CHECK(reference_error->IsObject());
5702 CHECK(reference_error.As<v8::Object>()->Get(message)->Equals(foo)); 5702 CHECK(reference_error.As<v8::Object>()->Get(message)->Equals(foo));
5703 v8::Handle<Value> syntax_error = v8::Exception::SyntaxError(foo); 5703 v8::Handle<Value> syntax_error = v8::Exception::SyntaxError(foo);
5704 CHECK(syntax_error->IsObject()); 5704 CHECK(syntax_error->IsObject());
5705 CHECK(syntax_error.As<v8::Object>()->Get(message)->Equals(foo)); 5705 CHECK(syntax_error.As<v8::Object>()->Get(message)->Equals(foo));
5706 v8::Handle<Value> type_error = v8::Exception::TypeError(foo); 5706 v8::Handle<Value> type_error = v8::Exception::TypeError(foo);
5707 CHECK(type_error->IsObject()); 5707 CHECK(type_error->IsObject());
5708 CHECK(type_error.As<v8::Object>()->Get(message)->Equals(foo)); 5708 CHECK(type_error.As<v8::Object>()->Get(message)->Equals(foo));
(...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after
7258 // Hold on to the global object so it can be used again in another 7258 // Hold on to the global object so it can be used again in another
7259 // environment initialization. 7259 // environment initialization.
7260 global_object = env->Global(); 7260 global_object = env->Global();
7261 foo = Script::Compile(v8_str(script))->Run(); 7261 foo = Script::Compile(v8_str(script))->Run();
7262 } 7262 }
7263 7263
7264 { 7264 {
7265 // Create new environment reusing the global object. 7265 // Create new environment reusing the global object.
7266 LocalContext env(NULL, instance_template, global_object); 7266 LocalContext env(NULL, instance_template, global_object);
7267 env->Global()->Set(v8_str("foo"), foo); 7267 env->Global()->Set(v8_str("foo"), foo);
7268 Local<Value> value = Script::Compile(v8_str("foo()"))->Run(); 7268 Local<Value> value(Script::Compile(v8_str("foo()"))->Run());
7269 } 7269 }
7270 } 7270 }
7271 7271
7272 7272
7273 static v8::Handle<Value> ShadowFunctionCallback(const v8::Arguments& args) { 7273 static v8::Handle<Value> ShadowFunctionCallback(const v8::Arguments& args) {
7274 ApiTestFuzzer::Fuzz(); 7274 ApiTestFuzzer::Fuzz();
7275 return v8_num(42); 7275 return v8_num(42);
7276 } 7276 }
7277 7277
7278 7278
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
7529 7529
7530 7530
7531 THREADED_TEST(Constructor) { 7531 THREADED_TEST(Constructor) {
7532 v8::HandleScope handle_scope; 7532 v8::HandleScope handle_scope;
7533 LocalContext context; 7533 LocalContext context;
7534 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); 7534 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
7535 templ->SetClassName(v8_str("Fun")); 7535 templ->SetClassName(v8_str("Fun"));
7536 Local<Function> cons = templ->GetFunction(); 7536 Local<Function> cons = templ->GetFunction();
7537 context->Global()->Set(v8_str("Fun"), cons); 7537 context->Global()->Set(v8_str("Fun"), cons);
7538 Local<v8::Object> inst = cons->NewInstance(); 7538 Local<v8::Object> inst = cons->NewInstance();
7539 i::Handle<i::JSObject> obj = v8::Utils::OpenHandle(*inst); 7539 i::Handle<i::JSObject> obj(v8::Utils::OpenHandle(*inst));
7540 Local<Value> value = CompileRun("(new Fun()).constructor === Fun"); 7540 Local<Value> value = CompileRun("(new Fun()).constructor === Fun");
7541 CHECK(value->BooleanValue()); 7541 CHECK(value->BooleanValue());
7542 } 7542 }
7543 7543
7544 7544
7545 static Handle<Value> ConstructorCallback(const Arguments& args) { 7545 static Handle<Value> ConstructorCallback(const Arguments& args) {
7546 ApiTestFuzzer::Fuzz(); 7546 ApiTestFuzzer::Fuzz();
7547 Local<Object> This; 7547 Local<Object> This;
7548 7548
7549 if (args.IsConstructCall()) { 7549 if (args.IsConstructCall()) {
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
8000 8000
8001 // Check that the call-as-function handler can be called through 8001 // Check that the call-as-function handler can be called through
8002 // the API. 8002 // the API.
8003 v8::Handle<Value> args[] = { v8_num(28) }; 8003 v8::Handle<Value> args[] = { v8_num(28) };
8004 value = instance->CallAsFunction(instance, 1, args); 8004 value = instance->CallAsFunction(instance, 1, args);
8005 CHECK(!try_catch.HasCaught()); 8005 CHECK(!try_catch.HasCaught());
8006 CHECK_EQ(28, value->Int32Value()); 8006 CHECK_EQ(28, value->Int32Value());
8007 } 8007 }
8008 8008
8009 { Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); 8009 { Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
8010 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); 8010 Local<ObjectTemplate> instance_template(t->InstanceTemplate());
8011 Local<v8::Object> instance = t->GetFunction()->NewInstance(); 8011 Local<v8::Object> instance = t->GetFunction()->NewInstance();
8012 context->Global()->Set(v8_str("obj2"), instance); 8012 context->Global()->Set(v8_str("obj2"), instance);
8013 v8::TryCatch try_catch; 8013 v8::TryCatch try_catch;
8014 Local<Value> value; 8014 Local<Value> value;
8015 CHECK(!try_catch.HasCaught()); 8015 CHECK(!try_catch.HasCaught());
8016 8016
8017 // Call an object without call-as-function handler through the JS 8017 // Call an object without call-as-function handler through the JS
8018 value = CompileRun("obj2(28)"); 8018 value = CompileRun("obj2(28)");
8019 CHECK(value.IsEmpty()); 8019 CHECK(value.IsEmpty());
8020 CHECK(try_catch.HasCaught()); 8020 CHECK(try_catch.HasCaught());
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
8105 8105
8106 static int CountHandles() { 8106 static int CountHandles() {
8107 return v8::HandleScope::NumberOfHandles(); 8107 return v8::HandleScope::NumberOfHandles();
8108 } 8108 }
8109 8109
8110 8110
8111 static int Recurse(int depth, int iterations) { 8111 static int Recurse(int depth, int iterations) {
8112 v8::HandleScope scope; 8112 v8::HandleScope scope;
8113 if (depth == 0) return CountHandles(); 8113 if (depth == 0) return CountHandles();
8114 for (int i = 0; i < iterations; i++) { 8114 for (int i = 0; i < iterations; i++) {
8115 Local<v8::Number> n = v8::Integer::New(42); 8115 Local<v8::Number> n(v8::Integer::New(42));
8116 } 8116 }
8117 return Recurse(depth - 1, iterations); 8117 return Recurse(depth - 1, iterations);
8118 } 8118 }
8119 8119
8120 8120
8121 THREADED_TEST(HandleIteration) { 8121 THREADED_TEST(HandleIteration) {
8122 static const int kIterations = 500; 8122 static const int kIterations = 500;
8123 static const int kNesting = 200; 8123 static const int kNesting = 200;
8124 CHECK_EQ(0, CountHandles()); 8124 CHECK_EQ(0, CountHandles());
8125 { 8125 {
8126 v8::HandleScope scope1; 8126 v8::HandleScope scope1;
8127 CHECK_EQ(0, CountHandles()); 8127 CHECK_EQ(0, CountHandles());
8128 for (int i = 0; i < kIterations; i++) { 8128 for (int i = 0; i < kIterations; i++) {
8129 Local<v8::Number> n = v8::Integer::New(42); 8129 Local<v8::Number> n(v8::Integer::New(42));
8130 CHECK_EQ(i + 1, CountHandles()); 8130 CHECK_EQ(i + 1, CountHandles());
8131 } 8131 }
8132 8132
8133 CHECK_EQ(kIterations, CountHandles()); 8133 CHECK_EQ(kIterations, CountHandles());
8134 { 8134 {
8135 v8::HandleScope scope2; 8135 v8::HandleScope scope2;
8136 for (int j = 0; j < kIterations; j++) { 8136 for (int j = 0; j < kIterations; j++) {
8137 Local<v8::Number> n = v8::Integer::New(42); 8137 Local<v8::Number> n(v8::Integer::New(42));
8138 CHECK_EQ(j + 1 + kIterations, CountHandles()); 8138 CHECK_EQ(j + 1 + kIterations, CountHandles());
8139 } 8139 }
8140 } 8140 }
8141 CHECK_EQ(kIterations, CountHandles()); 8141 CHECK_EQ(kIterations, CountHandles());
8142 } 8142 }
8143 CHECK_EQ(0, CountHandles()); 8143 CHECK_EQ(0, CountHandles());
8144 CHECK_EQ(kNesting * kIterations, Recurse(kNesting, kIterations)); 8144 CHECK_EQ(kNesting * kIterations, Recurse(kNesting, kIterations));
8145 } 8145 }
8146 8146
8147 8147
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
8630 8630
8631 // This test should hit the store IC for the interceptor case. 8631 // This test should hit the store IC for the interceptor case.
8632 THREADED_TEST(InterceptorStoreIC) { 8632 THREADED_TEST(InterceptorStoreIC) {
8633 v8::HandleScope scope; 8633 v8::HandleScope scope;
8634 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); 8634 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
8635 templ->SetNamedPropertyHandler(InterceptorLoadICGetter, 8635 templ->SetNamedPropertyHandler(InterceptorLoadICGetter,
8636 InterceptorStoreICSetter, 8636 InterceptorStoreICSetter,
8637 0, 0, 0, v8_str("data")); 8637 0, 0, 0, v8_str("data"));
8638 LocalContext context; 8638 LocalContext context;
8639 context->Global()->Set(v8_str("o"), templ->NewInstance()); 8639 context->Global()->Set(v8_str("o"), templ->NewInstance());
8640 v8::Handle<Value> value = CompileRun( 8640 v8::Handle<Value> value(CompileRun(
8641 "for (var i = 0; i < 1000; i++) {" 8641 "for (var i = 0; i < 1000; i++) {"
8642 " o.x = 42;" 8642 " o.x = 42;"
8643 "}"); 8643 "}"));
8644 } 8644 }
8645 8645
8646 8646
8647 THREADED_TEST(InterceptorStoreICWithNoSetter) { 8647 THREADED_TEST(InterceptorStoreICWithNoSetter) {
8648 v8::HandleScope scope; 8648 v8::HandleScope scope;
8649 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); 8649 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
8650 templ->SetNamedPropertyHandler(InterceptorLoadXICGetter); 8650 templ->SetNamedPropertyHandler(InterceptorLoadXICGetter);
8651 LocalContext context; 8651 LocalContext context;
8652 context->Global()->Set(v8_str("o"), templ->NewInstance()); 8652 context->Global()->Set(v8_str("o"), templ->NewInstance());
8653 v8::Handle<Value> value = CompileRun( 8653 v8::Handle<Value> value = CompileRun(
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
9059 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 9059 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
9060 proto_templ->Set(v8_str("method"), method_templ); 9060 proto_templ->Set(v8_str("method"), method_templ);
9061 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); 9061 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
9062 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, 9062 templ->SetNamedPropertyHandler(InterceptorCallICFastApi,
9063 NULL, NULL, NULL, NULL, 9063 NULL, NULL, NULL, NULL,
9064 v8::External::Wrap(&interceptor_call_count)); 9064 v8::External::Wrap(&interceptor_call_count));
9065 LocalContext context; 9065 LocalContext context;
9066 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 9066 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
9067 GenerateSomeGarbage(); 9067 GenerateSomeGarbage();
9068 context->Global()->Set(v8_str("o"), fun->NewInstance()); 9068 context->Global()->Set(v8_str("o"), fun->NewInstance());
9069 v8::Handle<Value> value = CompileRun( 9069 v8::Handle<Value> value(CompileRun(
9070 "var result = 0;" 9070 "var result = 0;"
9071 "for (var i = 0; i < 100; i++) {" 9071 "for (var i = 0; i < 100; i++) {"
9072 " result = o.method(41);" 9072 " result = o.method(41);"
9073 "}"); 9073 "}"));
9074 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); 9074 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value());
9075 CHECK_EQ(100, interceptor_call_count); 9075 CHECK_EQ(100, interceptor_call_count);
9076 } 9076 }
9077 9077
9078 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature) { 9078 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature) {
9079 int interceptor_call_count = 0; 9079 int interceptor_call_count = 0;
9080 v8::HandleScope scope; 9080 v8::HandleScope scope;
9081 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 9081 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
9082 v8::Handle<v8::FunctionTemplate> method_templ = 9082 v8::Handle<v8::FunctionTemplate> method_templ =
9083 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 9083 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
9084 v8_str("method_data"), 9084 v8_str("method_data"),
9085 v8::Signature::New(fun_templ)); 9085 v8::Signature::New(fun_templ));
9086 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 9086 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
9087 proto_templ->Set(v8_str("method"), method_templ); 9087 proto_templ->Set(v8_str("method"), method_templ);
9088 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); 9088 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
9089 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, 9089 templ->SetNamedPropertyHandler(InterceptorCallICFastApi,
9090 NULL, NULL, NULL, NULL, 9090 NULL, NULL, NULL, NULL,
9091 v8::External::Wrap(&interceptor_call_count)); 9091 v8::External::Wrap(&interceptor_call_count));
9092 LocalContext context; 9092 LocalContext context;
9093 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 9093 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
9094 GenerateSomeGarbage(); 9094 GenerateSomeGarbage();
9095 context->Global()->Set(v8_str("o"), fun->NewInstance()); 9095 context->Global()->Set(v8_str("o"), fun->NewInstance());
9096 v8::Handle<Value> value = CompileRun( 9096 v8::Handle<Value> value(CompileRun(
9097 "o.foo = 17;" 9097 "o.foo = 17;"
9098 "var receiver = {};" 9098 "var receiver = {};"
9099 "receiver.__proto__ = o;" 9099 "receiver.__proto__ = o;"
9100 "var result = 0;" 9100 "var result = 0;"
9101 "for (var i = 0; i < 100; i++) {" 9101 "for (var i = 0; i < 100; i++) {"
9102 " result = receiver.method(41);" 9102 " result = receiver.method(41);"
9103 "}"); 9103 "}"));
9104 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); 9104 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value());
9105 CHECK_EQ(100, interceptor_call_count); 9105 CHECK_EQ(100, interceptor_call_count);
9106 } 9106 }
9107 9107
9108 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss1) { 9108 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss1) {
9109 int interceptor_call_count = 0; 9109 int interceptor_call_count = 0;
9110 v8::HandleScope scope; 9110 v8::HandleScope scope;
9111 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 9111 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
9112 v8::Handle<v8::FunctionTemplate> method_templ = 9112 v8::Handle<v8::FunctionTemplate> method_templ =
9113 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 9113 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
9114 v8_str("method_data"), 9114 v8_str("method_data"),
9115 v8::Signature::New(fun_templ)); 9115 v8::Signature::New(fun_templ));
9116 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 9116 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
9117 proto_templ->Set(v8_str("method"), method_templ); 9117 proto_templ->Set(v8_str("method"), method_templ);
9118 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); 9118 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
9119 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, 9119 templ->SetNamedPropertyHandler(InterceptorCallICFastApi,
9120 NULL, NULL, NULL, NULL, 9120 NULL, NULL, NULL, NULL,
9121 v8::External::Wrap(&interceptor_call_count)); 9121 v8::External::Wrap(&interceptor_call_count));
9122 LocalContext context; 9122 LocalContext context;
9123 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 9123 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
9124 GenerateSomeGarbage(); 9124 GenerateSomeGarbage();
9125 context->Global()->Set(v8_str("o"), fun->NewInstance()); 9125 context->Global()->Set(v8_str("o"), fun->NewInstance());
9126 v8::Handle<Value> value = CompileRun( 9126 v8::Handle<Value> value(CompileRun(
9127 "o.foo = 17;" 9127 "o.foo = 17;"
9128 "var receiver = {};" 9128 "var receiver = {};"
9129 "receiver.__proto__ = o;" 9129 "receiver.__proto__ = o;"
9130 "var result = 0;" 9130 "var result = 0;"
9131 "var saved_result = 0;" 9131 "var saved_result = 0;"
9132 "for (var i = 0; i < 100; i++) {" 9132 "for (var i = 0; i < 100; i++) {"
9133 " result = receiver.method(41);" 9133 " result = receiver.method(41);"
9134 " if (i == 50) {" 9134 " if (i == 50) {"
9135 " saved_result = result;" 9135 " saved_result = result;"
9136 " receiver = {method: function(x) { return x - 1 }};" 9136 " receiver = {method: function(x) { return x - 1 }};"
9137 " }" 9137 " }"
9138 "}"); 9138 "}"));
9139 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); 9139 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value());
9140 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); 9140 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
9141 CHECK_GE(interceptor_call_count, 50); 9141 CHECK_GE(interceptor_call_count, 50);
9142 } 9142 }
9143 9143
9144 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss2) { 9144 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss2) {
9145 int interceptor_call_count = 0; 9145 int interceptor_call_count = 0;
9146 v8::HandleScope scope; 9146 v8::HandleScope scope;
9147 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 9147 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
9148 v8::Handle<v8::FunctionTemplate> method_templ = 9148 v8::Handle<v8::FunctionTemplate> method_templ =
9149 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 9149 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
9150 v8_str("method_data"), 9150 v8_str("method_data"),
9151 v8::Signature::New(fun_templ)); 9151 v8::Signature::New(fun_templ));
9152 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 9152 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
9153 proto_templ->Set(v8_str("method"), method_templ); 9153 proto_templ->Set(v8_str("method"), method_templ);
9154 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); 9154 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
9155 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, 9155 templ->SetNamedPropertyHandler(InterceptorCallICFastApi,
9156 NULL, NULL, NULL, NULL, 9156 NULL, NULL, NULL, NULL,
9157 v8::External::Wrap(&interceptor_call_count)); 9157 v8::External::Wrap(&interceptor_call_count));
9158 LocalContext context; 9158 LocalContext context;
9159 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 9159 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
9160 GenerateSomeGarbage(); 9160 GenerateSomeGarbage();
9161 context->Global()->Set(v8_str("o"), fun->NewInstance()); 9161 context->Global()->Set(v8_str("o"), fun->NewInstance());
9162 v8::Handle<Value> value = CompileRun( 9162 v8::Handle<Value> value(CompileRun(
9163 "o.foo = 17;" 9163 "o.foo = 17;"
9164 "var receiver = {};" 9164 "var receiver = {};"
9165 "receiver.__proto__ = o;" 9165 "receiver.__proto__ = o;"
9166 "var result = 0;" 9166 "var result = 0;"
9167 "var saved_result = 0;" 9167 "var saved_result = 0;"
9168 "for (var i = 0; i < 100; i++) {" 9168 "for (var i = 0; i < 100; i++) {"
9169 " result = receiver.method(41);" 9169 " result = receiver.method(41);"
9170 " if (i == 50) {" 9170 " if (i == 50) {"
9171 " saved_result = result;" 9171 " saved_result = result;"
9172 " o.method = function(x) { return x - 1 };" 9172 " o.method = function(x) { return x - 1 };"
9173 " }" 9173 " }"
9174 "}"); 9174 "}"));
9175 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); 9175 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value());
9176 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); 9176 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
9177 CHECK_GE(interceptor_call_count, 50); 9177 CHECK_GE(interceptor_call_count, 50);
9178 } 9178 }
9179 9179
9180 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss3) { 9180 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss3) {
9181 int interceptor_call_count = 0; 9181 int interceptor_call_count = 0;
9182 v8::HandleScope scope; 9182 v8::HandleScope scope;
9183 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 9183 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
9184 v8::Handle<v8::FunctionTemplate> method_templ = 9184 v8::Handle<v8::FunctionTemplate> method_templ =
9185 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 9185 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
9186 v8_str("method_data"), 9186 v8_str("method_data"),
9187 v8::Signature::New(fun_templ)); 9187 v8::Signature::New(fun_templ));
9188 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 9188 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
9189 proto_templ->Set(v8_str("method"), method_templ); 9189 proto_templ->Set(v8_str("method"), method_templ);
9190 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); 9190 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
9191 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, 9191 templ->SetNamedPropertyHandler(InterceptorCallICFastApi,
9192 NULL, NULL, NULL, NULL, 9192 NULL, NULL, NULL, NULL,
9193 v8::External::Wrap(&interceptor_call_count)); 9193 v8::External::Wrap(&interceptor_call_count));
9194 LocalContext context; 9194 LocalContext context;
9195 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 9195 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
9196 GenerateSomeGarbage(); 9196 GenerateSomeGarbage();
9197 context->Global()->Set(v8_str("o"), fun->NewInstance()); 9197 context->Global()->Set(v8_str("o"), fun->NewInstance());
9198 v8::TryCatch try_catch; 9198 v8::TryCatch try_catch;
9199 v8::Handle<Value> value = CompileRun( 9199 v8::Handle<Value> value(CompileRun(
9200 "o.foo = 17;" 9200 "o.foo = 17;"
9201 "var receiver = {};" 9201 "var receiver = {};"
9202 "receiver.__proto__ = o;" 9202 "receiver.__proto__ = o;"
9203 "var result = 0;" 9203 "var result = 0;"
9204 "var saved_result = 0;" 9204 "var saved_result = 0;"
9205 "for (var i = 0; i < 100; i++) {" 9205 "for (var i = 0; i < 100; i++) {"
9206 " result = receiver.method(41);" 9206 " result = receiver.method(41);"
9207 " if (i == 50) {" 9207 " if (i == 50) {"
9208 " saved_result = result;" 9208 " saved_result = result;"
9209 " receiver = 333;" 9209 " receiver = 333;"
9210 " }" 9210 " }"
9211 "}"); 9211 "}"));
9212 CHECK(try_catch.HasCaught()); 9212 CHECK(try_catch.HasCaught());
9213 CHECK_EQ(v8_str("TypeError: Object 333 has no method 'method'"), 9213 CHECK_EQ(v8_str("TypeError: Object 333 has no method 'method'"),
9214 try_catch.Exception()->ToString()); 9214 try_catch.Exception()->ToString());
9215 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); 9215 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
9216 CHECK_GE(interceptor_call_count, 50); 9216 CHECK_GE(interceptor_call_count, 50);
9217 } 9217 }
9218 9218
9219 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) { 9219 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) {
9220 int interceptor_call_count = 0; 9220 int interceptor_call_count = 0;
9221 v8::HandleScope scope; 9221 v8::HandleScope scope;
9222 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 9222 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
9223 v8::Handle<v8::FunctionTemplate> method_templ = 9223 v8::Handle<v8::FunctionTemplate> method_templ =
9224 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 9224 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
9225 v8_str("method_data"), 9225 v8_str("method_data"),
9226 v8::Signature::New(fun_templ)); 9226 v8::Signature::New(fun_templ));
9227 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 9227 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
9228 proto_templ->Set(v8_str("method"), method_templ); 9228 proto_templ->Set(v8_str("method"), method_templ);
9229 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); 9229 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
9230 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, 9230 templ->SetNamedPropertyHandler(InterceptorCallICFastApi,
9231 NULL, NULL, NULL, NULL, 9231 NULL, NULL, NULL, NULL,
9232 v8::External::Wrap(&interceptor_call_count)); 9232 v8::External::Wrap(&interceptor_call_count));
9233 LocalContext context; 9233 LocalContext context;
9234 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 9234 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
9235 GenerateSomeGarbage(); 9235 GenerateSomeGarbage();
9236 context->Global()->Set(v8_str("o"), fun->NewInstance()); 9236 context->Global()->Set(v8_str("o"), fun->NewInstance());
9237 v8::TryCatch try_catch; 9237 v8::TryCatch try_catch;
9238 v8::Handle<Value> value = CompileRun( 9238 v8::Handle<Value> value(CompileRun(
9239 "o.foo = 17;" 9239 "o.foo = 17;"
9240 "var receiver = {};" 9240 "var receiver = {};"
9241 "receiver.__proto__ = o;" 9241 "receiver.__proto__ = o;"
9242 "var result = 0;" 9242 "var result = 0;"
9243 "var saved_result = 0;" 9243 "var saved_result = 0;"
9244 "for (var i = 0; i < 100; i++) {" 9244 "for (var i = 0; i < 100; i++) {"
9245 " result = receiver.method(41);" 9245 " result = receiver.method(41);"
9246 " if (i == 50) {" 9246 " if (i == 50) {"
9247 " saved_result = result;" 9247 " saved_result = result;"
9248 " receiver = {method: receiver.method};" 9248 " receiver = {method: receiver.method};"
9249 " }" 9249 " }"
9250 "}"); 9250 "}"));
9251 CHECK(try_catch.HasCaught()); 9251 CHECK(try_catch.HasCaught());
9252 CHECK_EQ(v8_str("TypeError: Illegal invocation"), 9252 CHECK_EQ(v8_str("TypeError: Illegal invocation"),
9253 try_catch.Exception()->ToString()); 9253 try_catch.Exception()->ToString());
9254 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); 9254 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
9255 CHECK_GE(interceptor_call_count, 50); 9255 CHECK_GE(interceptor_call_count, 50);
9256 } 9256 }
9257 9257
9258 THREADED_TEST(CallICFastApi_TrivialSignature) { 9258 THREADED_TEST(CallICFastApi_TrivialSignature) {
9259 v8::HandleScope scope; 9259 v8::HandleScope scope;
9260 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 9260 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
9261 v8::Handle<v8::FunctionTemplate> method_templ = 9261 v8::Handle<v8::FunctionTemplate> method_templ =
9262 v8::FunctionTemplate::New(FastApiCallback_TrivialSignature, 9262 v8::FunctionTemplate::New(FastApiCallback_TrivialSignature,
9263 v8_str("method_data"), 9263 v8_str("method_data"),
9264 v8::Handle<v8::Signature>()); 9264 v8::Handle<v8::Signature>());
9265 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 9265 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
9266 proto_templ->Set(v8_str("method"), method_templ); 9266 proto_templ->Set(v8_str("method"), method_templ);
9267 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); 9267 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
9268 LocalContext context; 9268 LocalContext context;
9269 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 9269 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
9270 GenerateSomeGarbage(); 9270 GenerateSomeGarbage();
9271 context->Global()->Set(v8_str("o"), fun->NewInstance()); 9271 context->Global()->Set(v8_str("o"), fun->NewInstance());
9272 v8::Handle<Value> value = CompileRun( 9272 v8::Handle<Value> value(CompileRun(
9273 "var result = 0;" 9273 "var result = 0;"
9274 "for (var i = 0; i < 100; i++) {" 9274 "for (var i = 0; i < 100; i++) {"
9275 " result = o.method(41);" 9275 " result = o.method(41);"
9276 "}"); 9276 "}"));
9277 9277
9278 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); 9278 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value());
9279 } 9279 }
9280 9280
9281 THREADED_TEST(CallICFastApi_SimpleSignature) { 9281 THREADED_TEST(CallICFastApi_SimpleSignature) {
9282 v8::HandleScope scope; 9282 v8::HandleScope scope;
9283 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 9283 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
9284 v8::Handle<v8::FunctionTemplate> method_templ = 9284 v8::Handle<v8::FunctionTemplate> method_templ =
9285 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 9285 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
9286 v8_str("method_data"), 9286 v8_str("method_data"),
9287 v8::Signature::New(fun_templ)); 9287 v8::Signature::New(fun_templ));
9288 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 9288 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
9289 proto_templ->Set(v8_str("method"), method_templ); 9289 proto_templ->Set(v8_str("method"), method_templ);
9290 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); 9290 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
9291 LocalContext context; 9291 LocalContext context;
9292 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 9292 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
9293 GenerateSomeGarbage(); 9293 GenerateSomeGarbage();
9294 context->Global()->Set(v8_str("o"), fun->NewInstance()); 9294 context->Global()->Set(v8_str("o"), fun->NewInstance());
9295 v8::Handle<Value> value = CompileRun( 9295 v8::Handle<Value> value(CompileRun(
9296 "o.foo = 17;" 9296 "o.foo = 17;"
9297 "var receiver = {};" 9297 "var receiver = {};"
9298 "receiver.__proto__ = o;" 9298 "receiver.__proto__ = o;"
9299 "var result = 0;" 9299 "var result = 0;"
9300 "for (var i = 0; i < 100; i++) {" 9300 "for (var i = 0; i < 100; i++) {"
9301 " result = receiver.method(41);" 9301 " result = receiver.method(41);"
9302 "}"); 9302 "}"));
9303 9303
9304 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); 9304 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value());
9305 } 9305 }
9306 9306
9307 THREADED_TEST(CallICFastApi_SimpleSignature_Miss1) { 9307 THREADED_TEST(CallICFastApi_SimpleSignature_Miss1) {
9308 v8::HandleScope scope; 9308 v8::HandleScope scope;
9309 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 9309 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
9310 v8::Handle<v8::FunctionTemplate> method_templ = 9310 v8::Handle<v8::FunctionTemplate> method_templ =
9311 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 9311 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
9312 v8_str("method_data"), 9312 v8_str("method_data"),
9313 v8::Signature::New(fun_templ)); 9313 v8::Signature::New(fun_templ));
9314 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 9314 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
9315 proto_templ->Set(v8_str("method"), method_templ); 9315 proto_templ->Set(v8_str("method"), method_templ);
9316 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); 9316 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
9317 LocalContext context; 9317 LocalContext context;
9318 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 9318 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
9319 GenerateSomeGarbage(); 9319 GenerateSomeGarbage();
9320 context->Global()->Set(v8_str("o"), fun->NewInstance()); 9320 context->Global()->Set(v8_str("o"), fun->NewInstance());
9321 v8::Handle<Value> value = CompileRun( 9321 v8::Handle<Value> value(CompileRun(
9322 "o.foo = 17;" 9322 "o.foo = 17;"
9323 "var receiver = {};" 9323 "var receiver = {};"
9324 "receiver.__proto__ = o;" 9324 "receiver.__proto__ = o;"
9325 "var result = 0;" 9325 "var result = 0;"
9326 "var saved_result = 0;" 9326 "var saved_result = 0;"
9327 "for (var i = 0; i < 100; i++) {" 9327 "for (var i = 0; i < 100; i++) {"
9328 " result = receiver.method(41);" 9328 " result = receiver.method(41);"
9329 " if (i == 50) {" 9329 " if (i == 50) {"
9330 " saved_result = result;" 9330 " saved_result = result;"
9331 " receiver = {method: function(x) { return x - 1 }};" 9331 " receiver = {method: function(x) { return x - 1 }};"
9332 " }" 9332 " }"
9333 "}"); 9333 "}"));
9334 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); 9334 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value());
9335 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); 9335 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
9336 } 9336 }
9337 9337
9338 THREADED_TEST(CallICFastApi_SimpleSignature_Miss2) { 9338 THREADED_TEST(CallICFastApi_SimpleSignature_Miss2) {
9339 v8::HandleScope scope; 9339 v8::HandleScope scope;
9340 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 9340 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
9341 v8::Handle<v8::FunctionTemplate> method_templ = 9341 v8::Handle<v8::FunctionTemplate> method_templ =
9342 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 9342 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
9343 v8_str("method_data"), 9343 v8_str("method_data"),
9344 v8::Signature::New(fun_templ)); 9344 v8::Signature::New(fun_templ));
9345 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 9345 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
9346 proto_templ->Set(v8_str("method"), method_templ); 9346 proto_templ->Set(v8_str("method"), method_templ);
9347 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); 9347 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
9348 LocalContext context; 9348 LocalContext context;
9349 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 9349 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
9350 GenerateSomeGarbage(); 9350 GenerateSomeGarbage();
9351 context->Global()->Set(v8_str("o"), fun->NewInstance()); 9351 context->Global()->Set(v8_str("o"), fun->NewInstance());
9352 v8::TryCatch try_catch; 9352 v8::TryCatch try_catch;
9353 v8::Handle<Value> value = CompileRun( 9353 v8::Handle<Value> value(CompileRun(
9354 "o.foo = 17;" 9354 "o.foo = 17;"
9355 "var receiver = {};" 9355 "var receiver = {};"
9356 "receiver.__proto__ = o;" 9356 "receiver.__proto__ = o;"
9357 "var result = 0;" 9357 "var result = 0;"
9358 "var saved_result = 0;" 9358 "var saved_result = 0;"
9359 "for (var i = 0; i < 100; i++) {" 9359 "for (var i = 0; i < 100; i++) {"
9360 " result = receiver.method(41);" 9360 " result = receiver.method(41);"
9361 " if (i == 50) {" 9361 " if (i == 50) {"
9362 " saved_result = result;" 9362 " saved_result = result;"
9363 " receiver = 333;" 9363 " receiver = 333;"
9364 " }" 9364 " }"
9365 "}"); 9365 "}"));
9366 CHECK(try_catch.HasCaught()); 9366 CHECK(try_catch.HasCaught());
9367 CHECK_EQ(v8_str("TypeError: Object 333 has no method 'method'"), 9367 CHECK_EQ(v8_str("TypeError: Object 333 has no method 'method'"),
9368 try_catch.Exception()->ToString()); 9368 try_catch.Exception()->ToString());
9369 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); 9369 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
9370 } 9370 }
9371 9371
9372 9372
9373 v8::Handle<Value> keyed_call_ic_function; 9373 v8::Handle<Value> keyed_call_ic_function;
9374 9374
9375 static v8::Handle<Value> InterceptorKeyedCallICGetter( 9375 static v8::Handle<Value> InterceptorKeyedCallICGetter(
9376 Local<String> name, const AccessorInfo& info) { 9376 Local<String> name, const AccessorInfo& info) {
9377 ApiTestFuzzer::Fuzz(); 9377 ApiTestFuzzer::Fuzz();
9378 if (v8_str("x")->Equals(name)) { 9378 if (v8_str("x")->Equals(name)) {
9379 return keyed_call_ic_function; 9379 return keyed_call_ic_function;
9380 } 9380 }
9381 return v8::Handle<Value>(); 9381 return v8::Handle<Value>();
9382 } 9382 }
9383 9383
9384 9384
9385 // Test the case when we stored cacheable lookup into 9385 // Test the case when we stored cacheable lookup into
9386 // a stub, but the function name changed (to another cacheable function). 9386 // a stub, but the function name changed (to another cacheable function).
9387 THREADED_TEST(InterceptorKeyedCallICKeyChange1) { 9387 THREADED_TEST(InterceptorKeyedCallICKeyChange1) {
9388 v8::HandleScope scope; 9388 v8::HandleScope scope;
9389 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); 9389 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
9390 templ->SetNamedPropertyHandler(NoBlockGetterX); 9390 templ->SetNamedPropertyHandler(NoBlockGetterX);
9391 LocalContext context; 9391 LocalContext context;
9392 context->Global()->Set(v8_str("o"), templ->NewInstance()); 9392 context->Global()->Set(v8_str("o"), templ->NewInstance());
9393 v8::Handle<Value> value = CompileRun( 9393 v8::Handle<Value> value(CompileRun(
9394 "proto = new Object();" 9394 "proto = new Object();"
9395 "proto.y = function(x) { return x + 1; };" 9395 "proto.y = function(x) { return x + 1; };"
9396 "proto.z = function(x) { return x - 1; };" 9396 "proto.z = function(x) { return x - 1; };"
9397 "o.__proto__ = proto;" 9397 "o.__proto__ = proto;"
9398 "var result = 0;" 9398 "var result = 0;"
9399 "var method = 'y';" 9399 "var method = 'y';"
9400 "for (var i = 0; i < 10; i++) {" 9400 "for (var i = 0; i < 10; i++) {"
9401 " if (i == 5) { method = 'z'; };" 9401 " if (i == 5) { method = 'z'; };"
9402 " result += o[method](41);" 9402 " result += o[method](41);"
9403 "}"); 9403 "}"));
9404 CHECK_EQ(42*5 + 40*5, context->Global()->Get(v8_str("result"))->Int32Value()); 9404 CHECK_EQ(42*5 + 40*5, context->Global()->Get(v8_str("result"))->Int32Value());
9405 } 9405 }
9406 9406
9407 9407
9408 // Test the case when we stored cacheable lookup into 9408 // Test the case when we stored cacheable lookup into
9409 // a stub, but the function name changed (and the new function is present 9409 // a stub, but the function name changed (and the new function is present
9410 // both before and after the interceptor in the prototype chain). 9410 // both before and after the interceptor in the prototype chain).
9411 THREADED_TEST(InterceptorKeyedCallICKeyChange2) { 9411 THREADED_TEST(InterceptorKeyedCallICKeyChange2) {
9412 v8::HandleScope scope; 9412 v8::HandleScope scope;
9413 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); 9413 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
9414 templ->SetNamedPropertyHandler(InterceptorKeyedCallICGetter); 9414 templ->SetNamedPropertyHandler(InterceptorKeyedCallICGetter);
9415 LocalContext context; 9415 LocalContext context;
9416 context->Global()->Set(v8_str("proto1"), templ->NewInstance()); 9416 context->Global()->Set(v8_str("proto1"), templ->NewInstance());
9417 keyed_call_ic_function = 9417 keyed_call_ic_function =
9418 v8_compile("function f(x) { return x - 1; }; f")->Run(); 9418 v8_compile("function f(x) { return x - 1; }; f")->Run();
9419 v8::Handle<Value> value = CompileRun( 9419 v8::Handle<Value> value(CompileRun(
9420 "o = new Object();" 9420 "o = new Object();"
9421 "proto2 = new Object();" 9421 "proto2 = new Object();"
9422 "o.y = function(x) { return x + 1; };" 9422 "o.y = function(x) { return x + 1; };"
9423 "proto2.y = function(x) { return x + 2; };" 9423 "proto2.y = function(x) { return x + 2; };"
9424 "o.__proto__ = proto1;" 9424 "o.__proto__ = proto1;"
9425 "proto1.__proto__ = proto2;" 9425 "proto1.__proto__ = proto2;"
9426 "var result = 0;" 9426 "var result = 0;"
9427 "var method = 'x';" 9427 "var method = 'x';"
9428 "for (var i = 0; i < 10; i++) {" 9428 "for (var i = 0; i < 10; i++) {"
9429 " if (i == 5) { method = 'y'; };" 9429 " if (i == 5) { method = 'y'; };"
9430 " result += o[method](41);" 9430 " result += o[method](41);"
9431 "}"); 9431 "}"));
9432 CHECK_EQ(42*5 + 40*5, context->Global()->Get(v8_str("result"))->Int32Value()); 9432 CHECK_EQ(42*5 + 40*5, context->Global()->Get(v8_str("result"))->Int32Value());
9433 } 9433 }
9434 9434
9435 9435
9436 // Same as InterceptorKeyedCallICKeyChange1 only the cacheable function sit 9436 // Same as InterceptorKeyedCallICKeyChange1 only the cacheable function sit
9437 // on the global object. 9437 // on the global object.
9438 THREADED_TEST(InterceptorKeyedCallICKeyChangeOnGlobal) { 9438 THREADED_TEST(InterceptorKeyedCallICKeyChangeOnGlobal) {
9439 v8::HandleScope scope; 9439 v8::HandleScope scope;
9440 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); 9440 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
9441 templ->SetNamedPropertyHandler(NoBlockGetterX); 9441 templ->SetNamedPropertyHandler(NoBlockGetterX);
9442 LocalContext context; 9442 LocalContext context;
9443 context->Global()->Set(v8_str("o"), templ->NewInstance()); 9443 context->Global()->Set(v8_str("o"), templ->NewInstance());
9444 v8::Handle<Value> value = CompileRun( 9444 v8::Handle<Value> value(CompileRun(
9445 "function inc(x) { return x + 1; };" 9445 "function inc(x) { return x + 1; };"
9446 "inc(1);" 9446 "inc(1);"
9447 "function dec(x) { return x - 1; };" 9447 "function dec(x) { return x - 1; };"
9448 "dec(1);" 9448 "dec(1);"
9449 "o.__proto__ = this;" 9449 "o.__proto__ = this;"
9450 "this.__proto__.x = inc;" 9450 "this.__proto__.x = inc;"
9451 "this.__proto__.y = dec;" 9451 "this.__proto__.y = dec;"
9452 "var result = 0;" 9452 "var result = 0;"
9453 "var method = 'x';" 9453 "var method = 'x';"
9454 "for (var i = 0; i < 10; i++) {" 9454 "for (var i = 0; i < 10; i++) {"
9455 " if (i == 5) { method = 'y'; };" 9455 " if (i == 5) { method = 'y'; };"
9456 " result += o[method](41);" 9456 " result += o[method](41);"
9457 "}"); 9457 "}"));
9458 CHECK_EQ(42*5 + 40*5, context->Global()->Get(v8_str("result"))->Int32Value()); 9458 CHECK_EQ(42*5 + 40*5, context->Global()->Get(v8_str("result"))->Int32Value());
9459 } 9459 }
9460 9460
9461 9461
9462 // Test the case when actual function to call sits on global object. 9462 // Test the case when actual function to call sits on global object.
9463 THREADED_TEST(InterceptorKeyedCallICFromGlobal) { 9463 THREADED_TEST(InterceptorKeyedCallICFromGlobal) {
9464 v8::HandleScope scope; 9464 v8::HandleScope scope;
9465 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); 9465 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New();
9466 templ_o->SetNamedPropertyHandler(NoBlockGetterX); 9466 templ_o->SetNamedPropertyHandler(NoBlockGetterX);
9467 LocalContext context; 9467 LocalContext context;
9468 context->Global()->Set(v8_str("o"), templ_o->NewInstance()); 9468 context->Global()->Set(v8_str("o"), templ_o->NewInstance());
9469 9469
9470 v8::Handle<Value> value = CompileRun( 9470 v8::Handle<Value> value(CompileRun(
9471 "function len(x) { return x.length; };" 9471 "function len(x) { return x.length; };"
9472 "o.__proto__ = this;" 9472 "o.__proto__ = this;"
9473 "var m = 'parseFloat';" 9473 "var m = 'parseFloat';"
9474 "var result = 0;" 9474 "var result = 0;"
9475 "for (var i = 0; i < 10; i++) {" 9475 "for (var i = 0; i < 10; i++) {"
9476 " if (i == 5) {" 9476 " if (i == 5) {"
9477 " m = 'len';" 9477 " m = 'len';"
9478 " saved_result = result;" 9478 " saved_result = result;"
9479 " };" 9479 " };"
9480 " result = o[m]('239');" 9480 " result = o[m]('239');"
9481 "}"); 9481 "}"));
9482 CHECK_EQ(3, context->Global()->Get(v8_str("result"))->Int32Value()); 9482 CHECK_EQ(3, context->Global()->Get(v8_str("result"))->Int32Value());
9483 CHECK_EQ(239, context->Global()->Get(v8_str("saved_result"))->Int32Value()); 9483 CHECK_EQ(239, context->Global()->Get(v8_str("saved_result"))->Int32Value());
9484 } 9484 }
9485 9485
9486 // Test the map transition before the interceptor. 9486 // Test the map transition before the interceptor.
9487 THREADED_TEST(InterceptorKeyedCallICMapChangeBefore) { 9487 THREADED_TEST(InterceptorKeyedCallICMapChangeBefore) {
9488 v8::HandleScope scope; 9488 v8::HandleScope scope;
9489 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); 9489 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New();
9490 templ_o->SetNamedPropertyHandler(NoBlockGetterX); 9490 templ_o->SetNamedPropertyHandler(NoBlockGetterX);
9491 LocalContext context; 9491 LocalContext context;
9492 context->Global()->Set(v8_str("proto"), templ_o->NewInstance()); 9492 context->Global()->Set(v8_str("proto"), templ_o->NewInstance());
9493 9493
9494 v8::Handle<Value> value = CompileRun( 9494 v8::Handle<Value> value(CompileRun(
9495 "var o = new Object();" 9495 "var o = new Object();"
9496 "o.__proto__ = proto;" 9496 "o.__proto__ = proto;"
9497 "o.method = function(x) { return x + 1; };" 9497 "o.method = function(x) { return x + 1; };"
9498 "var m = 'method';" 9498 "var m = 'method';"
9499 "var result = 0;" 9499 "var result = 0;"
9500 "for (var i = 0; i < 10; i++) {" 9500 "for (var i = 0; i < 10; i++) {"
9501 " if (i == 5) { o.method = function(x) { return x - 1; }; };" 9501 " if (i == 5) { o.method = function(x) { return x - 1; }; };"
9502 " result += o[m](41);" 9502 " result += o[m](41);"
9503 "}"); 9503 "}"));
9504 CHECK_EQ(42*5 + 40*5, context->Global()->Get(v8_str("result"))->Int32Value()); 9504 CHECK_EQ(42*5 + 40*5, context->Global()->Get(v8_str("result"))->Int32Value());
9505 } 9505 }
9506 9506
9507 9507
9508 // Test the map transition after the interceptor. 9508 // Test the map transition after the interceptor.
9509 THREADED_TEST(InterceptorKeyedCallICMapChangeAfter) { 9509 THREADED_TEST(InterceptorKeyedCallICMapChangeAfter) {
9510 v8::HandleScope scope; 9510 v8::HandleScope scope;
9511 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); 9511 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New();
9512 templ_o->SetNamedPropertyHandler(NoBlockGetterX); 9512 templ_o->SetNamedPropertyHandler(NoBlockGetterX);
9513 LocalContext context; 9513 LocalContext context;
9514 context->Global()->Set(v8_str("o"), templ_o->NewInstance()); 9514 context->Global()->Set(v8_str("o"), templ_o->NewInstance());
9515 9515
9516 v8::Handle<Value> value = CompileRun( 9516 v8::Handle<Value> value(CompileRun(
9517 "var proto = new Object();" 9517 "var proto = new Object();"
9518 "o.__proto__ = proto;" 9518 "o.__proto__ = proto;"
9519 "proto.method = function(x) { return x + 1; };" 9519 "proto.method = function(x) { return x + 1; };"
9520 "var m = 'method';" 9520 "var m = 'method';"
9521 "var result = 0;" 9521 "var result = 0;"
9522 "for (var i = 0; i < 10; i++) {" 9522 "for (var i = 0; i < 10; i++) {"
9523 " if (i == 5) { proto.method = function(x) { return x - 1; }; };" 9523 " if (i == 5) { proto.method = function(x) { return x - 1; }; };"
9524 " result += o[m](41);" 9524 " result += o[m](41);"
9525 "}"); 9525 "}"));
9526 CHECK_EQ(42*5 + 40*5, context->Global()->Get(v8_str("result"))->Int32Value()); 9526 CHECK_EQ(42*5 + 40*5, context->Global()->Get(v8_str("result"))->Int32Value());
9527 } 9527 }
9528 9528
9529 9529
9530 static int interceptor_call_count = 0; 9530 static int interceptor_call_count = 0;
9531 9531
9532 static v8::Handle<Value> InterceptorICRefErrorGetter(Local<String> name, 9532 static v8::Handle<Value> InterceptorICRefErrorGetter(Local<String> name,
9533 const AccessorInfo& info) { 9533 const AccessorInfo& info) {
9534 ApiTestFuzzer::Fuzz(); 9534 ApiTestFuzzer::Fuzz();
9535 if (v8_str("x")->Equals(name) && interceptor_call_count++ < 20) { 9535 if (v8_str("x")->Equals(name) && interceptor_call_count++ < 20) {
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
10431 env->Exit(); 10431 env->Exit();
10432 return value; 10432 return value;
10433 } 10433 }
10434 10434
10435 10435
10436 THREADED_TEST(NestedHandleScopeAndContexts) { 10436 THREADED_TEST(NestedHandleScopeAndContexts) {
10437 v8::HandleScope outer; 10437 v8::HandleScope outer;
10438 v8::Persistent<Context> env = Context::New(); 10438 v8::Persistent<Context> env = Context::New();
10439 env->Enter(); 10439 env->Enter();
10440 v8::Handle<Value> value = NestedScope(env); 10440 v8::Handle<Value> value = NestedScope(env);
10441 v8::Handle<String> str = value->ToString(); 10441 v8::Handle<String> str(value->ToString());
10442 env->Exit(); 10442 env->Exit();
10443 env.Dispose(); 10443 env.Dispose();
10444 } 10444 }
10445 10445
10446 10446
10447 THREADED_TEST(ExternalAllocatedMemory) { 10447 THREADED_TEST(ExternalAllocatedMemory) {
10448 v8::HandleScope outer; 10448 v8::HandleScope outer;
10449 v8::Persistent<Context> env = Context::New(); 10449 v8::Persistent<Context> env(Context::New());
10450 const int kSize = 1024*1024; 10450 const int kSize = 1024*1024;
10451 CHECK_EQ(v8::V8::AdjustAmountOfExternalAllocatedMemory(kSize), kSize); 10451 CHECK_EQ(v8::V8::AdjustAmountOfExternalAllocatedMemory(kSize), kSize);
10452 CHECK_EQ(v8::V8::AdjustAmountOfExternalAllocatedMemory(-kSize), 0); 10452 CHECK_EQ(v8::V8::AdjustAmountOfExternalAllocatedMemory(-kSize), 0);
10453 } 10453 }
10454 10454
10455 10455
10456 THREADED_TEST(DisposeEnteredContext) { 10456 THREADED_TEST(DisposeEnteredContext) {
10457 v8::HandleScope scope; 10457 v8::HandleScope scope;
10458 LocalContext outer; 10458 LocalContext outer;
10459 { v8::Persistent<v8::Context> inner = v8::Context::New(); 10459 { v8::Persistent<v8::Context> inner = v8::Context::New();
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
10777 v8::HandleScope handle_scope; 10777 v8::HandleScope handle_scope;
10778 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); 10778 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
10779 global_template->SetAccessCheckCallbacks(NamedSetAccessBlocker, 10779 global_template->SetAccessCheckCallbacks(NamedSetAccessBlocker,
10780 IndexedSetAccessBlocker); 10780 IndexedSetAccessBlocker);
10781 i::Handle<i::ObjectTemplateInfo> internal_template = 10781 i::Handle<i::ObjectTemplateInfo> internal_template =
10782 v8::Utils::OpenHandle(*global_template); 10782 v8::Utils::OpenHandle(*global_template);
10783 CHECK(!internal_template->constructor()->IsUndefined()); 10783 CHECK(!internal_template->constructor()->IsUndefined());
10784 i::Handle<i::FunctionTemplateInfo> constructor( 10784 i::Handle<i::FunctionTemplateInfo> constructor(
10785 i::FunctionTemplateInfo::cast(internal_template->constructor())); 10785 i::FunctionTemplateInfo::cast(internal_template->constructor()));
10786 CHECK(!constructor->access_check_info()->IsUndefined()); 10786 CHECK(!constructor->access_check_info()->IsUndefined());
10787 v8::Persistent<Context> context0 = Context::New(NULL, global_template); 10787 v8::Persistent<Context> context0(Context::New(NULL, global_template));
10788 CHECK(!constructor->access_check_info()->IsUndefined()); 10788 CHECK(!constructor->access_check_info()->IsUndefined());
10789 } 10789 }
10790 10790
10791 10791
10792 THREADED_TEST(TurnOnAccessCheck) { 10792 THREADED_TEST(TurnOnAccessCheck) {
10793 v8::HandleScope handle_scope; 10793 v8::HandleScope handle_scope;
10794 10794
10795 // Create an environment with access check to the global object disabled by 10795 // Create an environment with access check to the global object disabled by
10796 // default. 10796 // default.
10797 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); 10797 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
(...skipping 2055 matching lines...) Expand 10 before | Expand all | Expand 10 after
12853 // Test more complex manipulations which cause eax to contain values 12853 // Test more complex manipulations which cause eax to contain values
12854 // that won't be completely overwritten by loads from the arrays. 12854 // that won't be completely overwritten by loads from the arrays.
12855 // This catches bugs in the instructions used for the KeyedLoadIC 12855 // This catches bugs in the instructions used for the KeyedLoadIC
12856 // for byte and word types. 12856 // for byte and word types.
12857 { 12857 {
12858 const int kXSize = 300; 12858 const int kXSize = 300;
12859 const int kYSize = 300; 12859 const int kYSize = 300;
12860 const int kLargeElementCount = kXSize * kYSize * 4; 12860 const int kLargeElementCount = kXSize * kYSize * 4;
12861 ElementType* large_array_data = 12861 ElementType* large_array_data =
12862 static_cast<ElementType*>(malloc(kLargeElementCount * element_size)); 12862 static_cast<ElementType*>(malloc(kLargeElementCount * element_size));
12863 i::Handle<ExternalArrayClass> large_array = 12863 i::Handle<ExternalArrayClass> large_array(
12864 i::Handle<ExternalArrayClass>::cast( 12864 i::Handle<ExternalArrayClass>::cast(
12865 FACTORY->NewExternalArray(kLargeElementCount, 12865 FACTORY->NewExternalArray(kLargeElementCount,
12866 array_type, 12866 array_type,
12867 array_data)); 12867 array_data)));
12868 v8::Handle<v8::Object> large_obj = v8::Object::New(); 12868 v8::Handle<v8::Object> large_obj = v8::Object::New();
12869 // Set the elements to be the external array. 12869 // Set the elements to be the external array.
12870 large_obj->SetIndexedPropertiesToExternalArrayData(large_array_data, 12870 large_obj->SetIndexedPropertiesToExternalArrayData(large_array_data,
12871 array_type, 12871 array_type,
12872 kLargeElementCount); 12872 kLargeElementCount);
12873 context->Global()->Set(v8_str("large_array"), large_obj); 12873 context->Global()->Set(v8_str("large_array"), large_obj);
12874 // Initialize contents of a few rows. 12874 // Initialize contents of a few rows.
12875 for (int x = 0; x < 300; x++) { 12875 for (int x = 0; x < 300; x++) {
12876 int row = 0; 12876 int row = 0;
12877 int offset = row * 300 * 4; 12877 int offset = row * 300 * 4;
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
13256 const char *overview_source = 13256 const char *overview_source =
13257 "function bar() {\n" 13257 "function bar() {\n"
13258 " var y; AnalyzeStackInNativeCode(1);\n" 13258 " var y; AnalyzeStackInNativeCode(1);\n"
13259 "}\n" 13259 "}\n"
13260 "function foo() {\n" 13260 "function foo() {\n"
13261 "\n" 13261 "\n"
13262 " bar();\n" 13262 " bar();\n"
13263 "}\n" 13263 "}\n"
13264 "var x;eval('new foo();');"; 13264 "var x;eval('new foo();');";
13265 v8::Handle<v8::String> overview_src = v8::String::New(overview_source); 13265 v8::Handle<v8::String> overview_src = v8::String::New(overview_source);
13266 v8::Handle<Value> overview_result = 13266 v8::Handle<Value> overview_result(
13267 v8::Script::New(overview_src, origin)->Run(); 13267 v8::Script::New(overview_src, origin)->Run());
13268 ASSERT(!overview_result.IsEmpty()); 13268 ASSERT(!overview_result.IsEmpty());
13269 ASSERT(overview_result->IsObject()); 13269 ASSERT(overview_result->IsObject());
13270 13270
13271 // Test getting DETAILED information. 13271 // Test getting DETAILED information.
13272 const char *detailed_source = 13272 const char *detailed_source =
13273 "function bat() {AnalyzeStackInNativeCode(2);\n" 13273 "function bat() {AnalyzeStackInNativeCode(2);\n"
13274 "}\n" 13274 "}\n"
13275 "\n" 13275 "\n"
13276 "function baz() {\n" 13276 "function baz() {\n"
13277 " bat();\n" 13277 " bat();\n"
13278 "}\n" 13278 "}\n"
13279 "eval('new baz();');"; 13279 "eval('new baz();');";
13280 v8::Handle<v8::String> detailed_src = v8::String::New(detailed_source); 13280 v8::Handle<v8::String> detailed_src = v8::String::New(detailed_source);
13281 // Make the script using a non-zero line and column offset. 13281 // Make the script using a non-zero line and column offset.
13282 v8::Handle<v8::Integer> line_offset = v8::Integer::New(3); 13282 v8::Handle<v8::Integer> line_offset = v8::Integer::New(3);
13283 v8::Handle<v8::Integer> column_offset = v8::Integer::New(5); 13283 v8::Handle<v8::Integer> column_offset = v8::Integer::New(5);
13284 v8::ScriptOrigin detailed_origin(origin, line_offset, column_offset); 13284 v8::ScriptOrigin detailed_origin(origin, line_offset, column_offset);
13285 v8::Handle<v8::Script> detailed_script( 13285 v8::Handle<v8::Script> detailed_script(
13286 v8::Script::New(detailed_src, &detailed_origin)); 13286 v8::Script::New(detailed_src, &detailed_origin));
13287 v8::Handle<Value> detailed_result = detailed_script->Run(); 13287 v8::Handle<Value> detailed_result(detailed_script->Run());
13288 ASSERT(!detailed_result.IsEmpty()); 13288 ASSERT(!detailed_result.IsEmpty());
13289 ASSERT(detailed_result->IsObject()); 13289 ASSERT(detailed_result->IsObject());
13290 } 13290 }
13291 13291
13292 13292
13293 static void StackTraceForUncaughtExceptionListener( 13293 static void StackTraceForUncaughtExceptionListener(
13294 v8::Handle<v8::Message> message, 13294 v8::Handle<v8::Message> message,
13295 v8::Handle<Value>) { 13295 v8::Handle<Value>) {
13296 v8::Handle<v8::StackTrace> stack_trace = message->GetStackTrace(); 13296 v8::Handle<v8::StackTrace> stack_trace = message->GetStackTrace();
13297 CHECK_EQ(2, stack_trace->GetFrameCount()); 13297 CHECK_EQ(2, stack_trace->GetFrameCount());
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
13579 // Check if quiet nan (bits 51..62 all set). 13579 // Check if quiet nan (bits 51..62 all set).
13580 CHECK_EQ(0xfff, static_cast<int>((stored_bits >> 51) & 0xfff)); 13580 CHECK_EQ(0xfff, static_cast<int>((stored_bits >> 51) & 0xfff));
13581 } 13581 }
13582 } 13582 }
13583 } 13583 }
13584 13584
13585 13585
13586 static v8::Handle<Value> SpaghettiIncident(const v8::Arguments& args) { 13586 static v8::Handle<Value> SpaghettiIncident(const v8::Arguments& args) {
13587 v8::HandleScope scope; 13587 v8::HandleScope scope;
13588 v8::TryCatch tc; 13588 v8::TryCatch tc;
13589 v8::Handle<v8::String> str = args[0]->ToString(); 13589 v8::Handle<v8::String> str(args[0]->ToString());
13590 if (tc.HasCaught()) 13590 if (tc.HasCaught())
13591 return tc.ReThrow(); 13591 return tc.ReThrow();
13592 return v8::Undefined(); 13592 return v8::Undefined();
13593 } 13593 }
13594 13594
13595 13595
13596 // Test that an exception can be propagated down through a spaghetti 13596 // Test that an exception can be propagated down through a spaghetti
13597 // stack using ReThrow. 13597 // stack using ReThrow.
13598 THREADED_TEST(SpaghettiStackReThrow) { 13598 THREADED_TEST(SpaghettiStackReThrow) {
13599 v8::HandleScope scope; 13599 v8::HandleScope scope;
(...skipping 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after
14842 CHECK(re->IsRegExp()); 14842 CHECK(re->IsRegExp());
14843 CHECK(re->GetSource()->Equals(v8_str("foobarbaz"))); 14843 CHECK(re->GetSource()->Equals(v8_str("foobarbaz")));
14844 CHECK_EQ(v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline, 14844 CHECK_EQ(v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline,
14845 static_cast<int>(re->GetFlags())); 14845 static_cast<int>(re->GetFlags()));
14846 14846
14847 context->Global()->Set(v8_str("re"), re); 14847 context->Global()->Set(v8_str("re"), re);
14848 ExpectTrue("re.test('FoobarbaZ')"); 14848 ExpectTrue("re.test('FoobarbaZ')");
14849 14849
14850 // RegExps are objects on which you can set properties. 14850 // RegExps are objects on which you can set properties.
14851 re->Set(v8_str("property"), v8::Integer::New(32)); 14851 re->Set(v8_str("property"), v8::Integer::New(32));
14852 v8::Handle<v8::Value> value = CompileRun("re.property"); 14852 v8::Handle<v8::Value> value(CompileRun("re.property"));
14853 ASSERT_EQ(32, value->Int32Value()); 14853 ASSERT_EQ(32, value->Int32Value());
14854 14854
14855 v8::TryCatch try_catch; 14855 v8::TryCatch try_catch;
14856 re = v8::RegExp::New(v8_str("foo["), v8::RegExp::kNone); 14856 re = v8::RegExp::New(v8_str("foo["), v8::RegExp::kNone);
14857 CHECK(re.IsEmpty()); 14857 CHECK(re.IsEmpty());
14858 CHECK(try_catch.HasCaught()); 14858 CHECK(try_catch.HasCaught());
14859 context->Global()->Set(v8_str("ex"), try_catch.Exception()); 14859 context->Global()->Set(v8_str("ex"), try_catch.Exception());
14860 ExpectTrue("ex instanceof SyntaxError"); 14860 ExpectTrue("ex instanceof SyntaxError");
14861 } 14861 }
14862 14862
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
15489 CHECK(i->Equals(CompileRun("'abcbd'.replace(/b/g,func)[3]"))); 15489 CHECK(i->Equals(CompileRun("'abcbd'.replace(/b/g,func)[3]")));
15490 15490
15491 // TODO(1547): Make the following also return "i". 15491 // TODO(1547): Make the following also return "i".
15492 // Calling with environment record as base. 15492 // Calling with environment record as base.
15493 TestReceiver(o, context->Global(), "func()"); 15493 TestReceiver(o, context->Global(), "func()");
15494 // Calling with no base. 15494 // Calling with no base.
15495 TestReceiver(o, context->Global(), "(1,func)()"); 15495 TestReceiver(o, context->Global(), "(1,func)()");
15496 15496
15497 foreign_context.Dispose(); 15497 foreign_context.Dispose();
15498 } 15498 }
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/test-compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698