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 : #ifndef V8_OBJECTS_FOREIGN_INL_H_
6 : #define V8_OBJECTS_FOREIGN_INL_H_
7 :
8 : #include "src/objects/foreign.h"
9 :
10 : #include "src/heap/heap-write-barrier-inl.h"
11 : #include "src/objects-inl.h"
12 :
13 : // Has to be the last include (doesn't have include guards):
14 : #include "src/objects/object-macros.h"
15 :
16 : namespace v8 {
17 : namespace internal {
18 :
19 47628526 : OBJECT_CONSTRUCTORS_IMPL(Foreign, HeapObject)
20 :
21 23814262 : CAST_ACCESSOR(Foreign)
22 :
23 : // static
24 : bool Foreign::IsNormalized(Object value) {
25 : if (value == Smi::kZero) return true;
26 : return Foreign::cast(value)->foreign_address() != kNullAddress;
27 : }
28 :
29 : Address Foreign::foreign_address() {
30 22405473 : return READ_UINTPTR_FIELD(*this, kForeignAddressOffset);
31 : }
32 :
33 : void Foreign::set_foreign_address(Address value) {
34 10233079 : WRITE_UINTPTR_FIELD(*this, kForeignAddressOffset, value);
35 : }
36 :
37 : } // namespace internal
38 : } // namespace v8
39 :
40 : #include "src/objects/object-macros-undef.h"
41 :
42 : #endif // V8_OBJECTS_FOREIGN_INL_H_
|