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