1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-01 09:24:20 -04:00
Commit graph

63 commits

Author SHA1 Message Date
Bert Belder
9b1997b8b6
core: clearly define when module lookup is path-based vs URL-based
The rules are now as follows:

* In `import` statements, as mandated by the WHATWG specification,
  the import specifier is always treated as a URL.
  If it is a relative URL, it must start with either / or ./ or ../

* A script name passed to deno as a command line argument may be either
  an absolute URL or a local path.
  - If the name starts with a valid URI scheme followed by a colon, e.g.
    'http:', 'https:', 'file:', 'foo+bar:', it always interpreted as a
    URL (even if Deno doesn't support the indicated protocol).
  - Otherwise, the script name is interpreted as a local path. The local
    path may be relative, and operating system semantics determine how
    it is resolved. Prefixing a relative path with ./ is not required.
2019-07-08 13:07:32 +02:00
Bartek Iwańczuk
9d18f97327 fix: normalize Deno.execPath (#2598) 2019-06-30 13:32:24 -04:00
Jimmy Cao
fb6d57a281 fix: run blocking function on a different task (#2570)
This avoids freezing the current task if the fn blocks indefinitely
2019-06-26 19:12:11 -04:00
Evgeniy Karagodin
d089f97978 Add homeDir to Deno namespace (#2578) 2019-06-25 09:05:41 -07:00
Bartek Iwańczuk
70a9859adc refactor: use Path/PathBuf in deno dir (#2559) 2019-06-24 10:10:21 -07:00
Bartek Iwańczuk
b9fbd55214 feat: log permission access (#2518)
Replaces -D/--log-debug flag with --log-level=debug

--log-level=info displays permission access
2019-06-22 09:02:51 -07:00
Bartek Iwańczuk
642eaf97c6 feat: redirect process stdio to file (#2554) 2019-06-21 16:00:14 -07:00
Kitson Kelly
425df50484 Combine CLI Errors (#2487) 2019-06-19 19:07:01 -07:00
Bartek Iwańczuk
01858f115a fix: use Loader::resolve in op_fetch_module_meta_data (#2519) 2019-06-18 07:23:06 -07:00
andy finch
76d51b0f9a refactor dispatch take 2 (#2533) 2019-06-17 18:02:08 -07:00
Ryan Dahl
1361e30223 Revert "Refactor dispatch handling (#2452)"
Due to performance regression:
dc60fe9f30 (commitcomment-33943711)

This reverts commit dc60fe9f30.
2019-06-14 13:56:36 -07:00
andy finch
dc60fe9f30 Refactor dispatch handling (#2452)
Promise id is now created in core and passed back to JS.
2019-06-13 20:43:54 -07:00
Bartek Iwańczuk
bca5cc5041 Move ModuleSpecifier to //core (#2509) 2019-06-12 16:55:59 -07:00
Bartek Iwańczuk
b3c4307d02 Refactor module resolving (#2493)
Adds ModuleSpecifier, which wraps a URL. This is now passed around instead of
specifier and resolver strings.
2019-06-12 12:00:08 -07:00
Matt Harrison
d82c1991cf Add --seed for setting RNG seed (#2483) 2019-06-11 10:34:39 -04:00
Bartek Iwańczuk
a115340288 feat: Import maps (#2360) 2019-06-09 09:08:20 -04:00
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