Line data Source code
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 :
9 : namespace v8 {
10 : namespace internal {
11 :
12 2603112 : PropertyCallbackArguments::PropertyCallbackArguments(
13 : Isolate* isolate, Object data, Object self, JSObject holder,
14 : Maybe<ShouldThrow> should_throw)
15 2603112 : : Super(isolate) {
16 : slot_at(T::kThisIndex).store(self);
17 : slot_at(T::kHolderIndex).store(holder);
18 : slot_at(T::kDataIndex).store(data);
19 2603112 : slot_at(T::kIsolateIndex).store(Object(reinterpret_cast<Address>(isolate)));
20 : int value = Internals::kInferShouldThrowMode;
21 2603112 : if (should_throw.IsJust()) {
22 1811771 : 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 2603112 : }
34 :
35 2544094 : FunctionCallbackArguments::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 2544094 : 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 2544095 : }
52 :
53 : } // namespace internal
54 178779 : } // namespace v8
|