[modules] Fix bugs in assignments to exported variables.
- Add hole check if needed. - Preserve the accumulator so that the result is the rhs. R=adamk@chromium.org BUG=v8:1569,v8:5547 Review-Url: https://chromiumcodereview.appspot.com/2438653003 Cr-Commit-Position: refs/heads/master@{#40510}
This commit is contained in:
parent
44375382c1
commit
cadfe092a2
@ -2042,8 +2042,14 @@ void BytecodeGenerator::BuildVariableAssignment(Variable* variable,
|
||||
builder()
|
||||
->StoreAccumulatorInRegister(args[1])
|
||||
.LoadLiteral(it->second->export_name->string())
|
||||
.StoreAccumulatorInRegister(args[0])
|
||||
.CallRuntime(Runtime::kStoreModuleExport, args);
|
||||
.StoreAccumulatorInRegister(args[0]);
|
||||
if (needs_hole_check) {
|
||||
builder()->CallRuntime(Runtime::kLoadModuleExport, args[0]);
|
||||
BuildHoleCheckForVariableAssignment(variable, op);
|
||||
}
|
||||
builder()
|
||||
->CallRuntime(Runtime::kStoreModuleExport, args)
|
||||
.LoadAccumulatorWithRegister(args[1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,11 @@ assertThrows(() => x, ReferenceError);
|
||||
assertThrows(() => y, ReferenceError);
|
||||
assertThrows(() => z, ReferenceError);
|
||||
|
||||
assertEquals(23, w = 23);
|
||||
assertThrows(() => x = 666, ReferenceError);
|
||||
assertThrows(() => y = 666, ReferenceError);
|
||||
assertThrows(() => z = 666, TypeError);
|
||||
|
||||
export function* v() { return 40 }
|
||||
export var w = 41;
|
||||
export let x = 42;
|
||||
|
@ -10,6 +10,12 @@ assertThrows(() => x, ReferenceError);
|
||||
assertThrows(() => y, ReferenceError);
|
||||
assertThrows(() => z, ReferenceError);
|
||||
|
||||
assertThrows(() => v = 666, TypeError);
|
||||
assertThrows(() => w = 666, TypeError);
|
||||
assertThrows(() => x = 666, TypeError);
|
||||
assertThrows(() => y = 666, TypeError);
|
||||
assertThrows(() => z = 666, TypeError);
|
||||
|
||||
export function check() {
|
||||
assertEquals({value: 40, done: true}, v().next());
|
||||
assertEquals(41, w);
|
||||
|
Loading…
Reference in New Issue
Block a user