diff --git a/lib/IRGen/ESTreeIRGen-expr.cpp b/lib/IRGen/ESTreeIRGen-expr.cpp index cbb2c06a755..d136fd0346c 100644 --- a/lib/IRGen/ESTreeIRGen-expr.cpp +++ b/lib/IRGen/ESTreeIRGen-expr.cpp @@ -886,13 +886,9 @@ Value *ESTreeIRGen::genObjectExpr(ESTree::ObjectExpressionNode *Expr) { ESTree::PropertyNode *protoProperty = nullptr; uint32_t numComputed = 0; - bool hasSpread = false; - bool hasAccessor = false; - bool hasDuplicateProperty = false; for (auto &P : Expr->_properties) { if (llvh::isa(&P)) { - hasSpread = true; continue; } @@ -929,10 +925,8 @@ Value *ESTreeIRGen::genObjectExpr(ESTree::ObjectExpressionNode *Expr) { PropertyValue *propValue = &propMap[propName]; if (prop->_kind->str() == "get") { propValue->setGetter(cast(prop->_value)); - hasAccessor = true; } else if (prop->_kind->str() == "set") { propValue->setSetter(cast(prop->_value)); - hasAccessor = true; } else { assert(prop->_kind->str() == "init" && "invalid PropertyNode kind"); // We record the propValue if this is a regular property @@ -942,7 +936,6 @@ Value *ESTreeIRGen::genObjectExpr(ESTree::ObjectExpressionNode *Expr) { std::string key = (prop->_kind->str() + propName).str(); auto iterAndSuccess = firstLocMap.try_emplace(key, prop->getSourceRange()); if (!iterAndSuccess.second) { - hasDuplicateProperty = true; Builder.getModule()->getContext().getSourceErrorManager().warning( prop->getSourceRange(), Twine("the property \"") + propName + @@ -953,38 +946,6 @@ Value *ESTreeIRGen::genObjectExpr(ESTree::ObjectExpressionNode *Expr) { } } - // Heuristically determine if we emit AllocObjectLiteral. - // We do so if there is no computed key, no __proto__, no spread element - // node, no duplicate properties, no accessors, and object literal is not - // empty. - if (numComputed == 0 && !protoProperty && !hasSpread && - !hasDuplicateProperty && !hasAccessor && propMap.size()) { - AllocObjectLiteralInst::ObjectPropertyMap objPropMap; - // It is safe to assume that there is no computed keys, and - // no __proto__. - for (auto &P : Expr->_properties) { - auto *prop = cast(&P); - assert( - !prop->_computed && - "Cannot handle computed key in AllocObjectLiteral"); - - // We are reusing the storage, so make sure it is cleared at every - // iteration. - stringStorage.clear(); - - llvh::StringRef keyStr = propertyKeyAsString(stringStorage, prop->_key); - auto *Key = Builder.getLiteralString(keyStr); - assert( - propMap[keyStr].valueNode == prop->_value && - "Should only have one value for each property."); - auto value = - genExpression(prop->_value, Builder.createIdentifier(keyStr)); - objPropMap.push_back(std::pair(Key, value)); - } - - return Builder.createAllocObjectLiteralInst(objPropMap); - } - /// Attempt to determine whether we can directly use the value of the /// __proto__ property as a parent when creating the object for an object /// initializer, instead of setting it later with diff --git a/test/BCGen/HBC/callbuiltin.js b/test/BCGen/HBC/callbuiltin.js index b44bd63b688..9899ebec227 100644 --- a/test/BCGen/HBC/callbuiltin.js +++ b/test/BCGen/HBC/callbuiltin.js @@ -65,15 +65,15 @@ print(foo({a: 10, b: 20, lastKey:30, 5:6})) // CHKRA:function shadows#0#1()#2 : undefined // CHKRA-NEXT:S{shadows#0#1()#2} = [] // CHKRA-NEXT:%BB0: -// CHKRA-NEXT: %0 = HBCGetGlobalObjectInst -// CHKRA-NEXT: %1 = TryLoadGlobalPropertyInst %0 : object, "print" : string -// CHKRA-NEXT: %2 = AllocObjectInst 1 : number, empty -// CHKRA-NEXT: %3 = StoreNewOwnPropertyInst %1, %2 : object, "keys" : string, true : boolean -// CHKRA-NEXT: %4 = LoadPropertyInst %2 : object, "keys" : string +// CHKRA-NEXT: %0 = AllocObjectInst 1 : number, empty +// CHKRA-NEXT: %1 = HBCGetGlobalObjectInst +// CHKRA-NEXT: %2 = TryLoadGlobalPropertyInst %1 : object, "print" : string +// CHKRA-NEXT: %3 = StoreNewOwnPropertyInst %2, %0 : object, "keys" : string, true : boolean +// CHKRA-NEXT: %4 = LoadPropertyInst %0 : object, "keys" : string // CHKRA-NEXT: %5 = HBCLoadConstInst "evil" : string -// CHKRA-NEXT: %6 = ImplicitMovInst %2 : object +// CHKRA-NEXT: %6 = ImplicitMovInst %0 : object // CHKRA-NEXT: %7 = ImplicitMovInst %5 : string -// CHKRA-NEXT: %8 = HBCCallNInst %4, undefined : undefined, %2 : object, %5 : string +// CHKRA-NEXT: %8 = HBCCallNInst %4, undefined : undefined, %0 : object, %5 : string // CHKRA-NEXT: %9 = HBCLoadConstInst undefined : undefined // CHKRA-NEXT: %10 = ReturnInst %9 : undefined // CHKRA-NEXT:function_end @@ -162,9 +162,9 @@ print(foo({a: 10, b: 20, lastKey:30, 5:6})) // CHKBC:Function(1 params, 11 registers, 0 symbols): // CHKBC-NEXT:Offset in debug table: source 0x0034, scope 0x0000, textified callees 0x0000 +// CHKBC-NEXT: NewObject r2 // CHKBC-NEXT: GetGlobalObject r0 // CHKBC-NEXT: TryGetById r0, r0, 1, "print" -// CHKBC-NEXT: NewObject r2 // CHKBC-NEXT: PutNewOwnByIdShort r2, r0, "keys" // CHKBC-NEXT: GetByIdShort r1, r2, 2, "keys" // CHKBC-NEXT: LoadConstString r0, "evil" @@ -200,7 +200,7 @@ print(foo({a: 10, b: 20, lastKey:30, 5:6})) // CHKBC-NEXT: 0x0027 function idx 1, starts at line 12 col 1 // CHKBC-NEXT: bc 3: line 13 col 23 scope offset 0x0000 env none // CHKBC-NEXT: 0x0034 function idx 2, starts at line 17 col 1 -// CHKBC-NEXT: bc 2: line 18 col 25 scope offset 0x0000 env none +// CHKBC-NEXT: bc 4: line 18 col 25 scope offset 0x0000 env none // CHKBC-NEXT: bc 10: line 18 col 18 scope offset 0x0000 env none // CHKBC-NEXT: bc 14: line 19 col 16 scope offset 0x0000 env none // CHKBC-NEXT: bc 23: line 19 col 16 scope offset 0x0000 env none diff --git a/test/IRGen/__proto__-shorthand.js b/test/IRGen/__proto__-shorthand.js index 0d82f8516c2..b22a30ee1e6 100644 --- a/test/IRGen/__proto__-shorthand.js +++ b/test/IRGen/__proto__-shorthand.js @@ -64,11 +64,14 @@ function protoShorthandMix2(func) { // CHECK-NEXT: %1 = StoreFrameInst %func, [func#2], %0 // CHECK-NEXT: %2 = StoreFrameInst undefined : undefined, [__proto__#2], %0 // CHECK-NEXT: %3 = StoreFrameInst 42 : number, [__proto__#2], %0 -// CHECK-NEXT: %4 = LoadFrameInst [__proto__#2], %0 -// CHECK-NEXT: %5 = AllocObjectLiteralInst "__proto__" : string, %4, "a" : string, 2 : number, "b" : string, 3 : number -// CHECK-NEXT: %6 = ReturnInst %5 : object +// CHECK-NEXT: %4 = AllocObjectInst 3 : number, empty +// CHECK-NEXT: %5 = LoadFrameInst [__proto__#2], %0 +// CHECK-NEXT: %6 = StoreNewOwnPropertyInst %5, %4 : object, "__proto__" : string, true : boolean +// CHECK-NEXT: %7 = StoreNewOwnPropertyInst 2 : number, %4 : object, "a" : string, true : boolean +// CHECK-NEXT: %8 = StoreNewOwnPropertyInst 3 : number, %4 : object, "b" : string, true : boolean +// CHECK-NEXT: %9 = ReturnInst %4 : object // CHECK-NEXT:%BB1: -// CHECK-NEXT: %7 = ReturnInst undefined : undefined +// CHECK-NEXT: %10 = ReturnInst undefined : undefined // CHECK-NEXT:function_end // CHECK:function protoShorthandDup#0#1(func)#3 diff --git a/test/IRGen/array_object.js b/test/IRGen/array_object.js index 2a0a8eeb059..09c423512c8 100644 --- a/test/IRGen/array_object.js +++ b/test/IRGen/array_object.js @@ -40,16 +40,18 @@ function foo(param) { // CHECK-NEXT: %1 = StoreFrameInst %param, [param#2], %0 // CHECK-NEXT: %2 = StoreFrameInst undefined : undefined, [obj#2], %0 // CHECK-NEXT: %3 = StoreFrameInst undefined : undefined, [foo#2], %0 -// CHECK-NEXT: %4 = LoadFrameInst [param#2], %0 -// CHECK-NEXT: %5 = AllocObjectLiteralInst "1" : string, 2 : number, "key" : string, %4 -// CHECK-NEXT: %6 = StoreFrameInst %5 : object, [obj#2], %0 -// CHECK-NEXT: %7 = AllocArrayInst 4 : number, 1 : number, 2 : number, 3 : number, 4 : number -// CHECK-NEXT: %8 = StoreFrameInst %7 : object, [foo#2], %0 -// CHECK-NEXT: %9 = LoadFrameInst [obj#2], %0 -// CHECK-NEXT: %10 = LoadFrameInst [foo#2], %0 -// CHECK-NEXT: %11 = StorePropertyInst %10, %9, "field" : string +// CHECK-NEXT: %4 = AllocObjectInst 2 : number, empty +// CHECK-NEXT: %5 = StoreNewOwnPropertyInst 2 : number, %4 : object, "1" : string, true : boolean +// CHECK-NEXT: %6 = LoadFrameInst [param#2], %0 +// CHECK-NEXT: %7 = StoreNewOwnPropertyInst %6, %4 : object, "key" : string, true : boolean +// CHECK-NEXT: %8 = StoreFrameInst %4 : object, [obj#2], %0 +// CHECK-NEXT: %9 = AllocArrayInst 4 : number, 1 : number, 2 : number, 3 : number, 4 : number +// CHECK-NEXT: %10 = StoreFrameInst %9 : object, [foo#2], %0 +// CHECK-NEXT: %11 = LoadFrameInst [obj#2], %0 // CHECK-NEXT: %12 = LoadFrameInst [foo#2], %0 -// CHECK-NEXT: %13 = LoadFrameInst [obj#2], %0 -// CHECK-NEXT: %14 = StorePropertyInst %13, %12, 5 : number -// CHECK-NEXT: %15 = ReturnInst undefined : undefined +// CHECK-NEXT: %13 = StorePropertyInst %12, %11, "field" : string +// CHECK-NEXT: %14 = LoadFrameInst [foo#2], %0 +// CHECK-NEXT: %15 = LoadFrameInst [obj#2], %0 +// CHECK-NEXT: %16 = StorePropertyInst %15, %14, 5 : number +// CHECK-NEXT: %17 = ReturnInst undefined : undefined // CHECK-NEXT:function_end diff --git a/test/IRGen/es6/tagged-template.js b/test/IRGen/es6/tagged-template.js index ceadac8de5b..948d0c8f718 100644 --- a/test/IRGen/es6/tagged-template.js +++ b/test/IRGen/es6/tagged-template.js @@ -169,16 +169,17 @@ function helloWorld() { // CHECK-NEXT:%BB0: // CHECK-NEXT: %0 = CreateScopeInst %S{memberExpr#0#1()#8} // CHECK-NEXT: %1 = StoreFrameInst undefined : undefined, [obj#8], %0 -// CHECK-NEXT: %2 = LoadPropertyInst globalObject : object, "dummy" : string -// CHECK-NEXT: %3 = AllocObjectLiteralInst "func" : string, %2 -// CHECK-NEXT: %4 = StoreFrameInst %3 : object, [obj#8], %0 -// CHECK-NEXT: %5 = CallBuiltinInst [HermesBuiltin.getTemplateObject] : number, undefined : undefined, undefined : undefined, 5 : number, true : boolean, "hello world!" : string -// CHECK-NEXT: %6 = LoadFrameInst [obj#8], %0 -// CHECK-NEXT: %7 = LoadPropertyInst %6, "func" : string -// CHECK-NEXT: %8 = CallInst %7, undefined : undefined, %6, %5 -// CHECK-NEXT: %9 = ReturnInst %8 +// CHECK-NEXT: %2 = AllocObjectInst 1 : number, empty +// CHECK-NEXT: %3 = LoadPropertyInst globalObject : object, "dummy" : string +// CHECK-NEXT: %4 = StoreNewOwnPropertyInst %3, %2 : object, "func" : string, true : boolean +// CHECK-NEXT: %5 = StoreFrameInst %2 : object, [obj#8], %0 +// CHECK-NEXT: %6 = CallBuiltinInst [HermesBuiltin.getTemplateObject] : number, undefined : undefined, undefined : undefined, 5 : number, true : boolean, "hello world!" : string +// CHECK-NEXT: %7 = LoadFrameInst [obj#8], %0 +// CHECK-NEXT: %8 = LoadPropertyInst %7, "func" : string +// CHECK-NEXT: %9 = CallInst %8, undefined : undefined, %7, %6 +// CHECK-NEXT: %10 = ReturnInst %9 // CHECK-NEXT:%BB1: -// CHECK-NEXT: %10 = ReturnInst undefined : undefined +// CHECK-NEXT: %11 = ReturnInst undefined : undefined // CHECK-NEXT:function_end // CHECK:function callExpr#0#1()#9 diff --git a/test/IRGen/hbc_object_literals-lowering.js b/test/IRGen/hbc_object_literals-lowering.js index acdd9723d3a..8541f0d56cb 100644 --- a/test/IRGen/hbc_object_literals-lowering.js +++ b/test/IRGen/hbc_object_literals-lowering.js @@ -91,7 +91,7 @@ function accessorObjectLiteral(func) { // IRGEN-NEXT:%BB0: // IRGEN-NEXT: %0 = HBCAllocObjectFromBufferInst 4 : number, "a" : string, 10 : number, "c" : string, "hello" : string, "d" : string, null : null // IRGEN-NEXT: %1 = HBCAllocObjectFromBufferInst 2 : number, 1 : number, 100 : number, 2 : number, 200 : number -// IRGEN-NEXT: %2 = StoreOwnPropertyInst %1 : object, %0 : object, 42 : number, true : boolean +// IRGEN-NEXT: %2 = StoreNewOwnPropertyInst %1 : object, %0 : object, 42 : number, true : boolean // IRGEN-NEXT: %3 = ReturnInst %0 : object // IRGEN-NEXT:function_end diff --git a/test/IRGen/hbc_object_literals.js b/test/IRGen/hbc_object_literals.js index bda458a064d..d6676ec2d7a 100644 --- a/test/IRGen/hbc_object_literals.js +++ b/test/IRGen/hbc_object_literals.js @@ -73,41 +73,41 @@ var obj4 = { // IRGEN-NEXT:S{global#0()#1} = [] // IRGEN-NEXT:%BB0: // IRGEN-NEXT: %0 = HBCAllocObjectFromBufferInst 7 : number, "a" : string, "hello" : string, "b" : string, 1 : number, "c" : string, null : null, "d" : string, null : null, "e" : string, true : boolean, "f" : string, null : null, "g" : string, 2 : number -// IRGEN-NEXT: %1 = HBCLoadConstInst undefined : undefined -// IRGEN-NEXT: %2 = StorePropertyInst %1 : undefined, %0 : object, "d" : string -// IRGEN-NEXT: %3 = HBCCreateEnvironmentInst %S{global#0()#1} -// IRGEN-NEXT: %4 = HBCCreateFunctionInst %f#0#1()#2 : undefined, %3 -// IRGEN-NEXT: %5 = StorePropertyInst %4 : closure, %0 : object, "f" : string -// IRGEN-NEXT: %6 = HBCGetGlobalObjectInst -// IRGEN-NEXT: %7 = StorePropertyInst %0 : object, %6 : object, "obj1" : string -// IRGEN-NEXT: %8 = AllocObjectInst 18 : number, empty -// IRGEN-NEXT: %9 = StoreNewOwnPropertyInst %1 : undefined, %8 : object, "a" : string, true : boolean -// IRGEN-NEXT: %10 = StoreNewOwnPropertyInst %1 : undefined, %8 : object, "b" : string, true : boolean -// IRGEN-NEXT: %11 = StoreNewOwnPropertyInst %1 : undefined, %8 : object, "c" : string, true : boolean -// IRGEN-NEXT: %12 = StoreNewOwnPropertyInst %1 : undefined, %8 : object, "d" : string, true : boolean -// IRGEN-NEXT: %13 = StoreNewOwnPropertyInst %1 : undefined, %8 : object, "e" : string, true : boolean -// IRGEN-NEXT: %14 = StoreNewOwnPropertyInst %1 : undefined, %8 : object, "r" : string, true : boolean -// IRGEN-NEXT: %15 = HBCLoadConstInst 1 : number -// IRGEN-NEXT: %16 = StoreNewOwnPropertyInst %15 : number, %8 : object, "f" : string, true : boolean -// IRGEN-NEXT: %17 = StoreNewOwnPropertyInst %15 : number, %8 : object, "g" : string, true : boolean -// IRGEN-NEXT: %18 = StoreNewOwnPropertyInst %15 : number, %8 : object, "h" : string, true : boolean -// IRGEN-NEXT: %19 = StoreNewOwnPropertyInst %15 : number, %8 : object, "i" : string, true : boolean -// IRGEN-NEXT: %20 = StoreNewOwnPropertyInst %15 : number, %8 : object, "j" : string, true : boolean -// IRGEN-NEXT: %21 = StoreNewOwnPropertyInst %15 : number, %8 : object, "k" : string, true : boolean -// IRGEN-NEXT: %22 = StoreNewOwnPropertyInst %15 : number, %8 : object, "l" : string, true : boolean -// IRGEN-NEXT: %23 = StoreNewOwnPropertyInst %15 : number, %8 : object, "m" : string, true : boolean -// IRGEN-NEXT: %24 = StoreNewOwnPropertyInst %15 : number, %8 : object, "n" : string, true : boolean -// IRGEN-NEXT: %25 = StoreNewOwnPropertyInst %15 : number, %8 : object, "o" : string, true : boolean -// IRGEN-NEXT: %26 = StoreNewOwnPropertyInst %15 : number, %8 : object, "p" : string, true : boolean -// IRGEN-NEXT: %27 = StoreNewOwnPropertyInst %15 : number, %8 : object, "q" : string, true : boolean -// IRGEN-NEXT: %28 = StorePropertyInst %8 : object, %6 : object, "obj2" : string +// IRGEN-NEXT: %1 = HBCLoadConstInst 1 : number +// IRGEN-NEXT: %2 = HBCLoadConstInst undefined : undefined +// IRGEN-NEXT: %3 = StorePropertyInst %2 : undefined, %0 : object, "d" : string +// IRGEN-NEXT: %4 = HBCCreateEnvironmentInst %S{global#0()#1} +// IRGEN-NEXT: %5 = HBCCreateFunctionInst %f#0#1()#2 : undefined, %4 +// IRGEN-NEXT: %6 = StorePropertyInst %5 : closure, %0 : object, "f" : string +// IRGEN-NEXT: %7 = HBCGetGlobalObjectInst +// IRGEN-NEXT: %8 = StorePropertyInst %0 : object, %7 : object, "obj1" : string +// IRGEN-NEXT: %9 = AllocObjectInst 18 : number, empty +// IRGEN-NEXT: %10 = StoreNewOwnPropertyInst %2 : undefined, %9 : object, "a" : string, true : boolean +// IRGEN-NEXT: %11 = StoreNewOwnPropertyInst %2 : undefined, %9 : object, "b" : string, true : boolean +// IRGEN-NEXT: %12 = StoreNewOwnPropertyInst %2 : undefined, %9 : object, "c" : string, true : boolean +// IRGEN-NEXT: %13 = StoreNewOwnPropertyInst %2 : undefined, %9 : object, "d" : string, true : boolean +// IRGEN-NEXT: %14 = StoreNewOwnPropertyInst %2 : undefined, %9 : object, "e" : string, true : boolean +// IRGEN-NEXT: %15 = StoreNewOwnPropertyInst %2 : undefined, %9 : object, "r" : string, true : boolean +// IRGEN-NEXT: %16 = StoreNewOwnPropertyInst %1 : number, %9 : object, "f" : string, true : boolean +// IRGEN-NEXT: %17 = StoreNewOwnPropertyInst %1 : number, %9 : object, "g" : string, true : boolean +// IRGEN-NEXT: %18 = StoreNewOwnPropertyInst %1 : number, %9 : object, "h" : string, true : boolean +// IRGEN-NEXT: %19 = StoreNewOwnPropertyInst %1 : number, %9 : object, "i" : string, true : boolean +// IRGEN-NEXT: %20 = StoreNewOwnPropertyInst %1 : number, %9 : object, "j" : string, true : boolean +// IRGEN-NEXT: %21 = StoreNewOwnPropertyInst %1 : number, %9 : object, "k" : string, true : boolean +// IRGEN-NEXT: %22 = StoreNewOwnPropertyInst %1 : number, %9 : object, "l" : string, true : boolean +// IRGEN-NEXT: %23 = StoreNewOwnPropertyInst %1 : number, %9 : object, "m" : string, true : boolean +// IRGEN-NEXT: %24 = StoreNewOwnPropertyInst %1 : number, %9 : object, "n" : string, true : boolean +// IRGEN-NEXT: %25 = StoreNewOwnPropertyInst %1 : number, %9 : object, "o" : string, true : boolean +// IRGEN-NEXT: %26 = StoreNewOwnPropertyInst %1 : number, %9 : object, "p" : string, true : boolean +// IRGEN-NEXT: %27 = StoreNewOwnPropertyInst %1 : number, %9 : object, "q" : string, true : boolean +// IRGEN-NEXT: %28 = StorePropertyInst %9 : object, %7 : object, "obj2" : string // IRGEN-NEXT: %29 = HBCAllocObjectFromBufferInst 13 : number, "f" : string, 1 : number, "g" : string, 1 : number, "h" : string, 1 : number, "i" : string, 1 : number, "j" : string, 1 : number, "k" : string, 1 : number, "l" : string, 1 : number, "m" : string, 1 : number, "n" : string, 1 : number, "o" : string, 1 : number, "p" : string, 1 : number, "q" : string, 1 : number -// IRGEN-NEXT: %30 = StoreOwnPropertyInst %1 : undefined, %29 : object, 1 : number, true : boolean -// IRGEN-NEXT: %31 = StorePropertyInst %29 : object, %6 : object, "obj3" : string +// IRGEN-NEXT: %30 = StoreNewOwnPropertyInst %2 : undefined, %29 : object, 1 : number, true : boolean +// IRGEN-NEXT: %31 = StorePropertyInst %29 : object, %7 : object, "obj3" : string // IRGEN-NEXT: %32 = HBCAllocObjectFromBufferInst 13 : number, "f" : string, 1 : number, "g" : string, 1 : number, "h" : string, 1 : number, "i" : string, 1 : number, "j" : string, 1 : number, "k" : string, 1 : number, "l" : string, 1 : number, "m" : string, 1 : number, "n" : string, 1 : number, "o" : string, 1 : number, "p" : string, 1 : number, "q" : string, 1 : number -// IRGEN-NEXT: %33 = StoreOwnPropertyInst %1 : undefined, %32 : object, 1 : number, true : boolean -// IRGEN-NEXT: %34 = StorePropertyInst %32 : object, %6 : object, "obj4" : string -// IRGEN-NEXT: %35 = ReturnInst %1 : undefined +// IRGEN-NEXT: %33 = StoreNewOwnPropertyInst %2 : undefined, %32 : object, 1 : number, true : boolean +// IRGEN-NEXT: %34 = StorePropertyInst %32 : object, %7 : object, "obj4" : string +// IRGEN-NEXT: %35 = ReturnInst %2 : undefined // IRGEN-NEXT:function_end // IRGEN:function f#0#1()#2 : undefined @@ -206,6 +206,7 @@ var obj4 = { // BCGEN-NEXT: DeclareGlobalVar "obj3" // BCGEN-NEXT: DeclareGlobalVar "obj4" // BCGEN-NEXT: NewObjectWithBuffer r1, 7, 7, 0, 0 +// BCGEN-NEXT: LoadConstUInt8 r3, 1 // BCGEN-NEXT: LoadConstUndefined r0 // BCGEN-NEXT: PutById r1, r0, 1, "d" // BCGEN-NEXT: CreateEnvironment r2 @@ -220,7 +221,6 @@ var obj4 = { // BCGEN-NEXT: PutNewOwnByIdShort r1, r0, "d" // BCGEN-NEXT: PutNewOwnByIdShort r1, r0, "e" // BCGEN-NEXT: PutNewOwnByIdShort r1, r0, "r" -// BCGEN-NEXT: LoadConstUInt8 r3, 1 // BCGEN-NEXT: PutNewOwnByIdShort r1, r3, "f" // BCGEN-NEXT: PutNewOwnByIdShort r1, r3, "g" // BCGEN-NEXT: PutNewOwnByIdShort r1, r3, "h" @@ -254,15 +254,15 @@ var obj4 = { // BCGEN:Debug source table: // BCGEN-NEXT: 0x0000 function idx 0, starts at line 11 col 1 -// BCGEN-NEXT: bc 32: line 11 col 12 scope offset 0x0000 env r2 -// BCGEN-NEXT: bc 45: line 11 col 12 scope offset 0x0000 env r2 -// BCGEN-NEXT: bc 53: line 11 col 10 scope offset 0x0000 env r1 -// BCGEN-NEXT: bc 61: line 15 col 12 scope offset 0x0000 env r3 -// BCGEN-NEXT: bc 65: line 15 col 12 scope offset 0x0000 env r3 -// BCGEN-NEXT: bc 69: line 15 col 12 scope offset 0x0000 env r3 -// BCGEN-NEXT: bc 73: line 15 col 12 scope offset 0x0000 env r3 -// BCGEN-NEXT: bc 77: line 15 col 12 scope offset 0x0000 env r3 -// BCGEN-NEXT: bc 81: line 15 col 12 scope offset 0x0000 env r3 +// BCGEN-NEXT: bc 35: line 11 col 12 scope offset 0x0000 env r2 +// BCGEN-NEXT: bc 48: line 11 col 12 scope offset 0x0000 env r2 +// BCGEN-NEXT: bc 56: line 11 col 10 scope offset 0x0000 env r1 +// BCGEN-NEXT: bc 64: line 15 col 12 scope offset 0x0000 env r4 +// BCGEN-NEXT: bc 68: line 15 col 12 scope offset 0x0000 env r4 +// BCGEN-NEXT: bc 72: line 15 col 12 scope offset 0x0000 env r4 +// BCGEN-NEXT: bc 76: line 15 col 12 scope offset 0x0000 env r4 +// BCGEN-NEXT: bc 80: line 15 col 12 scope offset 0x0000 env r4 +// BCGEN-NEXT: bc 84: line 15 col 12 scope offset 0x0000 env r4 // BCGEN-NEXT: bc 88: line 15 col 12 scope offset 0x0000 env r4 // BCGEN-NEXT: bc 92: line 15 col 12 scope offset 0x0000 env r4 // BCGEN-NEXT: bc 96: line 15 col 12 scope offset 0x0000 env r4 diff --git a/test/IRGen/json.js b/test/IRGen/json.js index 32544570748..85a5c50852f 100644 --- a/test/IRGen/json.js +++ b/test/IRGen/json.js @@ -42,14 +42,29 @@ var json = { // CHECK-NEXT: %0 = CreateScopeInst %S{global#0()#1} // CHECK-NEXT: %1 = AllocStackInst $?anon_0_ret // CHECK-NEXT: %2 = StoreStackInst undefined : undefined, %1 -// CHECK-NEXT: %3 = AllocArrayInst 2 : number, "GML" : string, "XML" : string -// CHECK-NEXT: %4 = AllocObjectLiteralInst "para" : string, "A meta-markup language, used to create markup languages such as DocBook." : string, "GlossSeeAlso" : string, %3 : object -// CHECK-NEXT: %5 = AllocObjectLiteralInst "ID" : string, "SGML" : string, "SortAs" : string, "SGML" : string, "GlossTerm" : string, "Standard Generalized Markup Language" : string, "Acronym" : string, "SGML" : string, "Abbrev" : string, "ISO 8879:1986" : string, "GlossDef" : string, %4 : object, "GlossSee" : string, "markup" : string -// CHECK-NEXT: %6 = AllocObjectLiteralInst "GlossEntry" : string, %5 : object -// CHECK-NEXT: %7 = AllocObjectLiteralInst "title" : string, "S" : string, "GlossList" : string, %6 : object -// CHECK-NEXT: %8 = AllocObjectLiteralInst "title" : string, "example glossary" : string, "GlossDiv" : string, %7 : object -// CHECK-NEXT: %9 = AllocObjectLiteralInst "glossary" : string, %8 : object -// CHECK-NEXT: %10 = StorePropertyInst %9 : object, globalObject : object, "json" : string -// CHECK-NEXT: %11 = LoadStackInst %1 -// CHECK-NEXT: %12 = ReturnInst %11 +// CHECK-NEXT: %3 = AllocObjectInst 1 : number, empty +// CHECK-NEXT: %4 = AllocObjectInst 2 : number, empty +// CHECK-NEXT: %5 = StoreNewOwnPropertyInst "example glossary" : string, %4 : object, "title" : string, true : boolean +// CHECK-NEXT: %6 = AllocObjectInst 2 : number, empty +// CHECK-NEXT: %7 = StoreNewOwnPropertyInst "S" : string, %6 : object, "title" : string, true : boolean +// CHECK-NEXT: %8 = AllocObjectInst 1 : number, empty +// CHECK-NEXT: %9 = AllocObjectInst 7 : number, empty +// CHECK-NEXT: %10 = StoreNewOwnPropertyInst "SGML" : string, %9 : object, "ID" : string, true : boolean +// CHECK-NEXT: %11 = StoreNewOwnPropertyInst "SGML" : string, %9 : object, "SortAs" : string, true : boolean +// CHECK-NEXT: %12 = StoreNewOwnPropertyInst "Standard Generalized Markup Language" : string, %9 : object, "GlossTerm" : string, true : boolean +// CHECK-NEXT: %13 = StoreNewOwnPropertyInst "SGML" : string, %9 : object, "Acronym" : string, true : boolean +// CHECK-NEXT: %14 = StoreNewOwnPropertyInst "ISO 8879:1986" : string, %9 : object, "Abbrev" : string, true : boolean +// CHECK-NEXT: %15 = AllocObjectInst 2 : number, empty +// CHECK-NEXT: %16 = StoreNewOwnPropertyInst "A meta-markup language, used to create markup languages such as DocBook." : string, %15 : object, "para" : string, true : boolean +// CHECK-NEXT: %17 = AllocArrayInst 2 : number, "GML" : string, "XML" : string +// CHECK-NEXT: %18 = StoreNewOwnPropertyInst %17 : object, %15 : object, "GlossSeeAlso" : string, true : boolean +// CHECK-NEXT: %19 = StoreNewOwnPropertyInst %15 : object, %9 : object, "GlossDef" : string, true : boolean +// CHECK-NEXT: %20 = StoreNewOwnPropertyInst "markup" : string, %9 : object, "GlossSee" : string, true : boolean +// CHECK-NEXT: %21 = StoreNewOwnPropertyInst %9 : object, %8 : object, "GlossEntry" : string, true : boolean +// CHECK-NEXT: %22 = StoreNewOwnPropertyInst %8 : object, %6 : object, "GlossList" : string, true : boolean +// CHECK-NEXT: %23 = StoreNewOwnPropertyInst %6 : object, %4 : object, "GlossDiv" : string, true : boolean +// CHECK-NEXT: %24 = StoreNewOwnPropertyInst %4 : object, %3 : object, "glossary" : string, true : boolean +// CHECK-NEXT: %25 = StorePropertyInst %3 : object, globalObject : object, "json" : string +// CHECK-NEXT: %26 = LoadStackInst %1 +// CHECK-NEXT: %27 = ReturnInst %26 // CHECK-NEXT:function_end diff --git a/test/IRGen/object_literals.js b/test/IRGen/object_literals.js index 12afafc341d..0667c0c0ec9 100644 --- a/test/IRGen/object_literals.js +++ b/test/IRGen/object_literals.js @@ -103,9 +103,11 @@ function accessorObjectLiteral2(func) { // CHECK-NEXT:%BB0: // CHECK-NEXT: %0 = CreateScopeInst %S{simpleObjectLiteral#0#1()#2} // CHECK-NEXT: %1 = StoreFrameInst %func, [func#2], %0 -// CHECK-NEXT: %2 = AllocObjectLiteralInst "prop1" : string, 10 : number -// CHECK-NEXT: %3 = AllocObjectLiteralInst "prop1" : string, 10 : number -// CHECK-NEXT: %4 = ReturnInst undefined : undefined +// CHECK-NEXT: %2 = AllocObjectInst 1 : number, empty +// CHECK-NEXT: %3 = StoreNewOwnPropertyInst 10 : number, %2 : object, "prop1" : string, true : boolean +// CHECK-NEXT: %4 = AllocObjectInst 1 : number, empty +// CHECK-NEXT: %5 = StoreNewOwnPropertyInst 10 : number, %4 : object, "prop1" : string, true : boolean +// CHECK-NEXT: %6 = ReturnInst undefined : undefined // CHECK-NEXT:function_end // CHECK:function emitAllocObjectLiteral#0#1(func)#3 @@ -113,10 +115,16 @@ function accessorObjectLiteral2(func) { // CHECK-NEXT:%BB0: // CHECK-NEXT: %0 = CreateScopeInst %S{emitAllocObjectLiteral#0#1()#3} // CHECK-NEXT: %1 = StoreFrameInst %func, [func#3], %0 -// CHECK-NEXT: %2 = AllocObjectLiteralInst "a" : string, 1 : number, "b" : string, 2 : number, "c" : string, 3 : number, "d" : string, 4 : number, "5" : string, 5 : number, "6" : string, 6 : number -// CHECK-NEXT: %3 = ReturnInst %2 : object +// CHECK-NEXT: %2 = AllocObjectInst 6 : number, empty +// CHECK-NEXT: %3 = StoreNewOwnPropertyInst 1 : number, %2 : object, "a" : string, true : boolean +// CHECK-NEXT: %4 = StoreNewOwnPropertyInst 2 : number, %2 : object, "b" : string, true : boolean +// CHECK-NEXT: %5 = StoreNewOwnPropertyInst 3 : number, %2 : object, "c" : string, true : boolean +// CHECK-NEXT: %6 = StoreNewOwnPropertyInst 4 : number, %2 : object, "d" : string, true : boolean +// CHECK-NEXT: %7 = StoreNewOwnPropertyInst 5 : number, %2 : object, "5" : string, true : boolean +// CHECK-NEXT: %8 = StoreNewOwnPropertyInst 6 : number, %2 : object, "6" : string, true : boolean +// CHECK-NEXT: %9 = ReturnInst %2 : object // CHECK-NEXT:%BB1: -// CHECK-NEXT: %4 = ReturnInst undefined : undefined +// CHECK-NEXT: %10 = ReturnInst undefined : undefined // CHECK-NEXT:function_end // CHECK:function nestedAllocObjectLiteral#0#1(func)#4 @@ -124,11 +132,17 @@ function accessorObjectLiteral2(func) { // CHECK-NEXT:%BB0: // CHECK-NEXT: %0 = CreateScopeInst %S{nestedAllocObjectLiteral#0#1()#4} // CHECK-NEXT: %1 = StoreFrameInst %func, [func#4], %0 -// CHECK-NEXT: %2 = AllocObjectLiteralInst "1" : string, 100 : number, "2" : string, 200 : number -// CHECK-NEXT: %3 = AllocObjectLiteralInst "a" : string, 10 : number, "b" : string, %2 : object, "c" : string, "hello" : string, "d" : string, null : null -// CHECK-NEXT: %4 = ReturnInst %3 : object +// CHECK-NEXT: %2 = AllocObjectInst 4 : number, empty +// CHECK-NEXT: %3 = StoreNewOwnPropertyInst 10 : number, %2 : object, "a" : string, true : boolean +// CHECK-NEXT: %4 = AllocObjectInst 2 : number, empty +// CHECK-NEXT: %5 = StoreNewOwnPropertyInst 100 : number, %4 : object, "1" : string, true : boolean +// CHECK-NEXT: %6 = StoreNewOwnPropertyInst 200 : number, %4 : object, "2" : string, true : boolean +// CHECK-NEXT: %7 = StoreNewOwnPropertyInst %4 : object, %2 : object, "b" : string, true : boolean +// CHECK-NEXT: %8 = StoreNewOwnPropertyInst "hello" : string, %2 : object, "c" : string, true : boolean +// CHECK-NEXT: %9 = StoreNewOwnPropertyInst null : null, %2 : object, "d" : string, true : boolean +// CHECK-NEXT: %10 = ReturnInst %2 : object // CHECK-NEXT:%BB1: -// CHECK-NEXT: %5 = ReturnInst undefined : undefined +// CHECK-NEXT: %11 = ReturnInst undefined : undefined // CHECK-NEXT:function_end // CHECK:function duplicatedObjectLiteral#0#1(func)#5 @@ -210,15 +224,17 @@ function accessorObjectLiteral2(func) { // CHECK-NEXT: %0 = CreateScopeInst %S{spreadObjectLiteral#0#1()#10} // CHECK-NEXT: %1 = StoreFrameInst %func, [func#10], %0 // CHECK-NEXT: %2 = StoreFrameInst undefined : undefined, [obj#10], %0 -// CHECK-NEXT: %3 = AllocObjectLiteralInst "a" : string, 10 : number, "b" : string, 20 : number -// CHECK-NEXT: %4 = StoreFrameInst %3 : object, [obj#10], %0 -// CHECK-NEXT: %5 = AllocObjectInst 1 : number, empty -// CHECK-NEXT: %6 = LoadFrameInst [obj#10], %0 -// CHECK-NEXT: %7 = CallBuiltinInst [HermesBuiltin.copyDataProperties] : number, undefined : undefined, undefined : undefined, %5 : object, %6 -// CHECK-NEXT: %8 = StoreOwnPropertyInst 42 : number, %5 : object, "c" : string, true : boolean -// CHECK-NEXT: %9 = ReturnInst %5 : object +// CHECK-NEXT: %3 = AllocObjectInst 2 : number, empty +// CHECK-NEXT: %4 = StoreNewOwnPropertyInst 10 : number, %3 : object, "a" : string, true : boolean +// CHECK-NEXT: %5 = StoreNewOwnPropertyInst 20 : number, %3 : object, "b" : string, true : boolean +// CHECK-NEXT: %6 = StoreFrameInst %3 : object, [obj#10], %0 +// CHECK-NEXT: %7 = AllocObjectInst 1 : number, empty +// CHECK-NEXT: %8 = LoadFrameInst [obj#10], %0 +// CHECK-NEXT: %9 = CallBuiltinInst [HermesBuiltin.copyDataProperties] : number, undefined : undefined, undefined : undefined, %7 : object, %8 +// CHECK-NEXT: %10 = StoreOwnPropertyInst 42 : number, %7 : object, "c" : string, true : boolean +// CHECK-NEXT: %11 = ReturnInst %7 : object // CHECK-NEXT:%BB1: -// CHECK-NEXT: %10 = ReturnInst undefined : undefined +// CHECK-NEXT: %12 = ReturnInst undefined : undefined // CHECK-NEXT:function_end // CHECK:function accessorObjectLiteral1#0#1(func)#11 diff --git a/test/Optimizer/type_infer_fun_returns.js b/test/Optimizer/type_infer_fun_returns.js index adf9ec75956..358dabd22f6 100644 --- a/test/Optimizer/type_infer_fun_returns.js +++ b/test/Optimizer/type_infer_fun_returns.js @@ -42,11 +42,12 @@ function g14(z) { // CHECK-NEXT: %8 = CallInst %7 : closure, undefined : undefined, undefined : undefined // CHECK-NEXT: %9 = BinaryOperatorInst '+', %8 : boolean|number, 1 : number // CHECK-NEXT: %10 = CallInst %6, undefined : undefined, undefined : undefined, %9 : number -// CHECK-NEXT: %11 = CreateFunctionInst %m#1#2()#4 : undefined, %0 -// CHECK-NEXT: %12 = AllocObjectLiteralInst "m" : string, %11 : closure -// CHECK-NEXT: %13 = ReturnInst %12 : object +// CHECK-NEXT: %11 = AllocObjectInst 1 : number, empty +// CHECK-NEXT: %12 = CreateFunctionInst %m#1#2()#4 : undefined, %0 +// CHECK-NEXT: %13 = StoreNewOwnPropertyInst %12 : closure, %11 : object, "m" : string, true : boolean +// CHECK-NEXT: %14 = ReturnInst %11 : object // CHECK-NEXT:%BB2: -// CHECK-NEXT: %14 = ReturnInst undefined : undefined +// CHECK-NEXT: %15 = ReturnInst undefined : undefined // CHECK-NEXT:function_end // CHECK:function w#1#2()#3 : number diff --git a/test/hermes/not-a-function.js.ir.txt b/test/hermes/not-a-function.js.ir.txt index 10a331dc8dd..d789b413cd7 100644 --- a/test/hermes/not-a-function.js.ir.txt +++ b/test/hermes/not-a-function.js.ir.txt @@ -16,52 +16,53 @@ // CHKIR-NEXT: %2 = StorePropertyInst %1 : closure, globalObject : object, "test" : string // CHKIR-NEXT: %3 = TryLoadGlobalPropertyInst globalObject : object, "print" : string // CHKIR-NEXT: %4 = CallInst %3, undefined : undefined, undefined : undefined, "errors" : string // textified callee: "print" -// CHKIR-NEXT: %5 = CreateFunctionInst %b#0#1()#3 : object, %0 -// CHKIR-NEXT: %6 = AllocObjectLiteralInst "b" : string, %5 : closure -// CHKIR-NEXT: %7 = StorePropertyInst %6 : object, globalObject : object, "a" : string -// CHKIR-NEXT: %8 = LoadPropertyInst globalObject : object, "test" : string -// CHKIR-NEXT: %9 = CreateFunctionInst %" 1#"#0#1()#5, %0 -// CHKIR-NEXT: %10 = CallInst %8, undefined : undefined, undefined : undefined, %9 : closure // textified callee: "test" -// CHKIR-NEXT: %11 = LoadPropertyInst globalObject : object, "test" : string -// CHKIR-NEXT: %12 = CreateFunctionInst %" 2#"#0#1()#6, %0 -// CHKIR-NEXT: %13 = CallInst %11, undefined : undefined, undefined : undefined, %12 : closure // textified callee: "test" -// CHKIR-NEXT: %14 = LoadPropertyInst globalObject : object, "test" : string -// CHKIR-NEXT: %15 = CreateFunctionInst %" 3#"#0#1()#7, %0 -// CHKIR-NEXT: %16 = CallInst %14, undefined : undefined, undefined : undefined, %15 : closure // textified callee: "test" -// CHKIR-NEXT: %17 = LoadPropertyInst globalObject : object, "test" : string -// CHKIR-NEXT: %18 = CreateFunctionInst %" 4#"#0#1()#8, %0 -// CHKIR-NEXT: %19 = CallInst %17, undefined : undefined, undefined : undefined, %18 : closure // textified callee: "test" -// CHKIR-NEXT: %20 = LoadPropertyInst globalObject : object, "test" : string -// CHKIR-NEXT: %21 = CreateFunctionInst %" 5#"#0#1()#9, %0 -// CHKIR-NEXT: %22 = CallInst %20, undefined : undefined, undefined : undefined, %21 : closure // textified callee: "test" -// CHKIR-NEXT: %23 = LoadPropertyInst globalObject : object, "test" : string -// CHKIR-NEXT: %24 = CreateFunctionInst %" 6#"#0#1()#10, %0 -// CHKIR-NEXT: %25 = CallInst %23, undefined : undefined, undefined : undefined, %24 : closure // textified callee: "test" -// CHKIR-NEXT: %26 = LoadPropertyInst globalObject : object, "test" : string -// CHKIR-NEXT: %27 = CreateFunctionInst %" 7#"#0#1()#11, %0 -// CHKIR-NEXT: %28 = CallInst %26, undefined : undefined, undefined : undefined, %27 : closure // textified callee: "test" -// CHKIR-NEXT: %29 = LoadPropertyInst globalObject : object, "test" : string -// CHKIR-NEXT: %30 = CreateFunctionInst %" 8#"#0#1()#12, %0 -// CHKIR-NEXT: %31 = CallInst %29, undefined : undefined, undefined : undefined, %30 : closure // textified callee: "test" -// CHKIR-NEXT: %32 = LoadPropertyInst globalObject : object, "test" : string -// CHKIR-NEXT: %33 = CreateFunctionInst %" 9#"#0#1()#13, %0 -// CHKIR-NEXT: %34 = CallInst %32, undefined : undefined, undefined : undefined, %33 : closure // textified callee: "test" -// CHKIR-NEXT: %35 = LoadPropertyInst globalObject : object, "test" : string -// CHKIR-NEXT: %36 = CreateFunctionInst %" 10#"#0#1()#14, %0 -// CHKIR-NEXT: %37 = CallInst %35, undefined : undefined, undefined : undefined, %36 : closure // textified callee: "test" -// CHKIR-NEXT: %38 = LoadPropertyInst globalObject : object, "test" : string -// CHKIR-NEXT: %39 = CreateFunctionInst %" 11#"#0#1()#15, %0 -// CHKIR-NEXT: %40 = CallInst %38, undefined : undefined, undefined : undefined, %39 : closure // textified callee: "test" -// CHKIR-NEXT: %41 = LoadPropertyInst globalObject : object, "test" : string -// CHKIR-NEXT: %42 = CreateFunctionInst %" 12#"#0#1()#16, %0 -// CHKIR-NEXT: %43 = CallInst %41, undefined : undefined, undefined : undefined, %42 : closure // textified callee: "test" -// CHKIR-NEXT: %44 = LoadPropertyInst globalObject : object, "test" : string -// CHKIR-NEXT: %45 = CreateFunctionInst %" 13#"#0#1()#17, %0 -// CHKIR-NEXT: %46 = CallInst %44, undefined : undefined, undefined : undefined, %45 : closure // textified callee: "test" -// CHKIR-NEXT: %47 = LoadPropertyInst globalObject : object, "test" : string -// CHKIR-NEXT: %48 = CreateFunctionInst %" 14#"#0#1()#18, %0 -// CHKIR-NEXT: %49 = CallInst %47, undefined : undefined, undefined : undefined, %48 : closure // textified callee: "test" -// CHKIR-NEXT: %50 = ReturnInst %49 +// CHKIR-NEXT: %5 = AllocObjectInst 1 : number, empty +// CHKIR-NEXT: %6 = CreateFunctionInst %b#0#1()#3 : object, %0 +// CHKIR-NEXT: %7 = StoreNewOwnPropertyInst %6 : closure, %5 : object, "b" : string, true : boolean +// CHKIR-NEXT: %8 = StorePropertyInst %5 : object, globalObject : object, "a" : string +// CHKIR-NEXT: %9 = LoadPropertyInst globalObject : object, "test" : string +// CHKIR-NEXT: %10 = CreateFunctionInst %" 1#"#0#1()#5, %0 +// CHKIR-NEXT: %11 = CallInst %9, undefined : undefined, undefined : undefined, %10 : closure // textified callee: "test" +// CHKIR-NEXT: %12 = LoadPropertyInst globalObject : object, "test" : string +// CHKIR-NEXT: %13 = CreateFunctionInst %" 2#"#0#1()#6, %0 +// CHKIR-NEXT: %14 = CallInst %12, undefined : undefined, undefined : undefined, %13 : closure // textified callee: "test" +// CHKIR-NEXT: %15 = LoadPropertyInst globalObject : object, "test" : string +// CHKIR-NEXT: %16 = CreateFunctionInst %" 3#"#0#1()#7, %0 +// CHKIR-NEXT: %17 = CallInst %15, undefined : undefined, undefined : undefined, %16 : closure // textified callee: "test" +// CHKIR-NEXT: %18 = LoadPropertyInst globalObject : object, "test" : string +// CHKIR-NEXT: %19 = CreateFunctionInst %" 4#"#0#1()#8, %0 +// CHKIR-NEXT: %20 = CallInst %18, undefined : undefined, undefined : undefined, %19 : closure // textified callee: "test" +// CHKIR-NEXT: %21 = LoadPropertyInst globalObject : object, "test" : string +// CHKIR-NEXT: %22 = CreateFunctionInst %" 5#"#0#1()#9, %0 +// CHKIR-NEXT: %23 = CallInst %21, undefined : undefined, undefined : undefined, %22 : closure // textified callee: "test" +// CHKIR-NEXT: %24 = LoadPropertyInst globalObject : object, "test" : string +// CHKIR-NEXT: %25 = CreateFunctionInst %" 6#"#0#1()#10, %0 +// CHKIR-NEXT: %26 = CallInst %24, undefined : undefined, undefined : undefined, %25 : closure // textified callee: "test" +// CHKIR-NEXT: %27 = LoadPropertyInst globalObject : object, "test" : string +// CHKIR-NEXT: %28 = CreateFunctionInst %" 7#"#0#1()#11, %0 +// CHKIR-NEXT: %29 = CallInst %27, undefined : undefined, undefined : undefined, %28 : closure // textified callee: "test" +// CHKIR-NEXT: %30 = LoadPropertyInst globalObject : object, "test" : string +// CHKIR-NEXT: %31 = CreateFunctionInst %" 8#"#0#1()#12, %0 +// CHKIR-NEXT: %32 = CallInst %30, undefined : undefined, undefined : undefined, %31 : closure // textified callee: "test" +// CHKIR-NEXT: %33 = LoadPropertyInst globalObject : object, "test" : string +// CHKIR-NEXT: %34 = CreateFunctionInst %" 9#"#0#1()#13, %0 +// CHKIR-NEXT: %35 = CallInst %33, undefined : undefined, undefined : undefined, %34 : closure // textified callee: "test" +// CHKIR-NEXT: %36 = LoadPropertyInst globalObject : object, "test" : string +// CHKIR-NEXT: %37 = CreateFunctionInst %" 10#"#0#1()#14, %0 +// CHKIR-NEXT: %38 = CallInst %36, undefined : undefined, undefined : undefined, %37 : closure // textified callee: "test" +// CHKIR-NEXT: %39 = LoadPropertyInst globalObject : object, "test" : string +// CHKIR-NEXT: %40 = CreateFunctionInst %" 11#"#0#1()#15, %0 +// CHKIR-NEXT: %41 = CallInst %39, undefined : undefined, undefined : undefined, %40 : closure // textified callee: "test" +// CHKIR-NEXT: %42 = LoadPropertyInst globalObject : object, "test" : string +// CHKIR-NEXT: %43 = CreateFunctionInst %" 12#"#0#1()#16, %0 +// CHKIR-NEXT: %44 = CallInst %42, undefined : undefined, undefined : undefined, %43 : closure // textified callee: "test" +// CHKIR-NEXT: %45 = LoadPropertyInst globalObject : object, "test" : string +// CHKIR-NEXT: %46 = CreateFunctionInst %" 13#"#0#1()#17, %0 +// CHKIR-NEXT: %47 = CallInst %45, undefined : undefined, undefined : undefined, %46 : closure // textified callee: "test" +// CHKIR-NEXT: %48 = LoadPropertyInst globalObject : object, "test" : string +// CHKIR-NEXT: %49 = CreateFunctionInst %" 14#"#0#1()#18, %0 +// CHKIR-NEXT: %50 = CallInst %48, undefined : undefined, undefined : undefined, %49 : closure // textified callee: "test" +// CHKIR-NEXT: %51 = ReturnInst %50 // CHKIR-NEXT:function_end // CHKIR:function test#0#1(f)#2 : undefined diff --git a/unittests/BCGen/HBC.cpp b/unittests/BCGen/HBC.cpp index e43c1a97465..b9fb5145548 100644 --- a/unittests/BCGen/HBC.cpp +++ b/unittests/BCGen/HBC.cpp @@ -335,7 +335,9 @@ TEST(HBCBytecodeGen, ObjectBufferTest) { auto src = R"( var obj = {a:1, b:2, c:3}; )"; - auto BM = bytecodeModuleForSource(src); + auto opts = BytecodeGenerationOptions::defaults(); + opts.optimizationEnabled = true; + auto BM = bytecodeModuleForSource(src, opts); ASSERT_EQ(BM->getObjectKeyBufferSize(), 4u); ASSERT_EQ(BM->getObjectValueBufferSize(), 13u); } @@ -404,23 +406,6 @@ var s = arr1[0] + arr2[1]; ASSERT_LT(dedupBM->getArrayBufferSize(), dupBM->getArrayBufferSize()); } -TEST(HBCBytecodeGen, HardObjectDedupBufferTest) { - auto almostDupCode = R"( -var obj1 = {a:10,b:11,c:12,1:null,2:true,3:false}; -var obj2 = {a:10,b:11,c:12}; -var s = obj1.a + obj2.a; -)"; - auto dupBM = bytecodeModuleForSource(almostDupCode); - auto dedupOpts = BytecodeGenerationOptions::defaults(); - dedupOpts.optimizationEnabled = true; - auto dedupBM = bytecodeModuleForSource(almostDupCode, dedupOpts); - // The bytecode module which performed optimizations should have a smaller - // buffer size than the one that didn't. - ASSERT_LT(dedupBM->getObjectKeyBufferSize(), dupBM->getObjectKeyBufferSize()); - ASSERT_LT( - dedupBM->getObjectValueBufferSize(), dupBM->getObjectValueBufferSize()); -} - TEST(SpillRegisterTest, SpillsParameters) { auto Ctx = std::make_shared(); Module M(Ctx); diff --git a/unittests/VMRuntime/HeapSnapshotTest.cpp b/unittests/VMRuntime/HeapSnapshotTest.cpp index 8ec0a5ec84c..1e1c9bd2e15 100644 --- a/unittests/VMRuntime/HeapSnapshotTest.cpp +++ b/unittests/VMRuntime/HeapSnapshotTest.cpp @@ -1225,8 +1225,8 @@ foo(8) @ test.js(2):3:20)#"); (root)(0) @ (0):0:0 global(1) @ test.js(2):2:1 global(2) @ test.js(2):11:4 -baz(4) @ test.js(2):9:31 -bar(5) @ test.js(2):6:20)#"); +baz(3) @ test.js(2):9:31 +bar(4) @ test.js(2):6:20)#"); const JSONArray &samples = *llvh::cast(root->at("samples")); // Must have at least one sample