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

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

Issue 2575313002: [promisehook] Implement PromiseHook (Closed)
Patch Set: rebase + add comments Created 4 years 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 | « test/cctest/test-api.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 1774 matching lines...) Expand 10 before | Expand all | Expand 10 after
1785 Recompile<KeyedLoadICTFStub>(isolate); 1785 Recompile<KeyedLoadICTFStub>(isolate);
1786 Recompile<KeyedLoadICTrampolineTFStub>(isolate); 1786 Recompile<KeyedLoadICTrampolineTFStub>(isolate);
1787 Recompile<StoreICStub>(isolate, StoreICState(STRICT)); 1787 Recompile<StoreICStub>(isolate, StoreICState(STRICT));
1788 Recompile<StoreICTrampolineStub>(isolate, StoreICState(STRICT)); 1788 Recompile<StoreICTrampolineStub>(isolate, StoreICState(STRICT));
1789 Recompile<KeyedStoreICTFStub>(isolate, StoreICState(STRICT)); 1789 Recompile<KeyedStoreICTFStub>(isolate, StoreICState(STRICT));
1790 Recompile<KeyedStoreICTrampolineTFStub>(isolate, StoreICState(STRICT)); 1790 Recompile<KeyedStoreICTrampolineTFStub>(isolate, StoreICState(STRICT));
1791 } 1791 }
1792 v8_isolate->Dispose(); 1792 v8_isolate->Dispose();
1793 } 1793 }
1794 1794
1795 void CustomPromiseHook(v8::PromiseHookType type, v8::Local<v8::Promise> promise,
1796 v8::Local<v8::Value> parentPromise) {}
1797
1795 TEST(IsPromiseHookEnabled) { 1798 TEST(IsPromiseHookEnabled) {
1796 Isolate* isolate(CcTest::InitIsolateOnce()); 1799 Isolate* isolate(CcTest::InitIsolateOnce());
1797 1800
1798 const int kNumParams = 1; 1801 const int kNumParams = 1;
1799 CodeAssemblerTester data(isolate, kNumParams); 1802 CodeAssemblerTester data(isolate, kNumParams);
1800 CodeStubAssembler m(data.state()); 1803 CodeStubAssembler m(data.state());
1801 1804
1802 m.Return(m.SelectBooleanConstant(m.IsPromiseHookEnabled())); 1805 m.Return(m.SelectBooleanConstant(m.IsPromiseHookEnabled()));
1803 1806
1804 Handle<Code> code = data.GenerateCode(); 1807 Handle<Code> code = data.GenerateCode();
1805 CHECK(!code.is_null()); 1808 CHECK(!code.is_null());
1806 1809
1807 FunctionTester ft(code, kNumParams); 1810 FunctionTester ft(code, kNumParams);
1808 CHECK_EQ(false, isolate->IsPromiseHookEnabled());
1809 Handle<Object> result = 1811 Handle<Object> result =
1810 ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); 1812 ft.Call(isolate->factory()->undefined_value()).ToHandleChecked();
1811 CHECK_EQ(isolate->heap()->false_value(), *result); 1813 CHECK_EQ(isolate->heap()->false_value(), *result);
1812 1814
1813 isolate->EnablePromiseHook(); 1815 isolate->SetPromiseHook(CustomPromiseHook);
1814 result = ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); 1816 result = ft.Call(isolate->factory()->undefined_value()).ToHandleChecked();
1815 CHECK_EQ(isolate->heap()->true_value(), *result); 1817 CHECK_EQ(isolate->heap()->true_value(), *result);
1816 1818
1817 isolate->DisablePromiseHook(); 1819 isolate->SetPromiseHook(nullptr);
1818 result = ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); 1820 result = ft.Call(isolate->factory()->undefined_value()).ToHandleChecked();
1819 CHECK_EQ(isolate->heap()->false_value(), *result); 1821 CHECK_EQ(isolate->heap()->false_value(), *result);
1820 } 1822 }
1821 1823
1822 TEST(AllocateJSPromise) { 1824 TEST(AllocateJSPromise) {
1823 Isolate* isolate(CcTest::InitIsolateOnce()); 1825 Isolate* isolate(CcTest::InitIsolateOnce());
1824 1826
1825 const int kNumParams = 1; 1827 const int kNumParams = 1;
1826 CodeAssemblerTester data(isolate, kNumParams); 1828 CodeAssemblerTester data(isolate, kNumParams);
1827 CodeStubAssembler m(data.state()); 1829 CodeStubAssembler m(data.state());
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1967 1969
1968 result = ft.Call(isolate->factory()->empty_string()).ToHandleChecked(); 1970 result = ft.Call(isolate->factory()->empty_string()).ToHandleChecked();
1969 CHECK_EQ(isolate->heap()->false_value(), *result); 1971 CHECK_EQ(isolate->heap()->false_value(), *result);
1970 1972
1971 result = ft.Call(isolate->factory()->NewPrivateSymbol()).ToHandleChecked(); 1973 result = ft.Call(isolate->factory()->NewPrivateSymbol()).ToHandleChecked();
1972 CHECK_EQ(isolate->heap()->true_value(), *result); 1974 CHECK_EQ(isolate->heap()->true_value(), *result);
1973 } 1975 }
1974 1976
1975 } // namespace internal 1977 } // namespace internal
1976 } // namespace v8 1978 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698