OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |