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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/code-stub-assembler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-code-stub-assembler.cc
diff --git a/test/cctest/test-code-stub-assembler.cc b/test/cctest/test-code-stub-assembler.cc
index e7793e51053f79dce0c7a70fd4cc3f708fa71c70..7035d514fd6e162144af865b1050d60ccd1b880c 100644
--- a/test/cctest/test-code-stub-assembler.cc
+++ b/test/cctest/test-code-stub-assembler.cc
@@ -1760,5 +1760,42 @@ TEST(ArgumentsForEach) {
CHECK_EQ(Smi::FromInt(12 + 13 + 14), *result);
}
+TEST(IsDebugActive) {
+ Isolate* isolate(CcTest::InitIsolateOnce());
+
+ const int kNumParams = 1;
+ CodeAssemblerTester data(isolate, kNumParams);
+ CodeStubAssembler m(data.state());
+
+ CodeStubAssembler::Label if_active(&m), if_not_active(&m);
+
+ m.Branch(m.IsDebugActive(), &if_active, &if_not_active);
+ m.Bind(&if_active);
+ m.Return(m.TrueConstant());
+ m.Bind(&if_not_active);
+ m.Return(m.FalseConstant());
+
+ Handle<Code> code = data.GenerateCode();
+ CHECK(!code.is_null());
+
+ FunctionTester ft(code, kNumParams);
+ CHECK_EQ(false, isolate->debug()->is_active());
+ Handle<Object> result =
+ ft.Call(isolate->factory()->undefined_value()).ToHandleChecked();
+ CHECK_EQ(isolate->heap()->false_value(), *result);
+
+ bool* debug_is_active = reinterpret_cast<bool*>(
+ ExternalReference::debug_is_active_address(isolate).address());
+
+ // Cheat to enable debug (TODO: do this properly).
+ *debug_is_active = true;
+
+ result = ft.Call(isolate->factory()->undefined_value()).ToHandleChecked();
+ CHECK_EQ(isolate->heap()->true_value(), *result);
+
+ // Reset debug mode.
+ *debug_is_active = false;
+}
+
} // namespace internal
} // namespace v8
« 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