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

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

Issue 696783005: harmony-scoping: Implement LoadIC handler for loads from global contexts. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: CR feedback + rebase Created 6 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/ic/ic.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 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-2008 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 970 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 981
982 { 982 {
983 SimpleContext context; 983 SimpleContext context;
984 Local<String> undefined_string = String::NewFromUtf8( 984 Local<String> undefined_string = String::NewFromUtf8(
985 CcTest::isolate(), "undefined", String::kInternalizedString); 985 CcTest::isolate(), "undefined", String::kInternalizedString);
986 Local<String> number_string = String::NewFromUtf8( 986 Local<String> number_string = String::NewFromUtf8(
987 CcTest::isolate(), "number", String::kInternalizedString); 987 CcTest::isolate(), "number", String::kInternalizedString);
988 988
989 context.Check( 989 context.Check(
990 "function f(o) { return x; }" 990 "function f(o) { return x; }"
991 "function g(o) { x = 15; }" 991 "function g(v) { x = v; }"
992 "function h(o) { return typeof x; }", 992 "function h(o) { return typeof x; }",
993 EXPECT_RESULT, Undefined(CcTest::isolate())); 993 EXPECT_RESULT, Undefined(CcTest::isolate()));
994 context.Check("h({})", EXPECT_RESULT, undefined_string); 994 context.Check("h({})", EXPECT_RESULT, undefined_string);
995 context.Check( 995 context.Check(
996 "'use strict';" 996 "'use strict';"
997 "let x = 1;" 997 "let x = 1;"
998 "f({})", 998 "f({})",
999 EXPECT_RESULT, Number::New(CcTest::isolate(), 1)); 999 EXPECT_RESULT, Number::New(CcTest::isolate(), 1));
1000 context.Check( 1000 context.Check(
1001 "'use strict';" 1001 "'use strict';"
1002 "g({});x", 1002 "g(15);x",
1003 EXPECT_RESULT, Number::New(CcTest::isolate(), 15)); 1003 EXPECT_RESULT, Number::New(CcTest::isolate(), 15));
1004 context.Check("h({})", EXPECT_RESULT, number_string); 1004 context.Check("h({})", EXPECT_RESULT, number_string);
1005 context.Check("f({})", EXPECT_RESULT, Number::New(CcTest::isolate(), 15)); 1005 context.Check("f({})", EXPECT_RESULT, Number::New(CcTest::isolate(), 15));
1006 context.Check("h({})", EXPECT_RESULT, number_string); 1006 context.Check("h({})", EXPECT_RESULT, number_string);
1007 } 1007 }
1008 } 1008 }
1009
1010
1011 TEST(CrossScriptICs) {
1012 i::FLAG_harmony_scoping = true;
1013 i::FLAG_allow_natives_syntax = true;
1014
1015 HandleScope handle_scope(CcTest::isolate());
1016
1017 {
1018 SimpleContext context;
1019 context.Check(
1020 "x = 15;"
1021 "function f() { return x; }"
1022 "function g() { return x; }"
1023 "f()",
1024 EXPECT_RESULT, Number::New(CcTest::isolate(), 15));
1025 context.Check(
1026 "'use strict';"
1027 "let x = 5;"
1028 "f()",
1029 EXPECT_RESULT, Number::New(CcTest::isolate(), 5));
1030 for (int k = 0; k < 3; k++) {
1031 context.Check("g()", EXPECT_RESULT, Number::New(CcTest::isolate(), 5));
1032 }
1033 for (int k = 0; k < 3; k++) {
1034 context.Check("f()", EXPECT_RESULT, Number::New(CcTest::isolate(), 5));
1035 }
1036 context.Check("%OptimizeFunctionOnNextCall(g); g()", EXPECT_RESULT,
1037 Number::New(CcTest::isolate(), 5));
1038 context.Check("%OptimizeFunctionOnNextCall(f); f()", EXPECT_RESULT,
1039 Number::New(CcTest::isolate(), 5));
1040 }
1041 {
1042 SimpleContext context;
1043 context.Check(
1044 "x = 15;"
1045 "function f() { return x; }"
1046 "f()",
1047 EXPECT_RESULT, Number::New(CcTest::isolate(), 15));
1048 for (int k = 0; k < 3; k++) {
1049 context.Check("f()", EXPECT_RESULT, Number::New(CcTest::isolate(), 15));
1050 }
1051 context.Check("%OptimizeFunctionOnNextCall(f); f()", EXPECT_RESULT,
1052 Number::New(CcTest::isolate(), 15));
1053 context.Check(
1054 "'use strict';"
1055 "let x = 5;"
1056 "f()",
1057 EXPECT_RESULT, Number::New(CcTest::isolate(), 5));
1058 for (int k = 0; k < 3; k++) {
1059 context.Check("f()", EXPECT_RESULT, Number::New(CcTest::isolate(), 5));
1060 }
1061 context.Check("%OptimizeFunctionOnNextCall(f); f()", EXPECT_RESULT,
1062 Number::New(CcTest::isolate(), 5));
1063 }
1064 }
OLDNEW
« no previous file with comments | « src/ic/ic.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698