Commit graph

47 commits

Author SHA1 Message Date
gurv-s 35f879ad32 Remove tokio_util::block_on dep in compile_async and other cleanup 2019-06-08 10:59:20 -04:00
gurv-s 564222bc10 make op_create_worker async internally 2019-06-08 10:59:20 -04:00
Ryan Dahl e152dae006
RecursiveLoad shouldn't own the Isolate (#2453)
This patch makes it so that RecursiveLoad doesn't own the Isolate, so
Worker::execute_mod_async does not consume itself.

Previously Worker implemented Loader, but now ThreadSafeState does.

This is necessary preparation work for dynamic import (#1789) and import
maps (#1921)
2019-06-05 16:35:38 -04:00
Ryan Dahl 856c44213b TS compiler refactor
* Compiler no longer has its own Tokio runtime. Compiler handles one
  message and then exits.

* Uses the simpler ts.CompilerHost interface instead of
  ts.LanguageServiceHost.

* avoids recompiling the same module by introducing a hacky but simple
  `hashset<string>` that stores the module names that have been already
  compiled.

* Removes the CompilerConfig op.

* Removes a lot of the mocking stuff in compiler.ts like `this._ts`. It
  is not useful as we don't even have tests.

* Turns off checkJs because it causes fmt_test to die with OOM.
2019-05-29 07:53:39 -04:00
Ryan Dahl 53b6356ec5 Correct tokio_util::block_on() and op_fetch_module_meta_data
op_fetch_module_meta_data is an op that is used by the TypeScript
compiler. TypeScript requires this op to be sync. However the
implementation of the op does things on the event loop (like fetching
HTTP resources).

In certain situations this can lead to deadlocks. The runtime's thread
pool can be filled with ops waiting on the result of
op_fetch_module_meta_data. The runtime has a maximum number of
threads it can use (the number of logical CPUs on the system).

This patch changes tokio_util::block_on to launch a new Tokio runtime
for evaluating the future, thus bipassing the max-thread problem.

This is only an issue in op_fetch_module_meta_data. Other synchronous
ops are truly synchornous, not interacting with the event loop.  TODO
comments are added to direct future development.
2019-05-29 07:53:39 -04:00
Bartek Iwańczuk 1105982586 re-fix permissions for dial and listen (#2400)
Closes #2397
2019-05-23 23:47:55 +03:00
Ryan Dahl 2952fb5405
Rename --allow-high-precision to --allow-hrtime (#2398) 2019-05-23 19:28:29 +03:00
Bert Belder 7d03a63ded
Revert "Fix permissions for dial and listen (#2373)"
This reverts commit 7219787894.
2019-05-22 19:47:15 -07:00
Bartek Iwańczuk 7219787894 Fix permissions for dial and listen (#2373) 2019-05-17 14:50:53 -04:00
chiefbiiko 00f6fa46b3 Add crypto.getRandomValues() (#2327) 2019-05-17 14:03:01 -04:00
Ryan Dahl e02d8bcf18 Remove FileInfo.path 2019-05-15 21:14:17 -04:00
Ryan Dahl aba952397a
Add progress bar (#2309) 2019-05-11 10:23:19 -04:00
Bartek Iwańczuk 1fc61f3b6a core: Privatize ModuleNameMap SymbolicModule deno_buf (#2324) 2019-05-09 16:44:30 -04:00
Kevin (Kun) "Kassimo" Qian d9cdc6788b fix: support relative path for whitelisting (#2317)
Using `std::fs::canonicalize` to expand path to full existing path, such that
later attempt to loop-pop and compare path segment would work.
2019-05-09 12:20:34 -04:00
andy finch 2edee3367d First pass at permissions whitelist (#2129) 2019-05-08 19:20:30 -04:00
Yingbo (Max) Wang ec9080f34c Add Deno.chown (#2292) 2019-05-07 21:58:57 -04:00
Kevin (Kun) "Kassimo" Qian 3608117132 feat(cli cmd): deno xeval (#2260) 2019-05-03 16:24:09 -04:00
Bartek Iwańczuk 459162fc6e add --no-fetch CLI flag to prevent remote downloads (#2213) 2019-05-03 11:09:51 -04:00
Ryan Dahl 00ac871607
Optimize read and write ops (#2259) 2019-05-03 00:06:43 -04:00
Bert Belder 8999517421
core,cli: fix clippy warnings 2019-05-03 03:29:42 +02:00
Ryan Dahl c171813e89
core: express op as enum (#2255) 2019-05-01 18:22:32 -04:00
Bert Belder 41c7e96f1a
Refactor zero-copy buffers for performance and to prevent memory leaks
* In order to prevent ArrayBuffers from getting garbage collected by V8,
  we used to store a v8::Persistent<ArrayBuffer> in a map. This patch
  introduces a custom ArrayBuffer allocator which doesn't use Persistent
  handles, but instead stores a pointer to the actual ArrayBuffer data
  alongside with a reference count. Since creating Persistent handles
  has quite a bit of overhead, this change significantly increases
  performance. Various HTTP server benchmarks report about 5-10% more
  requests per second than before.

* Previously the Persistent handle that prevented garbage collection had
  to be released manually, and this wasn't always done, which was
  causing memory leaks. This has been resolved by introducing a new
  `PinnedBuf` type in both Rust and C++ that automatically re-enables
  garbage collection when it goes out of scope.

* Zero-copy buffers are now correctly wrapped in an Option if there is a
  possibility that they're not present. This clears up a correctness
  issue where we were creating zero-length slices from a null pointer,
  which is against the rules.
2019-05-01 21:11:09 +02:00
Kevin (Kun) "Kassimo" Qian 7237e9d34a fs: add Deno.utime/Deno.utimeSync (#2241) 2019-05-01 05:08:11 -04:00
Kitson Kelly 1a0f53a807 Add support for custom tsconfig.json (#2089)
Use `--config`
2019-04-29 07:58:31 -07:00
Kevin (Kun) "Kassimo" Qian 1d4b92ac85 Add Deno.kill(pid, signo) and process.kill(signo) (Unix only) (#2177) 2019-04-21 21:26:56 -04:00
Bartek Iwańczuk cd19da62d9 Refactor CLI entry point (#2157)
Changes "deno --types" to "deno types"
and "deno --prefetch" to "deno prefetch"
2019-04-21 11:34:18 -04:00
Bert Belder 8477daa8b9
Fix clippy warnings 2019-04-17 15:35:46 +02:00
Ryan Dahl 1bfb443369
Implement async module loading in CLI (#2084) 2019-04-16 15:13:42 -04:00
andy finch 960ee5257a Improve op dispatch (#2088) 2019-04-11 10:58:31 -04:00
Bert Belder 4ffe1612ff Silence clippy warnings and format source code 2019-04-09 20:05:47 +02:00
Ryan Dahl d2579f4564
core: Rename Behavior to Dispatch (#2082)
And rename IsolateState to ThreadSafeState.

Also make ThreadSafeState directly implement Dispatch. This is simpler.
2019-04-09 13:11:25 -04:00
Ryan Dahl 2debbdacb9
Merge Worker and Isolate types (#2078)
Reduces generics.
2019-04-08 17:10:00 -04:00
Vincent LE GOFF 734cf781c6 Allow high precision performance.now() (#1977) 2019-04-08 16:22:40 -04:00
Ryan Dahl f7fdb90fd5
core: snapshot improvements (#2052)
* Moves how snapshots are supplied to the Isolate. Previously they were
  given by Behavior::startup_data() but it was only called once at
  startup. It makes more sense (and simplifies Behavior) to pass it to the
  constructor of Isolate.
* Adds new libdeno type deno_snapshot instead of overloading
  deno_buf.
* Adds new libdeno method to delete snapshot deno_snapshot_delete().
* Renames deno_get_snapshot() to deno_snapshot_new().
* Makes StartupData hold references to snapshots. This was implicit when
  it previously held a deno_buf but is made explicit now. Note that
  include_bytes!() returns a &'static [u8] and we want to avoid
  copying that.
2019-04-08 10:12:43 -04:00
Kevin (Kun) "Kassimo" Qian 1746a3ac69 Add link/linkSync fs call for hardlinks (#2074) 2019-04-08 09:11:32 -04:00
Bert Belder b735155712
Clippy fixes 2019-04-02 18:04:25 +02:00
andy finch b0a23beb8f Add web worker JS API (#1993)
* Refactored the way worker polling is scheduled and errors are handled.
* Share the worker future as a Shared
2019-04-01 15:09:59 -04:00
Ryan Dahl e9910d8ae5
Rename crate deno_core to deno (#2022) 2019-03-30 19:30:40 -04:00
Ryan Dahl c25e262b04
Merge the --recompile and --reload flags (#2003) 2019-03-28 16:05:41 -04:00
Bartek Iwańczuk 597ee38ef2 Rewrite readFile and writeFile (#2000)
Using open/read/write
2019-03-27 23:29:36 -04:00
Kitson Kelly c43cfedeba namespace reorg: libdeno and DenoCore to Deno.core (#1998) 2019-03-26 08:22:07 -04:00
andy finch 1499d57490 Remove dead code (#1983) 2019-03-21 15:52:30 -04:00
Ryan Dahl 94405bb617
Fix clippy errors and upgrade Rust to 1.33.0 in CI (#1945) 2019-03-20 18:55:52 -04:00
Ryan Dahl 4c831f1eb5
Add more async module loading function (#1974)
* get_source_code_async
* fetch_module_meta_data_async
* fetch_module_meta_data_and_maybe_compile_async
2019-03-20 11:38:43 -04:00
andy finch 48bf419669 Separate behavior for the compiler isolate (#1973) 2019-03-19 20:55:59 -04:00
andy finch 6131152a57 Remove old Buf definition in cli.rs (#1971) 2019-03-19 16:47:35 -04:00
Ryan Dahl fa3c35301a
Rename //src/ to //cli/ (#1962)
To better distinguish the deno_core crate from the executable deno,
which will now be called "the cli" internally.
2019-03-19 12:18:05 -04:00
Renamed from src/ops.rs (Browse further)