1 // Copyright 2017 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "src/builtins/builtins-utils-gen.h"
6 #include "src/builtins/builtins.h"
7 #include "src/code-stub-assembler.h"
8 #include "src/frame-constants.h"
9
10 namespace v8 {
11 namespace internal {
12
TF_BUILTIN(FastConsoleAssert,CodeStubAssembler)13 TF_BUILTIN(FastConsoleAssert, CodeStubAssembler) {
14 Label runtime(this);
15 Label out(this);
16
17 // TODO(ishell): use constants from Descriptor once the JSFunction linkage
18 // arguments are reordered.
19 Node* argc = Parameter(Descriptor::kJSActualArgumentsCount);
20 Node* context = Parameter(Descriptor::kContext);
21 Node* new_target = Parameter(Descriptor::kJSNewTarget);
22 GotoIf(Word32Equal(argc, Int32Constant(0)), &runtime);
23
24 CodeStubArguments args(this, ChangeInt32ToIntPtr(argc));
25 BranchIfToBooleanIsTrue(args.AtIndex(0), &out, &runtime);
26 BIND(&out);
27 args.PopAndReturn(UndefinedConstant());
28
29 BIND(&runtime);
30 {
31 // We are not using Parameter(Descriptor::kJSTarget) and loading the value
32 // from the current frame here in order to reduce register pressure on the
33 // fast path.
34 TNode<JSFunction> target = LoadTargetFromFrame();
35 TailCallBuiltin(Builtins::kConsoleAssert, context, target, new_target,
36 argc);
37 }
38 }
39
40 } // namespace internal
41 } // namespace v8
42