Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/value-serializer.cc

Issue 2364053003: ValueSerializer: Handle JS_SPECIAL_API_OBJECT_TYPE. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/value-serializer.h" 5 #include "src/value-serializer.h"
6 6
7 #include <type_traits> 7 #include <type_traits>
8 8
9 #include "src/base/logging.h" 9 #include "src/base/logging.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 WriteVarint(id - 1); 342 WriteVarint(id - 1);
343 return Just(true); 343 return Just(true);
344 } 344 }
345 345
346 // Otherwise, allocate an ID for it. 346 // Otherwise, allocate an ID for it.
347 uint32_t id = next_id_++; 347 uint32_t id = next_id_++;
348 *id_map_entry = id + 1; 348 *id_map_entry = id + 1;
349 349
350 // Eliminate callable and exotic objects, which should not be serialized. 350 // Eliminate callable and exotic objects, which should not be serialized.
351 InstanceType instance_type = receiver->map()->instance_type(); 351 InstanceType instance_type = receiver->map()->instance_type();
352 if (receiver->IsCallable() || instance_type <= LAST_SPECIAL_RECEIVER_TYPE) { 352 if (receiver->IsCallable() || (instance_type <= LAST_SPECIAL_RECEIVER_TYPE &&
353 instance_type != JS_SPECIAL_API_OBJECT_TYPE)) {
353 ThrowDataCloneError(MessageTemplate::kDataCloneError, receiver); 354 ThrowDataCloneError(MessageTemplate::kDataCloneError, receiver);
354 return Nothing<bool>(); 355 return Nothing<bool>();
355 } 356 }
356 357
357 // If we are at the end of the stack, abort. This function may recurse. 358 // If we are at the end of the stack, abort. This function may recurse.
358 STACK_CHECK(isolate_, Nothing<bool>()); 359 STACK_CHECK(isolate_, Nothing<bool>());
359 360
360 HandleScope scope(isolate_); 361 HandleScope scope(isolate_);
361 switch (instance_type) { 362 switch (instance_type) {
362 case JS_ARRAY_TYPE: 363 case JS_ARRAY_TYPE:
363 return WriteJSArray(Handle<JSArray>::cast(receiver)); 364 return WriteJSArray(Handle<JSArray>::cast(receiver));
364 case JS_OBJECT_TYPE: 365 case JS_OBJECT_TYPE:
365 case JS_API_OBJECT_TYPE: { 366 case JS_API_OBJECT_TYPE:
367 case JS_SPECIAL_API_OBJECT_TYPE: {
366 Handle<JSObject> js_object = Handle<JSObject>::cast(receiver); 368 Handle<JSObject> js_object = Handle<JSObject>::cast(receiver);
369 if (instance_type == JS_SPECIAL_API_OBJECT_TYPE)
370 DCHECK(js_object->GetInternalFieldCount());
Jakob Kummerow 2016/09/23 17:20:30 nit: {} please Or even better: DCHECK_IMPLIES(in
jbroman 2016/09/23 17:50:36 Urgh. I've been writing Blink CLs mostly for the l
367 return js_object->GetInternalFieldCount() ? WriteHostObject(js_object) 371 return js_object->GetInternalFieldCount() ? WriteHostObject(js_object)
368 : WriteJSObject(js_object); 372 : WriteJSObject(js_object);
369 } 373 }
370 case JS_DATE_TYPE: 374 case JS_DATE_TYPE:
371 WriteJSDate(JSDate::cast(*receiver)); 375 WriteJSDate(JSDate::cast(*receiver));
372 return Just(true); 376 return Just(true);
373 case JS_VALUE_TYPE: 377 case JS_VALUE_TYPE:
374 return WriteJSValue(Handle<JSValue>::cast(receiver)); 378 return WriteJSValue(Handle<JSValue>::cast(receiver));
375 case JS_REGEXP_TYPE: 379 case JS_REGEXP_TYPE:
376 WriteJSRegExp(JSRegExp::cast(*receiver)); 380 WriteJSRegExp(JSRegExp::cast(*receiver));
(...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after
1709 if (stack.size() != 1) { 1713 if (stack.size() != 1) {
1710 isolate_->Throw(*isolate_->factory()->NewError( 1714 isolate_->Throw(*isolate_->factory()->NewError(
1711 MessageTemplate::kDataCloneDeserializationError)); 1715 MessageTemplate::kDataCloneDeserializationError));
1712 return MaybeHandle<Object>(); 1716 return MaybeHandle<Object>();
1713 } 1717 }
1714 return scope.CloseAndEscape(stack[0]); 1718 return scope.CloseAndEscape(stack[0]);
1715 } 1719 }
1716 1720
1717 } // namespace internal 1721 } // namespace internal
1718 } // namespace v8 1722 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698