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

Side by Side Diff: test/cctest/test-code-stub-assembler.cc

Issue 2517823002: [builtins] add CodeStubAssembler::IsDebugActive() helper (Closed)
Patch Set: Created 4 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
« no previous file with comments | « src/code-stub-assembler.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/base/utils/random-number-generator.h" 5 #include "src/base/utils/random-number-generator.h"
6 #include "src/code-factory.h" 6 #include "src/code-factory.h"
7 #include "src/code-stub-assembler.h" 7 #include "src/code-stub-assembler.h"
8 #include "src/compiler/node.h" 8 #include "src/compiler/node.h"
9 #include "src/isolate.h" 9 #include "src/isolate.h"
10 #include "test/cctest/compiler/code-assembler-tester.h" 10 #include "test/cctest/compiler/code-assembler-tester.h"
(...skipping 1742 matching lines...) Expand 10 before | Expand all | Expand 10 after
1753 1753
1754 FunctionTester ft(code, kNumParams); 1754 FunctionTester ft(code, kNumParams);
1755 Handle<Object> result = ft.Call(isolate->factory()->undefined_value(), 1755 Handle<Object> result = ft.Call(isolate->factory()->undefined_value(),
1756 Handle<Smi>(Smi::FromInt(12), isolate), 1756 Handle<Smi>(Smi::FromInt(12), isolate),
1757 Handle<Smi>(Smi::FromInt(13), isolate), 1757 Handle<Smi>(Smi::FromInt(13), isolate),
1758 Handle<Smi>(Smi::FromInt(14), isolate)) 1758 Handle<Smi>(Smi::FromInt(14), isolate))
1759 .ToHandleChecked(); 1759 .ToHandleChecked();
1760 CHECK_EQ(Smi::FromInt(12 + 13 + 14), *result); 1760 CHECK_EQ(Smi::FromInt(12 + 13 + 14), *result);
1761 } 1761 }
1762 1762
1763 TEST(IsDebugActive) {
1764 Isolate* isolate(CcTest::InitIsolateOnce());
1765
1766 const int kNumParams = 1;
1767 CodeAssemblerTester data(isolate, kNumParams);
1768 CodeStubAssembler m(data.state());
1769
1770 CodeStubAssembler::Label if_active(&m), if_not_active(&m);
1771
1772 m.Branch(m.IsDebugActive(), &if_active, &if_not_active);
1773 m.Bind(&if_active);
1774 m.Return(m.TrueConstant());
1775 m.Bind(&if_not_active);
1776 m.Return(m.FalseConstant());
1777
1778 Handle<Code> code = data.GenerateCode();
1779 CHECK(!code.is_null());
1780
1781 FunctionTester ft(code, kNumParams);
1782 CHECK_EQ(false, isolate->debug()->is_active());
1783 Handle<Object> result =
1784 ft.Call(isolate->factory()->undefined_value()).ToHandleChecked();
1785 CHECK_EQ(isolate->heap()->false_value(), *result);
1786
1787 bool* debug_is_active = reinterpret_cast<bool*>(
1788 ExternalReference::debug_is_active_address(isolate).address());
1789
1790 // Cheat to enable debug (TODO: do this properly).
1791 *debug_is_active = true;
1792
1793 result = ft.Call(isolate->factory()->undefined_value()).ToHandleChecked();
1794 CHECK_EQ(isolate->heap()->true_value(), *result);
1795
1796 // Reset debug mode.
1797 *debug_is_active = false;
1798 }
1799
1763 } // namespace internal 1800 } // namespace internal
1764 } // namespace v8 1801 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stub-assembler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698