zexus 1.7.1 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/package.json +1 -1
- package/src/__init__.py +7 -0
- package/src/zexus/__init__.py +1 -1
- package/src/zexus/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/capability_system.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/debug_sanitizer.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/environment.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/error_reporter.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/input_validation.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/lexer.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/module_cache.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/module_manager.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/object.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/security.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/security_enforcement.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/syntax_validator.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/zexus_ast.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/zexus_token.cpython-312.pyc +0 -0
- package/src/zexus/access_control_system/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/access_control_system/__pycache__/access_control.cpython-312.pyc +0 -0
- package/src/zexus/advanced_types.py +17 -2
- package/src/zexus/blockchain/__init__.py +411 -0
- package/src/zexus/blockchain/accelerator.py +1160 -0
- package/src/zexus/blockchain/chain.py +660 -0
- package/src/zexus/blockchain/consensus.py +821 -0
- package/src/zexus/blockchain/contract_vm.py +1019 -0
- package/src/zexus/blockchain/crypto.py +79 -14
- package/src/zexus/blockchain/events.py +526 -0
- package/src/zexus/blockchain/loadtest.py +721 -0
- package/src/zexus/blockchain/monitoring.py +350 -0
- package/src/zexus/blockchain/mpt.py +716 -0
- package/src/zexus/blockchain/multichain.py +951 -0
- package/src/zexus/blockchain/multiprocess_executor.py +338 -0
- package/src/zexus/blockchain/network.py +886 -0
- package/src/zexus/blockchain/node.py +666 -0
- package/src/zexus/blockchain/rpc.py +1203 -0
- package/src/zexus/blockchain/rust_bridge.py +421 -0
- package/src/zexus/blockchain/storage.py +423 -0
- package/src/zexus/blockchain/tokens.py +750 -0
- package/src/zexus/blockchain/upgradeable.py +1004 -0
- package/src/zexus/blockchain/verification.py +1602 -0
- package/src/zexus/blockchain/wallet.py +621 -0
- package/src/zexus/cli/__pycache__/main.cpython-312.pyc +0 -0
- package/src/zexus/cli/main.py +300 -20
- package/src/zexus/cli/zpm.py +1 -1
- package/src/zexus/compiler/__pycache__/bytecode.cpython-312.pyc +0 -0
- package/src/zexus/compiler/__pycache__/lexer.cpython-312.pyc +0 -0
- package/src/zexus/compiler/__pycache__/parser.cpython-312.pyc +0 -0
- package/src/zexus/compiler/__pycache__/semantic.cpython-312.pyc +0 -0
- package/src/zexus/compiler/__pycache__/zexus_ast.cpython-312.pyc +0 -0
- package/src/zexus/compiler/lexer.py +10 -5
- package/src/zexus/concurrency_system.py +79 -0
- package/src/zexus/config.py +54 -0
- package/src/zexus/crypto_bridge.py +244 -8
- package/src/zexus/dap/__init__.py +10 -0
- package/src/zexus/dap/__main__.py +4 -0
- package/src/zexus/dap/dap_server.py +391 -0
- package/src/zexus/dap/debug_engine.py +298 -0
- package/src/zexus/environment.py +10 -1
- package/src/zexus/evaluator/__pycache__/bytecode_compiler.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/core.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/expressions.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/functions.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/resource_limiter.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/statements.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/unified_execution.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/utils.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/bytecode_compiler.py +441 -37
- package/src/zexus/evaluator/core.py +560 -49
- package/src/zexus/evaluator/expressions.py +122 -49
- package/src/zexus/evaluator/functions.py +417 -16
- package/src/zexus/evaluator/statements.py +521 -118
- package/src/zexus/evaluator/unified_execution.py +573 -72
- package/src/zexus/evaluator/utils.py +14 -2
- package/src/zexus/event_loop.py +186 -0
- package/src/zexus/lexer.py +742 -486
- package/src/zexus/lsp/__init__.py +1 -1
- package/src/zexus/lsp/definition_provider.py +163 -9
- package/src/zexus/lsp/server.py +22 -8
- package/src/zexus/lsp/symbol_provider.py +182 -9
- package/src/zexus/module_cache.py +237 -9
- package/src/zexus/object.py +64 -6
- package/src/zexus/parser/__pycache__/parser.cpython-312.pyc +0 -0
- package/src/zexus/parser/__pycache__/strategy_context.cpython-312.pyc +0 -0
- package/src/zexus/parser/__pycache__/strategy_structural.cpython-312.pyc +0 -0
- package/src/zexus/parser/parser.py +786 -285
- package/src/zexus/parser/strategy_context.py +407 -66
- package/src/zexus/parser/strategy_structural.py +117 -19
- package/src/zexus/persistence.py +15 -1
- package/src/zexus/renderer/__init__.py +15 -0
- package/src/zexus/renderer/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/renderer/__pycache__/backend.cpython-312.pyc +0 -0
- package/src/zexus/renderer/__pycache__/canvas.cpython-312.pyc +0 -0
- package/src/zexus/renderer/__pycache__/color_system.cpython-312.pyc +0 -0
- package/src/zexus/renderer/__pycache__/layout.cpython-312.pyc +0 -0
- package/src/zexus/renderer/__pycache__/main_renderer.cpython-312.pyc +0 -0
- package/src/zexus/renderer/__pycache__/painter.cpython-312.pyc +0 -0
- package/src/zexus/renderer/tk_backend.py +208 -0
- package/src/zexus/renderer/web_backend.py +260 -0
- package/src/zexus/runtime/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/runtime/__pycache__/async_runtime.cpython-312.pyc +0 -0
- package/src/zexus/runtime/__pycache__/load_manager.cpython-312.pyc +0 -0
- package/src/zexus/runtime/file_flags.py +137 -0
- package/src/zexus/safety/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/safety/__pycache__/memory_safety.cpython-312.pyc +0 -0
- package/src/zexus/security.py +424 -34
- package/src/zexus/stdlib/fs.py +23 -18
- package/src/zexus/stdlib/http.py +289 -186
- package/src/zexus/stdlib/sockets.py +207 -163
- package/src/zexus/stdlib/websockets.py +282 -0
- package/src/zexus/stdlib_integration.py +369 -2
- package/src/zexus/strategy_recovery.py +6 -3
- package/src/zexus/type_checker.py +423 -0
- package/src/zexus/virtual_filesystem.py +189 -2
- package/src/zexus/vm/__init__.py +113 -3
- package/src/zexus/vm/__pycache__/async_optimizer.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/bytecode.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/bytecode_converter.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/cache.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/compiler.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/gas_metering.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/jit.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/parallel_vm.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/vm.cpython-312.pyc +0 -0
- package/src/zexus/vm/async_optimizer.py +14 -1
- package/src/zexus/vm/binary_bytecode.py +659 -0
- package/src/zexus/vm/bytecode.py +28 -1
- package/src/zexus/vm/bytecode_converter.py +26 -12
- package/src/zexus/vm/cabi.c +1985 -0
- package/src/zexus/vm/cabi.cpython-312-x86_64-linux-gnu.so +0 -0
- package/src/zexus/vm/cabi.h +127 -0
- package/src/zexus/vm/cache.py +557 -17
- package/src/zexus/vm/compiler.py +703 -5
- package/src/zexus/vm/fastops.c +15743 -0
- package/src/zexus/vm/fastops.cpython-312-x86_64-linux-gnu.so +0 -0
- package/src/zexus/vm/fastops.pyx +288 -0
- package/src/zexus/vm/gas_metering.py +50 -9
- package/src/zexus/vm/jit.py +83 -2
- package/src/zexus/vm/native_jit_backend.py +1816 -0
- package/src/zexus/vm/native_runtime.cpp +1388 -0
- package/src/zexus/vm/native_runtime.cpython-312-x86_64-linux-gnu.so +0 -0
- package/src/zexus/vm/optimizer.py +161 -11
- package/src/zexus/vm/parallel_vm.py +118 -42
- package/src/zexus/vm/peephole_optimizer.py +82 -4
- package/src/zexus/vm/profiler.py +38 -18
- package/src/zexus/vm/register_allocator.py +16 -5
- package/src/zexus/vm/register_vm.py +8 -5
- package/src/zexus/vm/vm.py +3411 -573
- package/src/zexus/vm/wasm_compiler.py +658 -0
- package/src/zexus/zexus_ast.py +63 -11
- package/src/zexus/zexus_token.py +13 -5
- package/src/zexus/zpm/installer.py +55 -15
- package/src/zexus/zpm/package_manager.py +1 -1
- package/src/zexus/zpm/registry.py +257 -28
- package/src/zexus.egg-info/PKG-INFO +7 -4
- package/src/zexus.egg-info/SOURCES.txt +116 -9
- package/src/zexus.egg-info/entry_points.txt +1 -0
- package/src/zexus.egg-info/requires.txt +4 -0
package/src/zexus/vm/__init__.py
CHANGED
|
@@ -1,8 +1,118 @@
|
|
|
1
1
|
"""
|
|
2
2
|
Zexus Virtual Machine - Backend Execution Engine
|
|
3
|
+
|
|
4
|
+
This package provides a comprehensive VM system for Zexus with:
|
|
5
|
+
- Stack-based VM (standard execution)
|
|
6
|
+
- Register-based VM (optimized paths)
|
|
7
|
+
- Parallel VM (multi-core execution)
|
|
8
|
+
- JIT compilation (hot path native code)
|
|
9
|
+
- Peephole optimizer (bytecode optimization)
|
|
10
|
+
- Bytecode caching (persistent across runs)
|
|
11
|
+
- Memory pooling (efficient allocation)
|
|
12
|
+
- Gas metering (resource control)
|
|
3
13
|
"""
|
|
4
14
|
|
|
5
|
-
|
|
6
|
-
from .
|
|
15
|
+
# Core VM
|
|
16
|
+
from .vm import VM as ZexusVM, VMMode
|
|
17
|
+
from .bytecode import Bytecode, Opcode, BytecodeBuilder
|
|
18
|
+
|
|
19
|
+
# Caching system (with file-based persistence)
|
|
20
|
+
from .cache import BytecodeCache, CacheStats, FileMetadata
|
|
21
|
+
|
|
22
|
+
# Compilers
|
|
23
|
+
from .compiler import BytecodeCompiler
|
|
24
|
+
|
|
25
|
+
# Optimizers
|
|
26
|
+
try:
|
|
27
|
+
from .optimizer import BytecodeOptimizer
|
|
28
|
+
OPTIMIZER_AVAILABLE = True
|
|
29
|
+
except ImportError:
|
|
30
|
+
BytecodeOptimizer = None
|
|
31
|
+
OPTIMIZER_AVAILABLE = False
|
|
32
|
+
|
|
33
|
+
try:
|
|
34
|
+
from .peephole_optimizer import PeepholeOptimizer, OptimizationLevel
|
|
35
|
+
PEEPHOLE_AVAILABLE = True
|
|
36
|
+
except ImportError:
|
|
37
|
+
PeepholeOptimizer = None
|
|
38
|
+
OptimizationLevel = None
|
|
39
|
+
PEEPHOLE_AVAILABLE = False
|
|
40
|
+
|
|
41
|
+
# JIT
|
|
42
|
+
try:
|
|
43
|
+
from .jit import JITCompiler, ExecutionTier
|
|
44
|
+
JIT_AVAILABLE = True
|
|
45
|
+
except ImportError:
|
|
46
|
+
JITCompiler = None
|
|
47
|
+
ExecutionTier = None
|
|
48
|
+
JIT_AVAILABLE = False
|
|
49
|
+
|
|
50
|
+
# Register VM
|
|
51
|
+
try:
|
|
52
|
+
from .register_vm import RegisterVM
|
|
53
|
+
REGISTER_VM_AVAILABLE = True
|
|
54
|
+
except ImportError:
|
|
55
|
+
RegisterVM = None
|
|
56
|
+
REGISTER_VM_AVAILABLE = False
|
|
57
|
+
|
|
58
|
+
# Parallel VM
|
|
59
|
+
try:
|
|
60
|
+
from .parallel_vm import ParallelVM, ExecutionMode
|
|
61
|
+
PARALLEL_VM_AVAILABLE = True
|
|
62
|
+
except ImportError:
|
|
63
|
+
ParallelVM = None
|
|
64
|
+
ExecutionMode = None
|
|
65
|
+
PARALLEL_VM_AVAILABLE = False
|
|
66
|
+
|
|
67
|
+
# Memory management
|
|
68
|
+
try:
|
|
69
|
+
from .memory_pool import IntegerPool, StringPool, ListPool
|
|
70
|
+
MEMORY_POOL_AVAILABLE = True
|
|
71
|
+
except ImportError:
|
|
72
|
+
IntegerPool = None
|
|
73
|
+
StringPool = None
|
|
74
|
+
ListPool = None
|
|
75
|
+
MEMORY_POOL_AVAILABLE = False
|
|
76
|
+
|
|
77
|
+
# Gas metering
|
|
78
|
+
try:
|
|
79
|
+
from .gas_metering import GasMetering, OutOfGasError
|
|
80
|
+
GAS_METERING_AVAILABLE = True
|
|
81
|
+
except ImportError:
|
|
82
|
+
GasMetering = None
|
|
83
|
+
OutOfGasError = None
|
|
84
|
+
GAS_METERING_AVAILABLE = False
|
|
85
|
+
|
|
86
|
+
# Profiler
|
|
87
|
+
try:
|
|
88
|
+
from .profiler import InstructionProfiler, ProfilingLevel
|
|
89
|
+
PROFILER_AVAILABLE = True
|
|
90
|
+
except ImportError:
|
|
91
|
+
InstructionProfiler = None
|
|
92
|
+
ProfilingLevel = None
|
|
93
|
+
PROFILER_AVAILABLE = False
|
|
7
94
|
|
|
8
|
-
__all__ = [
|
|
95
|
+
__all__ = [
|
|
96
|
+
# Core
|
|
97
|
+
'ZexusVM', 'VMMode', 'Bytecode', 'Opcode', 'BytecodeBuilder',
|
|
98
|
+
# Cache
|
|
99
|
+
'BytecodeCache', 'CacheStats', 'FileMetadata',
|
|
100
|
+
# Compiler
|
|
101
|
+
'BytecodeCompiler',
|
|
102
|
+
# Optimizers
|
|
103
|
+
'BytecodeOptimizer', 'PeepholeOptimizer', 'OptimizationLevel',
|
|
104
|
+
# JIT
|
|
105
|
+
'JITCompiler', 'ExecutionTier',
|
|
106
|
+
# Advanced VMs
|
|
107
|
+
'RegisterVM', 'ParallelVM', 'ExecutionMode',
|
|
108
|
+
# Memory
|
|
109
|
+
'IntegerPool', 'StringPool', 'ListPool',
|
|
110
|
+
# Gas
|
|
111
|
+
'GasMetering', 'OutOfGasError',
|
|
112
|
+
# Profiler
|
|
113
|
+
'InstructionProfiler', 'ProfilingLevel',
|
|
114
|
+
# Availability flags
|
|
115
|
+
'OPTIMIZER_AVAILABLE', 'PEEPHOLE_AVAILABLE', 'JIT_AVAILABLE',
|
|
116
|
+
'REGISTER_VM_AVAILABLE', 'PARALLEL_VM_AVAILABLE',
|
|
117
|
+
'MEMORY_POOL_AVAILABLE', 'GAS_METERING_AVAILABLE', 'PROFILER_AVAILABLE',
|
|
118
|
+
]
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -328,9 +328,18 @@ class AsyncOptimizer:
|
|
|
328
328
|
|
|
329
329
|
# Use pooling if enabled
|
|
330
330
|
if self.coroutine_pool and self.level.value >= AsyncOptimizationLevel.BASIC.value:
|
|
331
|
-
|
|
331
|
+
wrapper = self.coroutine_pool.get_wrapper(coro)
|
|
332
|
+
return self._wrap_pooled(wrapper)
|
|
332
333
|
|
|
333
334
|
return coro
|
|
335
|
+
|
|
336
|
+
async def _wrap_pooled(self, wrapper: PooledCoroutineWrapper) -> Any:
|
|
337
|
+
"""Ensure pooled wrappers are released after completion."""
|
|
338
|
+
try:
|
|
339
|
+
return await wrapper
|
|
340
|
+
finally:
|
|
341
|
+
if self.coroutine_pool:
|
|
342
|
+
self.coroutine_pool.release_wrapper(wrapper)
|
|
334
343
|
|
|
335
344
|
async def await_optimized(self, awaitable: Any) -> Any:
|
|
336
345
|
"""
|
|
@@ -346,6 +355,10 @@ class AsyncOptimizer:
|
|
|
346
355
|
|
|
347
356
|
# Fast path for already-resolved futures (MODERATE+)
|
|
348
357
|
if self.level.value >= AsyncOptimizationLevel.MODERATE.value:
|
|
358
|
+
if not asyncio.isfuture(awaitable) and not asyncio.iscoroutine(awaitable) and not hasattr(awaitable, "__await__"):
|
|
359
|
+
self.stats.fast_path_hits += 1
|
|
360
|
+
self.stats.event_loop_skips += 1
|
|
361
|
+
return awaitable
|
|
349
362
|
if isinstance(awaitable, FastFuture):
|
|
350
363
|
self.stats.fast_path_hits += 1
|
|
351
364
|
self.stats.event_loop_skips += 1
|