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

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

Issue 6995046: Support %_IsUndetectableObject in crankshaft. (Closed)
Patch Set: Review fixes Created 9 years, 7 months 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
« no previous file with comments | « src/x64/lithium-x64.cc ('k') | no next file » | 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 3922 matching lines...) Expand 10 before | Expand all | Expand 10 after
3933 3933
3934 3934
3935 ExpectBoolean("undetectable===null", false); 3935 ExpectBoolean("undetectable===null", false);
3936 ExpectBoolean("null===undetectable", false); 3936 ExpectBoolean("null===undetectable", false);
3937 ExpectBoolean("undetectable===undefined", false); 3937 ExpectBoolean("undetectable===undefined", false);
3938 ExpectBoolean("undefined===undetectable", false); 3938 ExpectBoolean("undefined===undetectable", false);
3939 ExpectBoolean("undetectable===undetectable", true); 3939 ExpectBoolean("undetectable===undetectable", true);
3940 } 3940 }
3941 3941
3942 3942
3943 TEST(UndetectableOptimized) {
3944 i::FLAG_allow_natives_syntax = true;
3945 v8::HandleScope scope;
3946 LocalContext env;
3947
3948 Local<String> obj = String::NewUndetectable("foo");
3949 env->Global()->Set(v8_str("undetectable"), obj);
3950 env->Global()->Set(v8_str("detectable"), v8_str("bar"));
3951
3952 ExpectString(
3953 "function testBranch() {"
3954 " if (!%_IsUndetectableObject(undetectable)) throw 1;"
3955 " if (%_IsUndetectableObject(detectable)) throw 2;"
3956 "}\n"
3957 "function testBool() {"
3958 " var b1 = !%_IsUndetectableObject(undetectable);"
3959 " var b2 = %_IsUndetectableObject(detectable);"
3960 " if (b1) throw 3;"
3961 " if (b2) throw 4;"
3962 " return b1 == b2;"
3963 "}\n"
3964 "%OptimizeFunctionOnNextCall(testBranch);"
3965 "%OptimizeFunctionOnNextCall(testBool);"
3966 "for (var i = 0; i < 10; i++) {"
3967 " testBranch();"
3968 " testBool();"
3969 "}\n"
3970 "\"PASS\"",
3971 "PASS");
3972 }
3973
3974
3943 template <typename T> static void USE(T) { } 3975 template <typename T> static void USE(T) { }
3944 3976
3945 3977
3946 // This test is not intended to be run, just type checked. 3978 // This test is not intended to be run, just type checked.
3947 static void PersistentHandles() { 3979 static void PersistentHandles() {
3948 USE(PersistentHandles); 3980 USE(PersistentHandles);
3949 Local<String> str = v8_str("foo"); 3981 Local<String> str = v8_str("foo");
3950 v8::Persistent<String> p_str = v8::Persistent<String>::New(str); 3982 v8::Persistent<String> p_str = v8::Persistent<String>::New(str);
3951 USE(p_str); 3983 USE(p_str);
3952 Local<Script> scr = Script::Compile(v8_str("")); 3984 Local<Script> scr = Script::Compile(v8_str(""));
(...skipping 10491 matching lines...) Expand 10 before | Expand all | Expand 10 after
14444 THREADED_TEST(CallAPIFunctionOnNonObject) { 14476 THREADED_TEST(CallAPIFunctionOnNonObject) {
14445 v8::HandleScope scope; 14477 v8::HandleScope scope;
14446 LocalContext context; 14478 LocalContext context;
14447 Handle<FunctionTemplate> templ = v8::FunctionTemplate::New(NonObjectThis); 14479 Handle<FunctionTemplate> templ = v8::FunctionTemplate::New(NonObjectThis);
14448 Handle<Function> function = templ->GetFunction(); 14480 Handle<Function> function = templ->GetFunction();
14449 context->Global()->Set(v8_str("f"), function); 14481 context->Global()->Set(v8_str("f"), function);
14450 TryCatch try_catch; 14482 TryCatch try_catch;
14451 CompileRun("f.call(2)"); 14483 CompileRun("f.call(2)");
14452 CHECK(try_catch.HasCaught()); 14484 CHECK(try_catch.HasCaught());
14453 } 14485 }
OLDNEW
« no previous file with comments | « src/x64/lithium-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698