1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

Fix protobufjs snapshotting.

This commit is contained in:
Ryan Dahl 2018-06-12 06:36:01 +02:00
parent dd48f8095c
commit 7784cc2c15
12 changed files with 1786 additions and 2125 deletions

View file

@ -98,7 +98,7 @@ run_node("bundle") {
run_node("run_tsc") {
main_source = "js/main.ts"
sources = [
"js/msg.pb.d.ts",
#"js/msg.pb.d.ts",
"js/msg.pb.js",
"js/tsconfig.json",
main_source,
@ -178,6 +178,9 @@ template("create_snapshot") {
rebase_path(natives_out_cc, root_build_dir),
rebase_path(snapshot_out_cc, root_build_dir),
]
# To debug snapshotting problems:
# args += ["--trace-serializer"]
data = [
invoker.js,
]

View file

@ -199,6 +199,19 @@ bool Execute(v8::Local<v8::Context> context, const char* js_filename,
return true;
}
v8::StartupData SerializeInternalFields(v8::Local<v8::Object> holder, int index,
void* data) {
assert(data == nullptr); // TODO(ry) pass Deno* object here.
InternalFieldData* embedder_field = static_cast<InternalFieldData*>(
holder->GetAlignedPointerFromInternalField(index));
if (embedder_field == nullptr) return {nullptr, 0};
int size = sizeof(*embedder_field);
char* payload = new char[size];
// We simply use memcpy to serialize the content.
memcpy(payload, embedder_field, size);
return {payload, size};
}
v8::StartupData MakeSnapshot(v8::StartupData* prev_natives_blob,
v8::StartupData* prev_snapshot_blob,
const char* js_filename, const char* js_source) {
@ -232,7 +245,8 @@ v8::StartupData MakeSnapshot(v8::StartupData* prev_natives_blob,
bool r = Execute(context, js_filename, js_source);
assert(r);
creator->SetDefaultContext(context);
creator->SetDefaultContext(context, v8::SerializeInternalFieldsCallback(
SerializeInternalFields, nullptr));
}
auto snapshot_blob =

View file

@ -21,6 +21,10 @@ struct deno_s {
namespace deno {
struct InternalFieldData {
uint32_t data;
};
void Print(const v8::FunctionCallbackInfo<v8::Value>& args);
void Sub(const v8::FunctionCallbackInfo<v8::Value>& args);
void Pub(const v8::FunctionCallbackInfo<v8::Value>& args);

View file

@ -21,12 +21,28 @@ namespace deno {
#include "snapshot_deno.cc"
#endif
std::vector<InternalFieldData*> deserialized_data;
void DeserializeInternalFields(v8::Local<v8::Object> holder, int index,
v8::StartupData payload, void* data) {
assert(data == nullptr); // TODO(ry) pass Deno* object here.
if (payload.raw_size == 0) {
holder->SetAlignedPointerInInternalField(index, nullptr);
return;
}
InternalFieldData* embedder_field = new InternalFieldData{0};
memcpy(embedder_field, payload.data, payload.raw_size);
holder->SetAlignedPointerInInternalField(index, embedder_field);
deserialized_data.push_back(embedder_field);
}
Deno* NewFromSnapshot(void* data, deno_sub_cb cb) {
auto natives_blob = *StartupBlob_natives();
auto snapshot_blob = *StartupBlob_snapshot();
v8::V8::SetNativesDataBlob(&natives_blob);
v8::V8::SetSnapshotDataBlob(&snapshot_blob);
v8::DeserializeInternalFieldsCallback(DeserializeInternalFields, nullptr);
Deno* d = new Deno;
d->cb = cb;
@ -42,7 +58,11 @@ Deno* NewFromSnapshot(void* data, deno_sub_cb cb) {
v8::Isolate::Scope isolate_scope(isolate);
{
v8::HandleScope handle_scope(isolate);
auto context = v8::Context::New(isolate);
auto context =
v8::Context::New(isolate, nullptr, v8::MaybeLocal<v8::ObjectTemplate>(),
v8::MaybeLocal<v8::Value>(),
v8::DeserializeInternalFieldsCallback(
DeserializeInternalFields, nullptr));
d->context.Reset(d->isolate, context);
}

View file

@ -1,12 +1,13 @@
/// <reference path="deno.d.ts" />
//import { main as pb } from "./msg.pb"
import { main as pb } from "./msg.pb";
import * as ts from "typescript";
const globalEval = eval;
const window = globalEval("this");
window["denoMain"] = () => {
//const msg = pb.Msg.fromObject({});
//denoPrint(`msg.command: ${msg.command}`);
denoPrint("Hello world");
const msg = pb.Msg.fromObject({});
denoPrint(`msg.command: ${msg.command}`);
denoPrint(`ts.version: ${ts.version}`);
denoPrint("Hello world from foo");
return "foo";

View file

@ -15,6 +15,17 @@ function CanCallFunction() {
return "foo";
}
// This object is created to test snapshotting.
// See DeserializeInternalFieldsCallback and SerializeInternalFieldsCallback.
const snapshotted = new Uint8Array([1, 3, 3, 7]);
function TypedArraySnapshots() {
assert(snapshotted[0] === 1);
assert(snapshotted[1] === 3);
assert(snapshotted[2] === 3);
assert(snapshotted[3] === 7);
}
function PubSuccess() {
denoSub((channel, msg) => {
assert(channel === "PubSuccess");

824
deno2/js/msg.pb.d.ts vendored
View file

@ -2,431 +2,409 @@ import * as $protobuf from "protobufjs";
/** Namespace main. */
export namespace main {
/** Properties of a BaseMsg. */
interface IBaseMsg {
/** BaseMsg channel */
channel?: string | null;
/** BaseMsg payload */
payload?: Uint8Array | null;
}
/** Properties of a BaseMsg. */
interface IBaseMsg {
/** Represents a BaseMsg. */
class BaseMsg implements IBaseMsg {
/**
* Constructs a new BaseMsg.
* @param [properties] Properties to set
*/
constructor(properties?: main.IBaseMsg);
/** BaseMsg channel */
channel?: (string|null);
/** BaseMsg channel. */
public channel: string;
/** BaseMsg payload. */
public payload: Uint8Array;
/**
* Creates a new BaseMsg instance using the specified properties.
* @param [properties] Properties to set
* @returns BaseMsg instance
*/
public static create(properties?: main.IBaseMsg): main.BaseMsg;
/**
* Encodes the specified BaseMsg message. Does not implicitly {@link main.BaseMsg.verify|verify} messages.
* @param message BaseMsg message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encode(
message: main.IBaseMsg,
writer?: $protobuf.Writer
): $protobuf.Writer;
/**
* Encodes the specified BaseMsg message, length delimited. Does not implicitly {@link main.BaseMsg.verify|verify} messages.
* @param message BaseMsg message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encodeDelimited(
message: main.IBaseMsg,
writer?: $protobuf.Writer
): $protobuf.Writer;
/**
* Decodes a BaseMsg message from the specified reader or buffer.
* @param reader Reader or buffer to decode from
* @param [length] Message length if known beforehand
* @returns BaseMsg
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
public static decode(
reader: $protobuf.Reader | Uint8Array,
length?: number
): main.BaseMsg;
/**
* Decodes a BaseMsg message from the specified reader or buffer, length delimited.
* @param reader Reader or buffer to decode from
* @returns BaseMsg
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
public static decodeDelimited(
reader: $protobuf.Reader | Uint8Array
): main.BaseMsg;
/**
* Verifies a BaseMsg message.
* @param message Plain object to verify
* @returns `null` if valid, otherwise the reason why it is not
*/
public static verify(message: { [k: string]: any }): string | null;
/**
* Creates a BaseMsg message from a plain object. Also converts values to their respective internal types.
* @param object Plain object
* @returns BaseMsg
*/
public static fromObject(object: { [k: string]: any }): main.BaseMsg;
/**
* Creates a plain object from a BaseMsg message. Also converts values to other types if specified.
* @param message BaseMsg
* @param [options] Conversion options
* @returns Plain object
*/
public static toObject(
message: main.BaseMsg,
options?: $protobuf.IConversionOptions
): { [k: string]: any };
/**
* Converts this BaseMsg to JSON.
* @returns JSON object
*/
public toJSON(): { [k: string]: any };
}
/** Properties of a Msg. */
interface IMsg {
/** Msg command */
command?: main.Msg.Command | null;
/** Msg error */
error?: string | null;
/** Msg startCwd */
startCwd?: string | null;
/** Msg startArgv */
startArgv?: string[] | null;
/** Msg startDebugFlag */
startDebugFlag?: boolean | null;
/** Msg startMainJs */
startMainJs?: string | null;
/** Msg startMainMap */
startMainMap?: string | null;
/** Msg codeFetchModuleSpecifier */
codeFetchModuleSpecifier?: string | null;
/** Msg codeFetchContainingFile */
codeFetchContainingFile?: string | null;
/** Msg codeFetchResModuleName */
codeFetchResModuleName?: string | null;
/** Msg codeFetchResFilename */
codeFetchResFilename?: string | null;
/** Msg codeFetchResSourceCode */
codeFetchResSourceCode?: string | null;
/** Msg codeFetchResOutputCode */
codeFetchResOutputCode?: string | null;
/** Msg codeCacheFilename */
codeCacheFilename?: string | null;
/** Msg codeCacheSourceCode */
codeCacheSourceCode?: string | null;
/** Msg codeCacheOutputCode */
codeCacheOutputCode?: string | null;
/** Msg exitCode */
exitCode?: number | null;
/** Msg timerStartId */
timerStartId?: number | null;
/** Msg timerStartInterval */
timerStartInterval?: boolean | null;
/** Msg timerStartDelay */
timerStartDelay?: number | null;
/** Msg timerReadyId */
timerReadyId?: number | null;
/** Msg timerReadyDone */
timerReadyDone?: boolean | null;
/** Msg timerClearId */
timerClearId?: number | null;
/** Msg fetchReqId */
fetchReqId?: number | null;
/** Msg fetchReqUrl */
fetchReqUrl?: string | null;
/** Msg fetchResId */
fetchResId?: number | null;
/** Msg fetchResStatus */
fetchResStatus?: number | null;
/** Msg fetchResHeaderLine */
fetchResHeaderLine?: string[] | null;
/** Msg fetchResBody */
fetchResBody?: Uint8Array | null;
/** Msg readFileSyncFilename */
readFileSyncFilename?: string | null;
/** Msg readFileSyncData */
readFileSyncData?: Uint8Array | null;
/** Msg writeFileSyncFilename */
writeFileSyncFilename?: string | null;
/** Msg writeFileSyncData */
writeFileSyncData?: Uint8Array | null;
/** Msg writeFileSyncPerm */
writeFileSyncPerm?: number | null;
}
/** Represents a Msg. */
class Msg implements IMsg {
/**
* Constructs a new Msg.
* @param [properties] Properties to set
*/
constructor(properties?: main.IMsg);
/** Msg command. */
public command: main.Msg.Command;
/** Msg error. */
public error: string;
/** Msg startCwd. */
public startCwd: string;
/** Msg startArgv. */
public startArgv: string[];
/** Msg startDebugFlag. */
public startDebugFlag: boolean;
/** Msg startMainJs. */
public startMainJs: string;
/** Msg startMainMap. */
public startMainMap: string;
/** Msg codeFetchModuleSpecifier. */
public codeFetchModuleSpecifier: string;
/** Msg codeFetchContainingFile. */
public codeFetchContainingFile: string;
/** Msg codeFetchResModuleName. */
public codeFetchResModuleName: string;
/** Msg codeFetchResFilename. */
public codeFetchResFilename: string;
/** Msg codeFetchResSourceCode. */
public codeFetchResSourceCode: string;
/** Msg codeFetchResOutputCode. */
public codeFetchResOutputCode: string;
/** Msg codeCacheFilename. */
public codeCacheFilename: string;
/** Msg codeCacheSourceCode. */
public codeCacheSourceCode: string;
/** Msg codeCacheOutputCode. */
public codeCacheOutputCode: string;
/** Msg exitCode. */
public exitCode: number;
/** Msg timerStartId. */
public timerStartId: number;
/** Msg timerStartInterval. */
public timerStartInterval: boolean;
/** Msg timerStartDelay. */
public timerStartDelay: number;
/** Msg timerReadyId. */
public timerReadyId: number;
/** Msg timerReadyDone. */
public timerReadyDone: boolean;
/** Msg timerClearId. */
public timerClearId: number;
/** Msg fetchReqId. */
public fetchReqId: number;
/** Msg fetchReqUrl. */
public fetchReqUrl: string;
/** Msg fetchResId. */
public fetchResId: number;
/** Msg fetchResStatus. */
public fetchResStatus: number;
/** Msg fetchResHeaderLine. */
public fetchResHeaderLine: string[];
/** Msg fetchResBody. */
public fetchResBody: Uint8Array;
/** Msg readFileSyncFilename. */
public readFileSyncFilename: string;
/** Msg readFileSyncData. */
public readFileSyncData: Uint8Array;
/** Msg writeFileSyncFilename. */
public writeFileSyncFilename: string;
/** Msg writeFileSyncData. */
public writeFileSyncData: Uint8Array;
/** Msg writeFileSyncPerm. */
public writeFileSyncPerm: number;
/**
* Creates a new Msg instance using the specified properties.
* @param [properties] Properties to set
* @returns Msg instance
*/
public static create(properties?: main.IMsg): main.Msg;
/**
* Encodes the specified Msg message. Does not implicitly {@link main.Msg.verify|verify} messages.
* @param message Msg message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encode(
message: main.IMsg,
writer?: $protobuf.Writer
): $protobuf.Writer;
/**
* Encodes the specified Msg message, length delimited. Does not implicitly {@link main.Msg.verify|verify} messages.
* @param message Msg message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encodeDelimited(
message: main.IMsg,
writer?: $protobuf.Writer
): $protobuf.Writer;
/**
* Decodes a Msg message from the specified reader or buffer.
* @param reader Reader or buffer to decode from
* @param [length] Message length if known beforehand
* @returns Msg
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
public static decode(
reader: $protobuf.Reader | Uint8Array,
length?: number
): main.Msg;
/**
* Decodes a Msg message from the specified reader or buffer, length delimited.
* @param reader Reader or buffer to decode from
* @returns Msg
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
public static decodeDelimited(
reader: $protobuf.Reader | Uint8Array
): main.Msg;
/**
* Verifies a Msg message.
* @param message Plain object to verify
* @returns `null` if valid, otherwise the reason why it is not
*/
public static verify(message: { [k: string]: any }): string | null;
/**
* Creates a Msg message from a plain object. Also converts values to their respective internal types.
* @param object Plain object
* @returns Msg
*/
public static fromObject(object: { [k: string]: any }): main.Msg;
/**
* Creates a plain object from a Msg message. Also converts values to other types if specified.
* @param message Msg
* @param [options] Conversion options
* @returns Plain object
*/
public static toObject(
message: main.Msg,
options?: $protobuf.IConversionOptions
): { [k: string]: any };
/**
* Converts this Msg to JSON.
* @returns JSON object
*/
public toJSON(): { [k: string]: any };
}
namespace Msg {
/** Command enum. */
enum Command {
ERROR = 0,
START = 1,
CODE_FETCH = 2,
CODE_FETCH_RES = 3,
CODE_CACHE = 4,
EXIT = 5,
TIMER_START = 6,
TIMER_READY = 7,
TIMER_CLEAR = 8,
FETCH_REQ = 9,
FETCH_RES = 10,
READ_FILE_SYNC = 11,
READ_FILE_SYNC_RES = 12,
WRITE_FILE_SYNC = 13
/** BaseMsg payload */
payload?: (Uint8Array|null);
}
/** Represents a BaseMsg. */
class BaseMsg implements IBaseMsg {
/**
* Constructs a new BaseMsg.
* @param [properties] Properties to set
*/
constructor(properties?: main.IBaseMsg);
/** BaseMsg channel. */
public channel: string;
/** BaseMsg payload. */
public payload: Uint8Array;
/**
* Creates a new BaseMsg instance using the specified properties.
* @param [properties] Properties to set
* @returns BaseMsg instance
*/
public static create(properties?: main.IBaseMsg): main.BaseMsg;
/**
* Encodes the specified BaseMsg message. Does not implicitly {@link main.BaseMsg.verify|verify} messages.
* @param message BaseMsg message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encode(message: main.IBaseMsg, writer?: $protobuf.Writer): $protobuf.Writer;
/**
* Encodes the specified BaseMsg message, length delimited. Does not implicitly {@link main.BaseMsg.verify|verify} messages.
* @param message BaseMsg message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encodeDelimited(message: main.IBaseMsg, writer?: $protobuf.Writer): $protobuf.Writer;
/**
* Decodes a BaseMsg message from the specified reader or buffer.
* @param reader Reader or buffer to decode from
* @param [length] Message length if known beforehand
* @returns BaseMsg
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): main.BaseMsg;
/**
* Decodes a BaseMsg message from the specified reader or buffer, length delimited.
* @param reader Reader or buffer to decode from
* @returns BaseMsg
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): main.BaseMsg;
/**
* Verifies a BaseMsg message.
* @param message Plain object to verify
* @returns `null` if valid, otherwise the reason why it is not
*/
public static verify(message: { [k: string]: any }): (string|null);
/**
* Creates a BaseMsg message from a plain object. Also converts values to their respective internal types.
* @param object Plain object
* @returns BaseMsg
*/
public static fromObject(object: { [k: string]: any }): main.BaseMsg;
/**
* Creates a plain object from a BaseMsg message. Also converts values to other types if specified.
* @param message BaseMsg
* @param [options] Conversion options
* @returns Plain object
*/
public static toObject(message: main.BaseMsg, options?: $protobuf.IConversionOptions): { [k: string]: any };
/**
* Converts this BaseMsg to JSON.
* @returns JSON object
*/
public toJSON(): { [k: string]: any };
}
/** Properties of a Msg. */
interface IMsg {
/** Msg command */
command?: (main.Msg.Command|null);
/** Msg error */
error?: (string|null);
/** Msg startCwd */
startCwd?: (string|null);
/** Msg startArgv */
startArgv?: (string[]|null);
/** Msg startDebugFlag */
startDebugFlag?: (boolean|null);
/** Msg startMainJs */
startMainJs?: (string|null);
/** Msg startMainMap */
startMainMap?: (string|null);
/** Msg codeFetchModuleSpecifier */
codeFetchModuleSpecifier?: (string|null);
/** Msg codeFetchContainingFile */
codeFetchContainingFile?: (string|null);
/** Msg codeFetchResModuleName */
codeFetchResModuleName?: (string|null);
/** Msg codeFetchResFilename */
codeFetchResFilename?: (string|null);
/** Msg codeFetchResSourceCode */
codeFetchResSourceCode?: (string|null);
/** Msg codeFetchResOutputCode */
codeFetchResOutputCode?: (string|null);
/** Msg codeCacheFilename */
codeCacheFilename?: (string|null);
/** Msg codeCacheSourceCode */
codeCacheSourceCode?: (string|null);
/** Msg codeCacheOutputCode */
codeCacheOutputCode?: (string|null);
/** Msg exitCode */
exitCode?: (number|null);
/** Msg timerStartId */
timerStartId?: (number|null);
/** Msg timerStartInterval */
timerStartInterval?: (boolean|null);
/** Msg timerStartDelay */
timerStartDelay?: (number|null);
/** Msg timerReadyId */
timerReadyId?: (number|null);
/** Msg timerReadyDone */
timerReadyDone?: (boolean|null);
/** Msg timerClearId */
timerClearId?: (number|null);
/** Msg fetchReqId */
fetchReqId?: (number|null);
/** Msg fetchReqUrl */
fetchReqUrl?: (string|null);
/** Msg fetchResId */
fetchResId?: (number|null);
/** Msg fetchResStatus */
fetchResStatus?: (number|null);
/** Msg fetchResHeaderLine */
fetchResHeaderLine?: (string[]|null);
/** Msg fetchResBody */
fetchResBody?: (Uint8Array|null);
/** Msg readFileSyncFilename */
readFileSyncFilename?: (string|null);
/** Msg readFileSyncData */
readFileSyncData?: (Uint8Array|null);
/** Msg writeFileSyncFilename */
writeFileSyncFilename?: (string|null);
/** Msg writeFileSyncData */
writeFileSyncData?: (Uint8Array|null);
/** Msg writeFileSyncPerm */
writeFileSyncPerm?: (number|null);
}
/** Represents a Msg. */
class Msg implements IMsg {
/**
* Constructs a new Msg.
* @param [properties] Properties to set
*/
constructor(properties?: main.IMsg);
/** Msg command. */
public command: main.Msg.Command;
/** Msg error. */
public error: string;
/** Msg startCwd. */
public startCwd: string;
/** Msg startArgv. */
public startArgv: string[];
/** Msg startDebugFlag. */
public startDebugFlag: boolean;
/** Msg startMainJs. */
public startMainJs: string;
/** Msg startMainMap. */
public startMainMap: string;
/** Msg codeFetchModuleSpecifier. */
public codeFetchModuleSpecifier: string;
/** Msg codeFetchContainingFile. */
public codeFetchContainingFile: string;
/** Msg codeFetchResModuleName. */
public codeFetchResModuleName: string;
/** Msg codeFetchResFilename. */
public codeFetchResFilename: string;
/** Msg codeFetchResSourceCode. */
public codeFetchResSourceCode: string;
/** Msg codeFetchResOutputCode. */
public codeFetchResOutputCode: string;
/** Msg codeCacheFilename. */
public codeCacheFilename: string;
/** Msg codeCacheSourceCode. */
public codeCacheSourceCode: string;
/** Msg codeCacheOutputCode. */
public codeCacheOutputCode: string;
/** Msg exitCode. */
public exitCode: number;
/** Msg timerStartId. */
public timerStartId: number;
/** Msg timerStartInterval. */
public timerStartInterval: boolean;
/** Msg timerStartDelay. */
public timerStartDelay: number;
/** Msg timerReadyId. */
public timerReadyId: number;
/** Msg timerReadyDone. */
public timerReadyDone: boolean;
/** Msg timerClearId. */
public timerClearId: number;
/** Msg fetchReqId. */
public fetchReqId: number;
/** Msg fetchReqUrl. */
public fetchReqUrl: string;
/** Msg fetchResId. */
public fetchResId: number;
/** Msg fetchResStatus. */
public fetchResStatus: number;
/** Msg fetchResHeaderLine. */
public fetchResHeaderLine: string[];
/** Msg fetchResBody. */
public fetchResBody: Uint8Array;
/** Msg readFileSyncFilename. */
public readFileSyncFilename: string;
/** Msg readFileSyncData. */
public readFileSyncData: Uint8Array;
/** Msg writeFileSyncFilename. */
public writeFileSyncFilename: string;
/** Msg writeFileSyncData. */
public writeFileSyncData: Uint8Array;
/** Msg writeFileSyncPerm. */
public writeFileSyncPerm: number;
/**
* Creates a new Msg instance using the specified properties.
* @param [properties] Properties to set
* @returns Msg instance
*/
public static create(properties?: main.IMsg): main.Msg;
/**
* Encodes the specified Msg message. Does not implicitly {@link main.Msg.verify|verify} messages.
* @param message Msg message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encode(message: main.IMsg, writer?: $protobuf.Writer): $protobuf.Writer;
/**
* Encodes the specified Msg message, length delimited. Does not implicitly {@link main.Msg.verify|verify} messages.
* @param message Msg message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encodeDelimited(message: main.IMsg, writer?: $protobuf.Writer): $protobuf.Writer;
/**
* Decodes a Msg message from the specified reader or buffer.
* @param reader Reader or buffer to decode from
* @param [length] Message length if known beforehand
* @returns Msg
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): main.Msg;
/**
* Decodes a Msg message from the specified reader or buffer, length delimited.
* @param reader Reader or buffer to decode from
* @returns Msg
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): main.Msg;
/**
* Verifies a Msg message.
* @param message Plain object to verify
* @returns `null` if valid, otherwise the reason why it is not
*/
public static verify(message: { [k: string]: any }): (string|null);
/**
* Creates a Msg message from a plain object. Also converts values to their respective internal types.
* @param object Plain object
* @returns Msg
*/
public static fromObject(object: { [k: string]: any }): main.Msg;
/**
* Creates a plain object from a Msg message. Also converts values to other types if specified.
* @param message Msg
* @param [options] Conversion options
* @returns Plain object
*/
public static toObject(message: main.Msg, options?: $protobuf.IConversionOptions): { [k: string]: any };
/**
* Converts this Msg to JSON.
* @returns JSON object
*/
public toJSON(): { [k: string]: any };
}
namespace Msg {
/** Command enum. */
enum Command {
ERROR = 0,
START = 1,
CODE_FETCH = 2,
CODE_FETCH_RES = 3,
CODE_CACHE = 4,
EXIT = 5,
TIMER_START = 6,
TIMER_READY = 7,
TIMER_CLEAR = 8,
FETCH_REQ = 9,
FETCH_RES = 10,
READ_FILE_SYNC = 11,
READ_FILE_SYNC_RES = 12,
WRITE_FILE_SYNC = 13
}
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -10,6 +10,7 @@ import sys
import os
js_path = os.path.dirname(os.path.realpath(__file__))
#bin_path = os.path.join(js_path, "deno_protobufjs", "bin")
bin_path = os.path.join(js_path, "node_modules", ".bin")
pbjs_bin = os.path.join(bin_path, "pbjs")
pbts_bin = os.path.join(bin_path, "pbts")
@ -28,8 +29,8 @@ def touch(fname):
open(fname, 'a').close()
subprocess.check_call([
"node",
pbjs_bin,
#"--dependency=./deno_protobufjs/minimal",
"--target=static-module",
"--wraper=commonjs",
"--out=" + msg_pbjs_out,
@ -45,5 +46,4 @@ subprocess.check_call([
])
assert os.path.exists(msg_pbts_out)
touch(stamp_file)

View file

@ -85,6 +85,12 @@ TEST(MockRuntimeTest, DoubleSubFails) {
deno_delete(d);
}
TEST(MockRuntimeTest, TypedArraySnapshots) {
Deno* d = deno_new(NULL, NULL);
EXPECT_TRUE(deno_execute(d, "a.js", "TypedArraySnapshots()"));
deno_delete(d);
}
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
deno_init();

View file

@ -1,5 +1,6 @@
// Copyright 2018 Ryan Dahl <ry@tinyclouds.org>
// All rights reserved. MIT License.
// Hint: --trace_serializer is a useful debugging flag.
#include <assert.h>
#include <stdio.h>
#include <string.h>
@ -126,6 +127,8 @@ int main(int argc, char** argv) {
const char* natives_out_cc = argv[4];
const char* snapshot_out_cc = argv[5];
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
auto js_data = ReadFile(js_fn);
auto natives_blob = ReadFile(natives_in_bin);
auto snapshot_in_blob = ReadFile(snapshot_in_bin);

View file

@ -4,4 +4,12 @@ clang-format -i -style Google *.cc *.h include/*.h
gn format BUILD.gn
gn format .gn
yapf -i tools/*.py
prettier --write js/*.ts js/*.js js/*.json
prettier --write \
js/deno.d.ts \
js/main.ts \
js/mock_runtime.js \
js/package.json \
js/tsconfig.json
# Do not format these.
# js/msg.pb.js
# js/msg.pb.d.ts