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

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

Issue 336863007: Parser: add usage counters for "use asm". (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: code review (jochen@) Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « src/parser.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 2727 matching lines...) Expand 10 before | Expand all | Expand 10 after
2738 const i::AstRawString* var_name = 2738 const i::AstRawString* var_name =
2739 info.ast_value_factory()->GetOneByteString("x"); 2739 info.ast_value_factory()->GetOneByteString("x");
2740 i::Variable* var = inner_scope->Lookup(var_name); 2740 i::Variable* var = inner_scope->Lookup(var_name);
2741 bool expected = outers[i].assigned || inners[j].assigned; 2741 bool expected = outers[i].assigned || inners[j].assigned;
2742 CHECK(var != NULL); 2742 CHECK(var != NULL);
2743 CHECK(var->is_used() || !expected); 2743 CHECK(var->is_used() || !expected);
2744 CHECK(var->maybe_assigned() == expected); 2744 CHECK(var->maybe_assigned() == expected);
2745 } 2745 }
2746 } 2746 }
2747 } 2747 }
2748
2749 namespace {
2750
2751 int* global_use_counts = NULL;
2752
2753 void MockUseCounterCallback(v8::Isolate* isolate,
2754 v8::Isolate::UseCounterFeature feature) {
2755 ++global_use_counts[feature];
2756 }
2757
2758 }
2759
2760
2761 TEST(UseAsmUseCount) {
2762 i::Isolate* isolate = CcTest::i_isolate();
2763 i::HandleScope scope(isolate);
2764 LocalContext env;
2765 int use_counts[v8::Isolate::kUseCounterFeatureCount] = {};
2766 global_use_counts = use_counts;
2767 CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback);
2768 CompileRun("\"use asm\";\n"
2769 "var foo = 1;\n"
2770 "\"use asm\";\n" // Only the first one counts.
2771 "function bar() { \"use asm\"; var baz = 1; }");
2772 CHECK_EQ(2, use_counts[v8::Isolate::kUseAsm]);
2773 }
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698