Skip to content

Commit 8a011b5

Browse files
danelphickCommit Bot
authored andcommitted
[explicit isolates] Remove nearly all GetIsolates in api.cc
This marks the following methods as V8_DEPRECATE_SOON and adds new versions that take Isolate* as their first parameter: PrimitiveArray::Set PrimitiveArray::Get StackTrace::GetFrame String::Write String::WriteOneByte String::WriteUtf8 String::Concat StringObject::New Additionally StackFrameInfo, Module and TemplateInfo are marked as NeverReadOnlySpaceObject so their GetIsolates calls are safe. In api.cc, ContextFromHeapObject is split into ContextFromNeverReadOnlySpaceObject and UnsafeContextFromHeapObject, where the latter uses the deprecated methods but is only called from methods that were themselves already marked V8_DEPRECATE_SOON. Deprecation warnings for using HeapObject::GetHeap/GetIsolate are suppressed for all the uses in V8_DEPRECATE_SOON methods so that stats produced using tools/collect_deprecation_stats.sh don't show them. Bug: v8:7786 Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng Change-Id: I48799b5599711661b14d0cd04f21a0a00322da4a Reviewed-on: https://chromium-review.googlesource.com/1136641 Commit-Queue: Dan Elphick <[email protected]> Reviewed-by: Leszek Swirski <[email protected]> Reviewed-by: Yang Guo <[email protected]> Cr-Commit-Position: refs/heads/master@{#54469}
1 parent 087cc34 commit 8a011b5

6 files changed

Lines changed: 258 additions & 100 deletions

File tree

include/v8.h

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ class Heap;
146146
class HeapObject;
147147
class Isolate;
148148
class LocalEmbedderHeapTracer;
149+
class NeverReadOnlySpaceObject;
149150
class Object;
150151
struct ScriptStreamingData;
151152
template<typename T> class CustomArguments;
@@ -994,8 +995,8 @@ class V8_EXPORT HandleScope {
994995
void operator delete[](void*, size_t);
995996

996997
// Uses heap_object to obtain the current Isolate.
997-
static internal::Object** CreateHandle(internal::HeapObject* heap_object,
998-
internal::Object* value);
998+
static internal::Object** CreateHandle(
999+
internal::NeverReadOnlySpaceObject* heap_object, internal::Object* value);
9991000

10001001
internal::Isolate* isolate_;
10011002
internal::Object** prev_next_;
@@ -1122,8 +1123,12 @@ class V8_EXPORT PrimitiveArray {
11221123
public:
11231124
static Local<PrimitiveArray> New(Isolate* isolate, int length);
11241125
int Length() const;
1125-
void Set(int index, Local<Primitive> item);
1126-
Local<Primitive> Get(int index);
1126+
void Set(Isolate* isolate, int index, Local<Primitive> item);
1127+
Local<Primitive> Get(Isolate* isolate, int index);
1128+
1129+
V8_DEPRECATE_SOON("Use Isolate version",
1130+
void Set(int index, Local<Primitive> item));
1131+
V8_DEPRECATE_SOON("Use Isolate version", Local<Primitive> Get(int index));
11271132
};
11281133

11291134
/**
@@ -1848,7 +1853,9 @@ class V8_EXPORT StackTrace {
18481853
/**
18491854
* Returns a StackFrame at a particular index.
18501855
*/
1851-
Local<StackFrame> GetFrame(uint32_t index) const;
1856+
V8_DEPRECATE_SOON("Use Isolate version",
1857+
Local<StackFrame> GetFrame(uint32_t index) const);
1858+
Local<StackFrame> GetFrame(Isolate* isolate, uint32_t index) const;
18521859

18531860
/**
18541861
* Returns the number of StackFrames.
@@ -2746,20 +2753,25 @@ class V8_EXPORT String : public Name {
27462753
};
27472754

27482755
// 16-bit character codes.
2749-
int Write(uint16_t* buffer,
2750-
int start = 0,
2751-
int length = -1,
2756+
int Write(Isolate* isolate, uint16_t* buffer, int start = 0, int length = -1,
27522757
int options = NO_OPTIONS) const;
2758+
V8_DEPRECATE_SOON("Use Isolate* version",
2759+
int Write(uint16_t* buffer, int start = 0, int length = -1,
2760+
int options = NO_OPTIONS) const);
27532761
// One byte characters.
2754-
int WriteOneByte(uint8_t* buffer,
2755-
int start = 0,
2756-
int length = -1,
2757-
int options = NO_OPTIONS) const;
2762+
int WriteOneByte(Isolate* isolate, uint8_t* buffer, int start = 0,
2763+
int length = -1, int options = NO_OPTIONS) const;
2764+
V8_DEPRECATE_SOON("Use Isolate* version",
2765+
int WriteOneByte(uint8_t* buffer, int start = 0,
2766+
int length = -1, int options = NO_OPTIONS)
2767+
const);
27582768
// UTF-8 encoded characters.
2759-
int WriteUtf8(char* buffer,
2760-
int length = -1,
2761-
int* nchars_ref = NULL,
2762-
int options = NO_OPTIONS) const;
2769+
int WriteUtf8(Isolate* isolate, char* buffer, int length = -1,
2770+
int* nchars_ref = NULL, int options = NO_OPTIONS) const;
2771+
V8_DEPRECATE_SOON("Use Isolate* version",
2772+
int WriteUtf8(char* buffer, int length = -1,
2773+
int* nchars_ref = NULL,
2774+
int options = NO_OPTIONS) const);
27632775

27642776
/**
27652777
* A zero length string.
@@ -2921,7 +2933,11 @@ class V8_EXPORT String : public Name {
29212933
* Creates a new string by concatenating the left and the right strings
29222934
* passed in as parameters.
29232935
*/
2924-
static Local<String> Concat(Local<String> left, Local<String> right);
2936+
static Local<String> Concat(Isolate* isolate, Local<String> left,
2937+
Local<String> right);
2938+
static V8_DEPRECATE_SOON("Use Isolate* version",
2939+
Local<String> Concat(Local<String> left,
2940+
Local<String> right));
29252941

29262942
/**
29272943
* Creates a new external string using the data defined in the given
@@ -5220,7 +5236,9 @@ class V8_EXPORT BooleanObject : public Object {
52205236
*/
52215237
class V8_EXPORT StringObject : public Object {
52225238
public:
5223-
static Local<Value> New(Local<String> value);
5239+
static Local<Value> New(Isolate* isolate, Local<String> value);
5240+
static V8_DEPRECATE_SOON("Use Isolate* version",
5241+
Local<Value> New(Local<String> value));
52245242

52255243
Local<String> ValueOf() const;
52265244

@@ -10090,7 +10108,6 @@ AccessorSignature* AccessorSignature::Cast(Data* data) {
1009010108
Local<Value> Object::GetInternalField(int index) {
1009110109
#ifndef V8_ENABLE_CHECKS
1009210110
typedef internal::Object O;
10093-
typedef internal::HeapObject HO;
1009410111
typedef internal::Internals I;
1009510112
O* obj = *reinterpret_cast<O**>(this);
1009610113
// Fast path: If the object is a plain JSObject, which is the common case, we
@@ -10101,7 +10118,8 @@ Local<Value> Object::GetInternalField(int index) {
1010110118
instance_type == I::kJSSpecialApiObjectType) {
1010210119
int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index);
1010310120
O* value = I::ReadField<O*>(obj, offset);
10104-
O** result = HandleScope::CreateHandle(reinterpret_cast<HO*>(obj), value);
10121+
O** result = HandleScope::CreateHandle(
10122+
reinterpret_cast<internal::NeverReadOnlySpaceObject*>(obj), value);
1010510123
return Local<Value>(reinterpret_cast<Value*>(result));
1010610124
}
1010710125
#endif
@@ -10741,9 +10759,8 @@ int64_t Isolate::AdjustAmountOfExternalAllocatedMemory(
1074110759
Local<Value> Context::GetEmbedderData(int index) {
1074210760
#ifndef V8_ENABLE_CHECKS
1074310761
typedef internal::Object O;
10744-
typedef internal::HeapObject HO;
1074510762
typedef internal::Internals I;
10746-
HO* context = *reinterpret_cast<HO**>(this);
10763+
auto* context = *reinterpret_cast<internal::NeverReadOnlySpaceObject**>(this);
1074710764
O** result =
1074810765
HandleScope::CreateHandle(context, I::ReadEmbedderData<O*>(this, index));
1074910766
return Local<Value>(reinterpret_cast<Value*>(result));

0 commit comments

Comments
 (0)