JavaScript Multi-Thread Refactoring via DOM Segmentation

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Multi-threading in software development, particularly for dynamic languages like JavaScript, poses challenges due to thread interactions, conflicts, and blocking issues, which complicates the execution and development of software applications on multi-core processing devices.

Innovation Solution

The method involves refactoring JavaScript code for multi-threading by creating background processes, analyzing code entries to create dependency records, and separating interacting code entries from document object modules (DOM) interactions, allowing for concurrent execution without blocking the main execution path.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Ease of operation

If JavaScript code is executed in a single thread, then the execution path is simple and easy to control, but the main execution path is blocked when background operations are performed

Engineering Contradiction:
Improveexecution path simplicityVSAvoidconcurrent execution efficiency
Core Design Contradiction:
Ease of operationVSProductivity

Solution Approach 1:

The patent segments the JavaScript code execution into two independent parts: a main execution path that handles user interface operations and a background execution path that handles computational tasks. This segmentation is achieved by creating separate execution contexts with independent stacks, allowing the main path to remain simple while background operations execute concurrently without blocking.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent introduces a new dimension of execution by implementing background execution paths that operate independently from the main execution path. This dimensional separation allows background operations to execute in parallel without interfering with the main UI thread, effectively transforming single-threaded sequential execution into multi-dimensional concurrent execution.

Inventive Principle:
Principle #17Another dimension (Dimensionality change)

2Productivity

If multi-threading is implemented in JavaScript, then concurrent execution and productivity are improved, but thread interactions and conflicts increase complexity

Engineering Contradiction:
Improveconcurrent execution efficiencyVSAvoidthread interaction complexity
Core Design Contradiction:
ProductivityVSDevice complexity

Solution Approach 1:

The patent extracts the complexity of thread interaction management from the main execution path by implementing a dedicated background execution mechanism. The background path isolates potential conflicts and interactions within its own execution context, preventing them from propagating to the main thread. This extraction allows concurrent execution to proceed without exposing the main codebase to complex synchronization issues.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The patent introduces an intermediary execution context structure that mediates between the main execution path and background operations. This intermediary layer handles the coordination and communication between threads, absorbing the complexity of thread interactions while presenting a simple interface to the main execution path. The intermediary manages resource sharing and synchronization without requiring explicit conflict resolution code in the main application.

Inventive Principle:
Principle #24Intermediary (Mediator)

3Device complexity

If background code entries are executed without separation from DOM interactions, then code structure remains simple, but blocking and conflicts with main execution path occur

Engineering Contradiction:
Improvecode structure simplicityVSAvoidexecution stability
Core Design Contradiction:
Device complexityVSReliability

Solution Approach 1:

The patent segments code entries into two distinct groups: those that interact with the DOM and those that perform background computations. By separating DOM-interacting code from background code, the patent eliminates blocking issues while maintaining relatively simple code structures. Each segment has clearly defined responsibilities and execution contexts, making the overall system more reliable without requiring complex refactoring.

Inventive Principle:
Principle #1Segmentation

Data Source

PatentUS9946536B2Automatic refactoring of javascript code for multi-thread execution
Publication Date: 2018.04.17 INTERNATIONAL BUSINESS MACHINE CORPORATION
  • US9946536B2 patent drawing
  • US9946536B2 patent drawing
  • US9946536B2 patent drawing

AI summary

Computer implemented method of refactoring JavaScript code for multi-threading concurrent execution, comprising:1) Designating a source code which includes background code entries indicated by a user as executed in background.2) Analyzing the source code entries to create a dependency record.3) Creating a background process comprising the background code entries and removing code entries which read or write from DOM(s).4) Creating a handler code comprising the write code entries.5) Creating main code which includes:(a) Remaining code entries not included in the background process and the handler code.(b) Process initiation code initiating the background process. The process initiation code is placed at a process initiation point identified based on the dependency record which follows the read code entries in the source code execution path and precedes the write code entries.6) Outputting refactored code file(s) which include the background process, handler code and main code.