[ddc] Isolate function signature per app

Fix function signatures from one app leaking into another app when
communicating via JavaScript interop.

Change-Id: Iba881f78bbe5444e3888c55fd317b8eda8e19f18
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321520
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
This commit is contained in:
Nicholas Shahan 2023-08-17 22:56:57 +00:00 committed by Commit Queue
parent 9f7de0dcd3
commit 7a93d80473
3 changed files with 8 additions and 2 deletions

View file

@ -17,7 +17,7 @@ const String dartSdkModule = 'dart_sdk';
/// `JsGetName` enum.
abstract class FixedNames {
static const operatorIsPrefix = r'$is_';
static const operatorSignature = r'$signature';
static const operatorSignature = r'_functionRti';
static const rtiName = r'$ti';
static const rtiAsField = '_as';
static const rtiIsField = '_is';

View file

@ -6646,7 +6646,8 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
case JsGetName.OPERATOR_IS_PREFIX:
return js.string(js_ast.FixedNames.operatorIsPrefix);
case JsGetName.SIGNATURE_NAME:
return js.string(js_ast.FixedNames.operatorSignature);
return runtimeCall(
'#', [js.string(js_ast.FixedNames.operatorSignature)]);
case JsGetName.RTI_NAME:
return js.string(js_ast.FixedNames.rtiName);
case JsGetName.FUTURE_CLASS_TYPE_NAME:

View file

@ -98,6 +98,11 @@ void nativeNonNullAsserts(bool enable) {
/// A JavaScript Symbol used to store the Rti object on a native array.
final arrayRti = JS('', r'Symbol("$ti")');
/// A JavaScript Symbol used to store the Rti signature object on a function.
///
/// Accessed by a call to `JS_GET_NAME(JsGetName.SIGNATURE_NAME)`.
final _functionRti = JS('', r'Symbol("$signatureRti")');
final metadata = JS('', 'Symbol("metadata")');
/// A javascript Symbol used to store a canonical version of T? on T.