1// Copyright 2018 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/api-arguments.h"
6
7#include "src/api-arguments-inl.h"
8
9namespace v8 {
10namespace internal {
11
12PropertyCallbackArguments::PropertyCallbackArguments(
13 Isolate* isolate, Object data, Object self, JSObject holder,
14 Maybe<ShouldThrow> should_throw)
15 : Super(isolate) {
16 slot_at(T::kThisIndex).store(self);
17 slot_at(T::kHolderIndex).store(holder);
18 slot_at(T::kDataIndex).store(data);
19 slot_at(T::kIsolateIndex).store(Object(reinterpret_cast<Address>(isolate)));
20 int value = Internals::kInferShouldThrowMode;
21 if (should_throw.IsJust()) {
22 value = should_throw.FromJust();
23 }
24 slot_at(T::kShouldThrowOnErrorIndex).store(Smi::FromInt(value));
25
26 // Here the hole is set as default value.
27 // It cannot escape into js as it's removed in Call below.
28 HeapObject the_hole = ReadOnlyRoots(isolate).the_hole_value();
29 slot_at(T::kReturnValueDefaultValueIndex).store(the_hole);
30 slot_at(T::kReturnValueIndex).store(the_hole);
31 DCHECK((*slot_at(T::kHolderIndex))->IsHeapObject());
32 DCHECK((*slot_at(T::kIsolateIndex))->IsSmi());
33}
34
35FunctionCallbackArguments::FunctionCallbackArguments(
36 internal::Isolate* isolate, internal::Object data,
37 internal::HeapObject callee, internal::Object holder,
38 internal::HeapObject new_target, internal::Address* argv, int argc)
39 : Super(isolate), argv_(argv), argc_(argc) {
40 slot_at(T::kDataIndex).store(data);
41 slot_at(T::kHolderIndex).store(holder);
42 slot_at(T::kNewTargetIndex).store(new_target);
43 slot_at(T::kIsolateIndex).store(Object(reinterpret_cast<Address>(isolate)));
44 // Here the hole is set as default value.
45 // It cannot escape into js as it's remove in Call below.
46 HeapObject the_hole = ReadOnlyRoots(isolate).the_hole_value();
47 slot_at(T::kReturnValueDefaultValueIndex).store(the_hole);
48 slot_at(T::kReturnValueIndex).store(the_hole);
49 DCHECK((*slot_at(T::kHolderIndex))->IsHeapObject());
50 DCHECK((*slot_at(T::kIsolateIndex))->IsSmi());
51}
52
53} // namespace internal
54} // namespace v8
55