Commit Graph
105 Commits
Author SHA1 Message Date
kchadha 107adad647 Revert "Push reported" 2018-02-02 12:42:09 -05:00
Michael "Z" Goddard 10acf3c4f5 Add BlocksExecuteCache
Add a Blocks cache available only to execute. This cache lets execute
get a blocks inputs, fields, opcode, and mutation in one request and an
object execute can further modify to store derivative values it use
this and every later execute iteration to perform its duties quicker.
2018-01-24 17:00:42 -05:00
Michael "Z" Goddard 41d6a8f925 Check if a thread's target is null in sequencer
Before calling execute, if a thread's target is null, retire that
thread.

This saves repeatedly checking if the thread's target is null in
recursive calls where even if scratch-gui or blocks, or some other
related library set the target to null, that will not happen during
block execution. It will happen at some time outside of the sequencer
letting the sequencer check once instead of execute checking at every
recursive level.
2018-01-24 17:00:37 -05:00
Michael "Z" Goddard 4286e3e982 Add Thread.blockContainer
Store the thread's blocks at blockContainer letting execute quickly
determine the block source. Monitor threads are a monitor thread. They
do not become a target thread suddenly.
2018-01-24 17:00:35 -05:00
Michael "Z" Goddard ab8d8e5f34 Add optional recursiveCall argument to execute
When execute calls itself to step into the next stack level, pass
RECURSIVE to the recursiveCall level. This argument provides
opportunity to recursed calls in execute to reduce the time needed for
some checks.

- Reduce time for checking around setting
  thread.requestScriptGlowInFrame
- Call thread.pushReportedValue at end of execute when in a recursive
  call

A boolean check is faster than a type lookup, command blocks will only
be executed in non-recursive calls. This saves a minor amount of time
for any result reporting blocks like blocks that get variables or add
two inputs together.

If the block is not returning a promise and execute is a recursed call,
that implies that the block is neither a hat or that the thread is not
at the top. That reduces handleReport to pushReportedValue. Using the
recursiveCall argument the final block calling handleReport can
shortcut the extra work in handleReport and reduce it to immediately
calling pushReportedValue.
2018-01-24 17:00:24 -05:00
Michael "Z" Goddard 6b7582f1c7 Report block result to stackFrame.justReported
- Add stackFrame.justReported

Report the block result to a known key `justReported` instead of a
dynamic key on `reported`. Assuming blocks with a promised value are
relatively infrequent the most common recursive input flow immediately
reads the value "just" reported. In the assumed uncommon case of a
promised thread status, empty the already argValues assigned values
onto the currentStackFrame's reported member. In the next execute call
on this stackFrame, values assigned to reported are read back off onto
argValues, and execute will returned to the assumed common case. This
is a safe assumption since a thread in the promise state will not exit
that state until the next frame when javascript has a chance to call
the resolve handle, setting the thread's state back to another
executable state.

Using direct assignment to `justReported` saves building an object
dynamically. Instead of always building `reported` and `argValues` only
`argValues` is built until a promised state is reached. This also gives
a known time when `reported` is used, allowing cleanup of a
stackFrame's reported to only happen when it was used to persist
already reported values.
2018-01-24 17:00:12 -05:00
Karishma Chadha c0e4ae455c Streamlining broadcast block execution. When arg information is provided to execute function, corresponding broadcast message is looked up by id, if provided, or if not, then name. If neither id nor name is provided, we can't look up the broadcast message and something is wrong, so an error is logged. We no longer need to differentiate between the shadow menu vs. plugged in input cases via the argValue name (e.g. 'BROADCAST_OPTION' vs. 'BROADCAST_INPUT'). This refactor also helps with sb2 import, coming in the next commit. 2017-12-21 19:06:11 -05:00
Karishma Chadha 413d113dda Adding support for blocks to be plugged into the input of broadcast blocks. SB2 Import to come. 2017-12-21 19:06:11 -05:00
Paul Kaplan a9e95f3b01 Merge pull request #829 from kchadha/broadcast-message-typed-variable
Broadcast message functionality
2017-12-01 11:51:38 -05:00
Karishma Chadha b674a0c047 Code cleanup and refactoring, and getting scratch3_event broadcast functionality to look up the variable name instead of getting it ad-hoc. 2017-11-28 22:33:27 -05:00
Karishma Chadha 0a15190b85 Broadcast message functionality (works with creating new messages, and switching back and forth between them as well). This commit includes a temporary workaround for the issue where the default broadcast message, 'message1' wasn't triggering a var_create event (filed in LLK/scratch-blocks#1258). 2017-11-21 16:48:48 -05:00
DD Liu 58dd57fe48 Merge pull request #784 from fsih/perSpriteMonitors
Execute monitors on a given target ID when block is sprite-specific
2017-11-21 10:23:53 -05:00
kchadha 9df3b8ad86 Merge pull request #780 from mzgoddard/runtime-profiler
Runtime profiler
2017-11-16 10:02:37 -05:00
Paul Kaplan 1e27d21b15 Merge pull request #782 from kchadha/list-typed-variable
List typed variable
2017-11-15 12:48:56 -05:00
DD 757dccd565 Move is sprite specific verification into VM in a temporary way. Remove monitors when their sprites are deleted. 2017-11-14 18:25:54 -05:00
Michael "Z" Goddard 516d4f6f30 Add Profiler events to Runtime, Sequencer and execute 2017-11-14 14:57:32 -05:00
DD 9048a9b9e7 Pipe through whether a monitor is sprite-specific 2017-11-14 12:20:24 -05:00
Karishma Chadha 70959cc7f5 First cut at turning lists into typed variables 2017-11-09 17:19:34 -05:00
Ray Schamp b07bbd4745 Merge pull request #765 from mzgoddard/execute-is-promise-deopt
Write src/engine/execute so it can be optimized
2017-11-07 12:19:58 -05:00
Michael "Z" Goddard bbe7981703 Extract blockUtility from execute to reduce allocations
blockUtility as an object literal inside execute creates 11 objects,
one for the object, and 10 for the function closures. As a separate
object and allocated once, setting its sequencer and thread members,
block functions can share the same util object. Extract blockUtility to
cut down on allocations.
2017-11-07 10:21:51 -05:00
Michael "Z" Goddard 78847de660 Extract handleReport and add arguments to prevent closure alloc
`handleReport` inside `src/engine/execute.js`'s `execute` method needs
to allocate a closure to be able to refer to the higher scoped
variables. `execute` is called frequently that this has a noticable
impact on memory allocation and later collection. Extract handleReport
and add arguments to prevent the allocation.
2017-11-07 10:21:51 -05:00
Michael "Z" Goddard cd9004ce5b Write src/engine/execute so it can be optimized
Testing with implicitly casted `value` and `value.then` is deoptimizing
isPromise, which deoptimizes execute. In this case deoptimizing means
that the JavaScript VM cannot compile the functions into a form that
can be run faster.
2017-11-06 15:54:22 -05:00
Paul Kaplan b0870518a4 Changing parsing of custom procedures for new style 2017-10-06 16:26:19 -04:00
Ray Schamp 32bc087bba Fix remaining lint issues 2017-08-26 13:24:10 -04:00
Ray Schamp 5113876588 Pass with --fix 2017-08-26 13:24:10 -04:00
DD Liu fed449876f just hat changes 2017-08-03 16:01:53 -04:00
marisaleung 875ccf5b88 Updated variables and var_fire event listener. 2017-06-23 09:57:01 -07:00
Ray Schamp adcd225598 Merge pull request #584 from rschamp/nit/no-useless-call
Fix no-useless-call todo
2017-06-01 09:48:58 -04:00
DD Liu 48c51ab2ec switch to nested immutables state 2017-05-19 17:28:00 -04:00
Ray Schamp 548aa6dd70 Fix no-useless-call todo
The linter is correct that `devObject[func].call(devObject, args)` is unnecessary because it's equivalent to `devObject[func](args)`.

@tmickel probably either meant to allow passing an array of arguments to be applied, or to call the function with the provided argument. Since we probably want to be able to use multi-argument functions, use `apply` and fix the one place that uses `ioQuery` with an argument.
2017-05-15 21:11:38 -07:00
DD Liu 6ee1e6614c Remove leftover instances of MONITORS_ADDED and MONITORS_REMOVED, change updateMonitor to requestUpdateMonitor, update some todos with tracking numbers. 2017-05-15 10:12:25 -04:00
DD Liu 2a7f3edda6 Fix some issues: 1. Monitors not running anymore if you change categories 2. Visual reports not showing 3. threads acquiring properties of old thread when restarting thread 2017-05-11 17:12:19 -04:00
DD Liu 6b774c58f5 Update some comments 2017-05-11 15:23:11 -04:00
DD Liu b2e0a632e3 add add monitor action 2017-05-10 17:00:08 -04:00
DD Liu 4687fe41fe don't show green flag when monitor running 2017-05-10 14:06:02 -04:00
DD Liu 4ae1321252 indicate show visual report or update monitor on the thread 2017-05-09 17:34:13 -04:00
DD Liu 26a5098347 don't show visual report when monitor is running 2017-05-08 16:51:45 -04:00
Ray Schamp 4455b0694f Fix remaining no-var and no-use-before-define's 2017-04-17 17:15:19 -04:00
Ray Schamp e01c4ae108 Pass with --fix 2017-04-17 15:10:04 -04:00
griffpatch c754cc7cf8 Remove line break 2017-03-22 09:11:53 +00:00
griffpatch 220d854f28 Merge remote-tracking branch 'refs/remotes/LLK/develop' into optimise/reduceGetBlockCalls
# Conflicts:
#	src/engine/execute.js
2017-03-22 08:58:01 +00:00
griffpatch 25429b1192 Tidy up commit and revert direct member access 2017-03-22 08:48:30 +00:00
Andrew Sliwinski 7042bdb45c Merge pull request #472 from griffpatch/bug/escapeFromConditionalBranches
Bug - escapeFromConditionalBranches
2017-03-01 16:42:30 -05:00
griffpatch c5eb8ece16 Handle actual looping cases
And it starts to get a little less elegant :/
Wondering if this should not be handled better in another part of the
codebase?
We don't want to be duplicating existing code stepping functionality
locally at the end of the promise script really... What do you think?
2017-02-20 09:40:32 +00:00
griffpatch 362a231279 bug - escape from conditional branches
Execution bug: can't escape from conditional branches that end with a
Promise-resolution-terminating command block (see #464)
2017-02-20 08:20:21 +00:00
griffpatch a141bfb1b9 Fix lint issues 2017-02-16 10:54:17 +00:00
griffpatch ea59f8cd66 Reduce calls to getBlock 2017-02-11 14:26:23 +00:00
Magmaboat 85eee4f18e Perform hasOwnProperty validation 2017-02-09 21:12:47 -05:00
griffpatch 9cb595312e Implement "Stop this script" function
Existing implementation incorrectly terminates the entire thread.
See: http://llk.github.io/scratch-vm/#144142535
2017-02-08 09:44:10 +00:00
Ray Schamp 727fcc7875 Lint for eslint-config-scratch@3 2017-02-01 16:27:55 -05:00