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

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

Issue 2575313002: [promisehook] Implement PromiseHook (Closed)
Patch Set: add tests 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
« src/isolate.cc ('K') | « 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 1954 matching lines...) Expand 10 before | Expand all | Expand 10 after
1965 Recompile<KeyedLoadICTFStub>(isolate); 1965 Recompile<KeyedLoadICTFStub>(isolate);
1966 Recompile<KeyedLoadICTrampolineTFStub>(isolate); 1966 Recompile<KeyedLoadICTrampolineTFStub>(isolate);
1967 Recompile<StoreICStub>(isolate, StoreICState(STRICT)); 1967 Recompile<StoreICStub>(isolate, StoreICState(STRICT));
1968 Recompile<StoreICTrampolineStub>(isolate, StoreICState(STRICT)); 1968 Recompile<StoreICTrampolineStub>(isolate, StoreICState(STRICT));
1969 Recompile<KeyedStoreICTFStub>(isolate, StoreICState(STRICT)); 1969 Recompile<KeyedStoreICTFStub>(isolate, StoreICState(STRICT));
1970 Recompile<KeyedStoreICTrampolineTFStub>(isolate, StoreICState(STRICT)); 1970 Recompile<KeyedStoreICTrampolineTFStub>(isolate, StoreICState(STRICT));
1971 } 1971 }
1972 v8_isolate->Dispose(); 1972 v8_isolate->Dispose();
1973 } 1973 }
1974 1974
1975 void CustomPromiseHook(v8::PromiseHookType type, v8::Local<v8::Promise> promise,
1976 v8::Local<v8::Value> parentPromise) {}
1977
1975 TEST(IsPromiseHookEnabled) { 1978 TEST(IsPromiseHookEnabled) {
1976 Isolate* isolate(CcTest::InitIsolateOnce()); 1979 Isolate* isolate(CcTest::InitIsolateOnce());
1977 1980
1978 const int kNumParams = 1; 1981 const int kNumParams = 1;
1979 CodeAssemblerTester data(isolate, kNumParams); 1982 CodeAssemblerTester data(isolate, kNumParams);
1980 CodeStubAssembler m(data.state()); 1983 CodeStubAssembler m(data.state());
1981 1984
1982 m.Return(m.SelectBooleanConstant(m.IsPromiseHookEnabled())); 1985 m.Return(m.SelectBooleanConstant(m.IsPromiseHookEnabled()));
1983 1986
1984 Handle<Code> code = data.GenerateCode(); 1987 Handle<Code> code = data.GenerateCode();
1985 CHECK(!code.is_null()); 1988 CHECK(!code.is_null());
1986 1989
1987 FunctionTester ft(code, kNumParams); 1990 FunctionTester ft(code, kNumParams);
1988 CHECK_EQ(false, isolate->IsPromiseHookEnabled()); 1991 CHECK_EQ(false, isolate->IsPromiseHookEnabled());
1989 Handle<Object> result = 1992 Handle<Object> result =
1990 ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); 1993 ft.Call(isolate->factory()->undefined_value()).ToHandleChecked();
1991 CHECK_EQ(isolate->heap()->false_value(), *result); 1994 CHECK_EQ(isolate->heap()->false_value(), *result);
1992 1995
1993 isolate->EnablePromiseHook(); 1996 isolate->SetPromiseHook(CustomPromiseHook);
1994 result = ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); 1997 result = ft.Call(isolate->factory()->undefined_value()).ToHandleChecked();
1995 CHECK_EQ(isolate->heap()->true_value(), *result); 1998 CHECK_EQ(isolate->heap()->true_value(), *result);
1996 1999
1997 isolate->DisablePromiseHook(); 2000 isolate->SetPromiseHook(nullptr);
1998 result = ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); 2001 result = ft.Call(isolate->factory()->undefined_value()).ToHandleChecked();
1999 CHECK_EQ(isolate->heap()->false_value(), *result); 2002 CHECK_EQ(isolate->heap()->false_value(), *result);
2000 } 2003 }
2001 2004
2002 TEST(AllocateJSPromise) { 2005 TEST(AllocateJSPromise) {
2003 Isolate* isolate(CcTest::InitIsolateOnce()); 2006 Isolate* isolate(CcTest::InitIsolateOnce());
2004 2007
2005 const int kNumParams = 1; 2008 const int kNumParams = 1;
2006 CodeAssemblerTester data(isolate, kNumParams); 2009 CodeAssemblerTester data(isolate, kNumParams);
2007 CodeStubAssembler m(data.state()); 2010 CodeStubAssembler m(data.state());
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2145 2148
2146 result = ft.Call(isolate->factory()->empty_string()).ToHandleChecked(); 2149 result = ft.Call(isolate->factory()->empty_string()).ToHandleChecked();
2147 CHECK_EQ(isolate->heap()->false_value(), *result); 2150 CHECK_EQ(isolate->heap()->false_value(), *result);
2148 2151
2149 result = ft.Call(isolate->factory()->NewPrivateSymbol()).ToHandleChecked(); 2152 result = ft.Call(isolate->factory()->NewPrivateSymbol()).ToHandleChecked();
2150 CHECK_EQ(isolate->heap()->true_value(), *result); 2153 CHECK_EQ(isolate->heap()->true_value(), *result);
2151 } 2154 }
2152 2155
2153 } // namespace internal 2156 } // namespace internal
2154 } // namespace v8 2157 } // namespace v8
OLDNEW
« src/isolate.cc ('K') | « test/cctest/test-api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698