forked from facebook/hermes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Allow the spread element in arguments using a simple naive implementation. We add a `HermesInternal.apply` function, spread the arguments into an array using the spread array mechanisms, and then use HermesInternal.apply to actually run the call. Note that because spread args can be used in constructors, we need to convey the use of `new` to `HermesInternal.apply` with one of the arguments. Reviewed By: tmikov Differential Revision: D17334064 fbshipit-source-id: f358475122bac76cc1a6533ac8ccd6d62851d312
- Loading branch information
1 parent
5a402ac
commit 51969f2
Showing
14 changed files
with
292 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) Facebook, Inc. and its affiliates. | ||
// | ||
// This source code is licensed under the MIT license found in the LICENSE | ||
// file in the root directory of this source tree. | ||
// | ||
// RUN: %hermesc -dump-bytecode %s | %FileCheck %s --match-full-lines | ||
|
||
function foo(fn, x) { | ||
fn(...x); | ||
new fn(...x); | ||
} | ||
|
||
// CHECK-LABEL: Function<foo>(3 params, 28 registers, 2 symbols): | ||
// CHECK-NEXT: Offset in debug table: src 0x7, vars 0x0 | ||
// CHECK-NEXT: CreateEnvironment r0 | ||
// CHECK-NEXT: LoadParam r1, 1 | ||
// CHECK-NEXT: LoadParam r2, 2 | ||
// CHECK-NEXT: LoadConstZero r3 | ||
// CHECK-NEXT: LoadConstUndefined r4 | ||
// CHECK-NEXT: StoreToEnvironment r0, 0, r1 | ||
// CHECK-NEXT: StoreToEnvironment r0, 1, r2 | ||
// CHECK-NEXT: LoadFromEnvironment r5, r0, 0 | ||
// CHECK-NEXT: Mov r6, r3 | ||
// CHECK-NEXT: LoadFromEnvironment r7, r0, 1 | ||
// CHECK-NEXT: NewArray r8, 0 | ||
// CHECK-NEXT: Mov r9, r6 | ||
// CHECK-NEXT: Mov r20, r8 | ||
// CHECK-NEXT: Mov r19, r7 | ||
// CHECK-NEXT: Mov r18, r9 | ||
// CHECK-NEXT: CallBuiltin r10, "HermesInternal.arraySpread", 4 | ||
// CHECK-NEXT: Mov r6, r10 | ||
// CHECK-NEXT: Mov r20, r5 | ||
// CHECK-NEXT: Mov r19, r8 | ||
// CHECK-NEXT: Mov r18, r4 | ||
// CHECK-NEXT: CallBuiltin r11, "HermesInternal.apply", 4 | ||
// CHECK-NEXT: LoadFromEnvironment r11, r0, 0 | ||
// CHECK-NEXT: Mov r12, r3 | ||
// CHECK-NEXT: LoadFromEnvironment r13, r0, 1 | ||
// CHECK-NEXT: NewArray r14, 0 | ||
// CHECK-NEXT: Mov r15, r12 | ||
// CHECK-NEXT: Mov r20, r14 | ||
// CHECK-NEXT: Mov r19, r13 | ||
// CHECK-NEXT: Mov r18, r15 | ||
// CHECK-NEXT: CallBuiltin r16, "HermesInternal.arraySpread", 4 | ||
// CHECK-NEXT: Mov r12, r16 | ||
// CHECK-NEXT: Mov r20, r11 | ||
// CHECK-NEXT: Mov r19, r14 | ||
// CHECK-NEXT: CallBuiltin r17, "HermesInternal.apply", 3 | ||
// CHECK-NEXT: Ret r4 |
Oops, something went wrong.