@@ -1177,61 +1177,43 @@ TypeProfile::ScriptData TypeProfile::GetScriptData(size_t i) const {
1177
1177
return ScriptData (i, type_profile_);
1178
1178
}
1179
1179
1180
- v8::MaybeLocal<v8::Value> WeakMap::Get (v8::Local<v8::Context> context,
1181
- v8::Local<v8::Value> key) {
1182
- PREPARE_FOR_EXECUTION (context, WeakMap, Get, Value);
1183
- auto self = Utils::OpenHandle (this );
1184
- Local<Value> result;
1185
- i::Handle <i::Object> argv[] = {Utils::OpenHandle (*key)};
1186
- has_pending_exception =
1187
- !ToLocal<Value>(i::Execution::CallBuiltin (isolate, isolate->weakmap_get (),
1188
- self, arraysize (argv), argv),
1189
- &result);
1190
- RETURN_ON_FAILED_EXECUTION (Value);
1191
- RETURN_ESCAPED (result);
1180
+ MaybeLocal<v8::Value> EphemeronTable::Get (v8::Isolate* isolate,
1181
+ v8::Local<v8::Value> key) {
1182
+ i::Isolate* internal_isolate = reinterpret_cast <i::Isolate*>(isolate);
1183
+ auto self = i::Handle <i::EphemeronHashTable>::cast (Utils::OpenHandle (this ));
1184
+ i::Handle <i::Object> internal_key = Utils::OpenHandle (*key);
1185
+ DCHECK (internal_key->IsJSReceiver ());
1186
+
1187
+ i::Handle <i::Object> value (self->Lookup (internal_key), internal_isolate);
1188
+
1189
+ if (value->IsTheHole ()) return {};
1190
+ return Utils::ToLocal (value);
1192
1191
}
1193
1192
1194
- v8::Maybe<bool > WeakMap::Delete (v8::Local<v8::Context> context,
1195
- v8::Local<v8::Value> key) {
1196
- PREPARE_FOR_EXECUTION_WITH_CONTEXT (context, WeakMap, Delete, Nothing<bool >(),
1197
- InternalEscapableScope, false );
1198
- auto self = Utils::OpenHandle (this );
1199
- Local<Value> result;
1200
- i::Handle <i::Object> argv[] = {Utils::OpenHandle (*key)};
1201
- has_pending_exception = !ToLocal<Value>(
1202
- i::Execution::CallBuiltin (isolate, isolate->weakmap_delete (), self,
1203
- arraysize (argv), argv),
1204
- &result);
1205
- RETURN_ON_FAILED_EXECUTION_PRIMITIVE (bool );
1206
- return Just (result->IsTrue ());
1207
- }
1208
-
1209
- v8::MaybeLocal<WeakMap> WeakMap::Set (v8::Local<v8::Context> context,
1210
- v8::Local<v8::Value> key,
1211
- v8::Local<v8::Value> value) {
1212
- PREPARE_FOR_EXECUTION (context, WeakMap, Set, WeakMap);
1213
- auto self = Utils::OpenHandle (this );
1214
- i::Handle <i::Object> result;
1215
- i::Handle <i::Object> argv[] = {Utils::OpenHandle (*key),
1216
- Utils::OpenHandle (*value)};
1217
- has_pending_exception =
1218
- !i::Execution::CallBuiltin (isolate, isolate->weakmap_set (), self,
1219
- arraysize (argv), argv)
1220
- .ToHandle (&result);
1221
- RETURN_ON_FAILED_EXECUTION (WeakMap);
1222
- RETURN_ESCAPED (Local<WeakMap>::Cast (Utils::ToLocal (result)));
1223
- }
1224
-
1225
- Local<WeakMap> WeakMap::New (v8::Isolate* isolate) {
1193
+ Local<EphemeronTable> EphemeronTable::Set (v8::Isolate* isolate,
1194
+ v8::Local<v8::Value> key,
1195
+ v8::Local<v8::Value> value) {
1196
+ auto self = i::Handle <i::EphemeronHashTable>::cast (Utils::OpenHandle (this ));
1197
+ i::Handle <i::Object> internal_key = Utils::OpenHandle (*key);
1198
+ i::Handle <i::Object> internal_value = Utils::OpenHandle (*value);
1199
+ DCHECK (internal_key->IsJSReceiver ());
1200
+
1201
+ i::Handle <i::EphemeronHashTable> result (
1202
+ i::EphemeronHashTable::Put (self, internal_key, internal_value));
1203
+
1204
+ return ToApiHandle<EphemeronTable>(result);
1205
+ }
1206
+
1207
+ Local<EphemeronTable> EphemeronTable::New (v8::Isolate* isolate) {
1226
1208
i::Isolate* i_isolate = reinterpret_cast <i::Isolate*>(isolate);
1227
- LOG_API (i_isolate, WeakMap, New);
1228
1209
ENTER_V8_NO_SCRIPT_NO_EXCEPTION (i_isolate);
1229
- i::Handle <i::JSWeakMap> obj = i_isolate->factory ()->NewJSWeakMap ();
1230
- return ToApiHandle<WeakMap>(obj);
1210
+ i::Handle <i::EphemeronHashTable> table =
1211
+ i::EphemeronHashTable::New (i_isolate, 0 );
1212
+ return ToApiHandle<EphemeronTable>(table);
1231
1213
}
1232
1214
1233
- WeakMap* WeakMap ::Cast (v8::Value* value) {
1234
- return static_cast <WeakMap *>(value);
1215
+ EphemeronTable* EphemeronTable ::Cast (v8::Value* value) {
1216
+ return static_cast <EphemeronTable *>(value);
1235
1217
}
1236
1218
1237
1219
Local<Value> AccessorPair::getter () {
0 commit comments