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
PropertyCallbackArguments(Isolate * isolate,Object * data,Object * self,JSObject * holder,ShouldThrow should_throw)12 PropertyCallbackArguments::PropertyCallbackArguments(Isolate* isolate,
13 Object* data, Object* self,
14 JSObject* holder,
15 ShouldThrow should_throw)
16 : Super(isolate) {
17 Object** values = this->begin();
18 values[T::kThisIndex] = self;
19 values[T::kHolderIndex] = holder;
20 values[T::kDataIndex] = data;
21 values[T::kIsolateIndex] = reinterpret_cast<Object*>(isolate);
22 values[T::kShouldThrowOnErrorIndex] =
23 Smi::FromInt(should_throw == kThrowOnError ? 1 : 0);
24
25 // Here the hole is set as default value.
26 // It cannot escape into js as it's removed in Call below.
27 HeapObject* the_hole = ReadOnlyRoots(isolate).the_hole_value();
28 values[T::kReturnValueDefaultValueIndex] = the_hole;
29 values[T::kReturnValueIndex] = the_hole;
30 DCHECK(values[T::kHolderIndex]->IsHeapObject());
31 DCHECK(values[T::kIsolateIndex]->IsSmi());
32 }
33
FunctionCallbackArguments(internal::Isolate * isolate,internal::Object * data,internal::HeapObject * callee,internal::Object * holder,internal::HeapObject * new_target,internal::Object ** argv,int argc)34 FunctionCallbackArguments::FunctionCallbackArguments(
35 internal::Isolate* isolate, internal::Object* data,
36 internal::HeapObject* callee, internal::Object* holder,
37 internal::HeapObject* new_target, internal::Object** argv, int argc)
38 : Super(isolate), argv_(argv), argc_(argc) {
39 Object** values = begin();
40 values[T::kDataIndex] = data;
41 values[T::kHolderIndex] = holder;
42 values[T::kNewTargetIndex] = new_target;
43 values[T::kIsolateIndex] = reinterpret_cast<internal::Object*>(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 values[T::kReturnValueDefaultValueIndex] = the_hole;
48 values[T::kReturnValueIndex] = the_hole;
49 DCHECK(values[T::kHolderIndex]->IsHeapObject());
50 DCHECK(values[T::kIsolateIndex]->IsSmi());
51 }
52
53 } // namespace internal
54 } // namespace v8
55