Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Revert typed descriptors and printer (#2508)
Browse files Browse the repository at this point in the history
Summary:
23c5da5
and
2b68c6e
Pull Request resolved: #2508

Differential Revision: D9566539

Pulled By: sebmarkbage

fbshipit-source-id: efefa126a141134969bbe94c6033110dae7a7ab0
  • Loading branch information
sebmarkbage authored and facebook-github-bot committed Aug 30, 2018
1 parent f062f34 commit ec36389
Show file tree
Hide file tree
Showing 76 changed files with 1,456 additions and 3,084 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
yarn test-react
yarn test-sourcemaps
yarn test-std-in
yarn test-test262 --expectedCounts 11944,5641,0 --statusFile ~/artifacts/test262-status.txt --timeout 140 --cpuScale 0.25 --verbose
yarn test-test262 --expectedCounts 11944,5641,0 --statusFile ~/artifacts/test262-status.txt --timeout 120 --cpuScale 0.25 --verbose
#yarn test-test262-new --statusFile ~/artifacts/test262-new-status.txt --timeout 120 --verbose
- store_artifacts:
path: ~/artifacts/
Expand Down
34 changes: 4 additions & 30 deletions scripts/test-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ let execSpec;
let JSONTokenizer = require("../lib/utils/JSONTokenizer.js").default;
let { Linter } = require("eslint");
let lintConfig = require("./lint-config");
let TextPrinter = require("../lib/utils/TextPrinter.js").TextPrinter;

function transformWithBabel(code, plugins, presets) {
return babel.transform(code, {
Expand Down Expand Up @@ -432,7 +431,6 @@ function runTest(name, code, options: PrepackOptions, args) {
return Promise.resolve(false);
} else {
let codeIterations = [];
let irIterations = [];
let markersToFind = [];
for (let [positive, marker] of [[true, "// does contain:"], [false, "// does not contain:"]]) {
for (let i = code.indexOf(marker); i >= 0; i = code.indexOf(marker, i + 1)) {
Expand Down Expand Up @@ -511,14 +509,6 @@ function runTest(name, code, options: PrepackOptions, args) {
options.errorHandler = getErrorHandlerWithWarningCapture(diagnosticOutput, args.verbose);
}

let ir = "";
if (args.ir)
options.onExecute = (realm, optimizedFunctions) => {
new TextPrinter(line => {
ir += line + "\n";
}).print(realm, optimizedFunctions);
};

let serialized = prepackSources([{ filePath: name, fileContents: code, sourceMapContents: "" }], options);
if (serialized.statistics && serialized.statistics.delayedValues > 0) anyDelayedValues = true;
if (!serialized) {
Expand Down Expand Up @@ -595,11 +585,7 @@ function runTest(name, code, options: PrepackOptions, args) {
if (!execSpec && options.lazyObjectsRuntime !== undefined) {
codeToRun = augmentCodeWithLazyObjectSupport(codeToRun, args.lazyObjectsRuntime);
}
if (args.verbose) {
if (args.ir) console.log(`=== ir\n${ir}\n`);
console.log(`=== generated code\n${codeToRun}\n`);
}
irIterations.push(unescapeUniqueSuffix(ir, options.uniqueSuffix));
if (args.verbose) console.log(codeToRun);
codeIterations.push(unescapeUniqueSuffix(codeToRun, options.uniqueSuffix));
if (args.es5) {
codeToRun = transformWithBabel(
Expand Down Expand Up @@ -676,10 +662,6 @@ function runTest(name, code, options: PrepackOptions, args) {
console.error(chalk.underline("output of inspect() on original code"));
console.error(expected);
for (let ii = 0; ii < codeIterations.length; ii++) {
if (args.ir) {
console.error(chalk.underline(`ir in iteration ${ii}`));
console.error(irIterations[ii]);
}
console.error(chalk.underline(`generated code in iteration ${ii}`));
console.error(codeIterations[ii]);
}
Expand Down Expand Up @@ -851,7 +833,6 @@ class ProgramArgs {
fast: boolean;
residual: boolean;
cpuprofilePath: string;
ir: boolean;
constructor(
debugNames: boolean,
debugScopes: boolean,
Expand All @@ -863,8 +844,7 @@ class ProgramArgs {
noLazySupport: boolean,
fast: boolean,
residual: boolean,
cpuProfilePath: string,
ir: boolean
cpuProfilePath: string
) {
this.debugNames = debugNames;
this.debugScopes = debugScopes;
Expand All @@ -877,7 +857,6 @@ class ProgramArgs {
this.fast = fast;
this.residual = residual;
this.cpuprofilePath = cpuProfilePath;
this.ir = ir;
}
}

Expand Down Expand Up @@ -912,7 +891,7 @@ function usage(): string {
return (
`Usage: ${process.argv[0]} ${process.argv[1]} ` +
EOL +
`[--debugNames] [--debugScopes] [--es5] [--fast] [--noLazySupport] [--verbose] [--ir] [--filter <string>] [--outOfProcessRuntime <path>] `
`[--debugNames] [--debugScopes] [--es5] [--fast] [--noLazySupport] [--verbose] [--filter <string>] [--outOfProcessRuntime <path>] `
);
}

Expand Down Expand Up @@ -940,7 +919,6 @@ function argsParse(): ProgramArgs {
// to run tests. If not a separate node context used.
lazyObjectsRuntime: LAZY_OBJECTS_RUNTIME_NAME,
noLazySupport: false,
ir: false,
fast: false,
residual: false,
cpuprofilePath: "",
Expand Down Expand Up @@ -975,9 +953,6 @@ function argsParse(): ProgramArgs {
if (typeof parsedArgs.noLazySupport !== "boolean") {
throw new ArgsParseError("noLazySupport must be a boolean (either --noLazySupport or not)");
}
if (typeof parsedArgs.ir !== "boolean") {
throw new ArgsParseError("ir must be a boolean (either --ir or not)");
}
if (typeof parsedArgs.residual !== "boolean") {
throw new ArgsParseError("residual must be a boolean (either --residual or not)");
}
Expand All @@ -995,8 +970,7 @@ function argsParse(): ProgramArgs {
parsedArgs.noLazySupport,
parsedArgs.fast,
parsedArgs.residual,
parsedArgs.cpuprofilePath,
parsedArgs.ir
parsedArgs.cpuprofilePath
);
return programArgs;
}
Expand Down
151 changes: 0 additions & 151 deletions src/descriptors.js

This file was deleted.

33 changes: 11 additions & 22 deletions src/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import PrimitiveValue from "./values/PrimitiveValue.js";
import { createOperationDescriptor } from "./utils/generator.js";

import { SourceMapConsumer, type NullableMappedPosition } from "source-map";
import { PropertyDescriptor } from "./descriptors.js";

function deriveGetBinding(realm: Realm, binding: Binding) {
let types = TypesDomain.topVal;
Expand Down Expand Up @@ -449,17 +448,12 @@ export class ObjectEnvironmentRecord extends EnvironmentRecord {
// 4. Return ? DefinePropertyOrThrow(bindings, N, PropertyDescriptor{[[Value]]: undefined, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: configValue}).
return new BooleanValue(
realm,
Properties.DefinePropertyOrThrow(
realm,
bindings,
N,
new PropertyDescriptor({
value: realm.intrinsics.undefined,
writable: true,
enumerable: true,
configurable: configValue,
})
)
Properties.DefinePropertyOrThrow(realm, bindings, N, {
value: realm.intrinsics.undefined,
writable: true,
enumerable: true,
configurable: configValue,
})
);
}

Expand Down Expand Up @@ -904,8 +898,7 @@ export class GlobalEnvironmentRecord extends EnvironmentRecord {

// 5. If existingProp is undefined, return false.
if (!existingProp) return false;
Properties.ThrowIfMightHaveBeenDeleted(existingProp);
existingProp = existingProp.throwIfNotConcrete(globalObject.$Realm);
Properties.ThrowIfMightHaveBeenDeleted(existingProp.value);

// 6. If existingProp.[[Configurable]] is true, return false.
if (existingProp.configurable) return false;
Expand Down Expand Up @@ -955,8 +948,7 @@ export class GlobalEnvironmentRecord extends EnvironmentRecord {

// 5. If existingProp is undefined, return ? IsExtensible(globalObject).
if (!existingProp) return IsExtensible(realm, globalObject);
Properties.ThrowIfMightHaveBeenDeleted(existingProp);
existingProp = existingProp.throwIfNotConcrete(globalObject.$Realm);
Properties.ThrowIfMightHaveBeenDeleted(existingProp.value);

// 6. If existingProp.[[Configurable]] is true, return true.
if (existingProp.configurable) return true;
Expand Down Expand Up @@ -1023,20 +1015,17 @@ export class GlobalEnvironmentRecord extends EnvironmentRecord {

// 4. Let existingProp be ? globalObject.[[GetOwnProperty]](N).
let existingProp = globalObject.$GetOwnProperty(N);
if (existingProp) {
existingProp = existingProp.throwIfNotConcrete(globalObject.$Realm);
}

// 5. If existingProp is undefined or existingProp.[[Configurable]] is true, then
let desc;
if (!existingProp || existingProp.configurable) {
// a. Let desc be the PropertyDescriptor{[[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: D}.
desc = new PropertyDescriptor({ value: V, writable: true, enumerable: true, configurable: D });
desc = { value: V, writable: true, enumerable: true, configurable: D };
} else {
// 6. Else,
Properties.ThrowIfMightHaveBeenDeleted(existingProp);
Properties.ThrowIfMightHaveBeenDeleted(existingProp.value);
// a. Let desc be the PropertyDescriptor{[[Value]]: V }.
desc = new PropertyDescriptor({ value: V });
desc = { value: V };
}

// 7. Perform ? DefinePropertyOrThrow(globalObject, N, desc).
Expand Down
2 changes: 1 addition & 1 deletion src/evaluators/ForInStatement.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function emitResidualLoopIfSafe(
if (key.object.unknownProperty === key) {
targetObject = key.object;
invariant(desc !== undefined);
let sourceValue = desc.throwIfNotConcrete(realm).value;
let sourceValue = desc.value;
if (sourceValue instanceof AbstractValue) {
// because sourceValue was written to key.object.unknownProperty it must be that
let cond = sourceValue.args[0];
Expand Down
16 changes: 5 additions & 11 deletions src/evaluators/FunctionDeclaration.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { MakeConstructor } from "../methods/construct.js";
import { Create, Functions, Properties } from "../singletons.js";
import { StringValue } from "../values/index.js";
import IsStrict from "../utils/strict.js";
import { PropertyDescriptor } from "../descriptors.js";
import type { BabelNodeFunctionDeclaration } from "@babel/types";

// ECMA262 14.1.20
Expand Down Expand Up @@ -45,16 +44,11 @@ export default function(
let prototype = Create.ObjectCreate(realm, realm.intrinsics.GeneratorPrototype);

// 5. Perform DefinePropertyOrThrow(F, "prototype", PropertyDescriptor{[[Value]]: prototype, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false}).
Properties.DefinePropertyOrThrow(
realm,
F,
"prototype",
new PropertyDescriptor({
value: prototype,
writable: true,
configurable: false,
})
);
Properties.DefinePropertyOrThrow(realm, F, "prototype", {
value: prototype,
writable: true,
configurable: false,
});

// 6. Perform SetFunctionName(F, name).
Functions.SetFunctionName(realm, F, name);
Expand Down
Loading

0 comments on commit ec36389

Please sign in to comment.