0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-11-29 16:31:01 -05:00
Commit graph

277 commits

Author SHA1 Message Date
Bert Belder
9ef9c5f871
Make all V8 heap object types subtypes of v8::Data (#351)
In v8.h, not all heap object classes actually derive from `v8::Data`,
but this seems to be a mistake, because this hierarchy does definitely
exists in V8's internal source code.
2020-04-15 23:56:59 +02:00
Bert Belder
16d6ca2398
Re-generate data.rs from the latest version of v8.h (#351) 2020-04-15 23:23:20 +02:00
Bert Belder
d1ac68f0c8
Always use raw pointers to send V8 handles between C++ and Rust (#349)
And other pointer usage touch-ups on the C++ side:
- const parameters are passed by & reference.
- mutable parameters are passed by * pointer.
2020-04-14 00:34:32 +02:00
Bert Belder
675d585977
Add binding for v8__internal__GetIsolateFromHeapObject() (#348) 2020-04-13 02:18:05 +02:00
Bert Belder
2b08fd1651
Format source code (#348) 2020-04-13 00:48:59 +02:00
FrankBlue
5a5bad9adf
add Map::size and Map::as_array (#333) 2020-04-02 13:37:13 -04:00
Ryan Dahl
fc948f4983
Merge all inspector bindings into one file (#331)
The file naming in the current src/inspector/ directory is inconsistent and difficult to
navigate. It will be simpler if we just put them all in one place since they're rather
interconnected.
2020-04-01 20:19:07 -04:00
Michał Sabiniarz
bb0be74b0b
add v8::Proxy (#330) 2020-04-01 17:47:19 -04:00
Max Bruce
6bf57abb5c
Implement GetPrototype and SetPrototype on objects (#321) 2020-03-23 11:39:43 -04:00
Kevin (Kun) "Kassimo" Qian
747f513cba
Add v8::Function::new_with_data to attach associated data (#310) 2020-03-14 22:42:18 -04:00
Ben Noordhuis
0df04f2129
Add Isolate::take_heap_snapshot() (#302)
This doesn't really follow the current V8 API (it's pretty close to how
V8 used to be back in 2012 though.) However:

1. The C++ API is very C++-y and doesn't carry over well to Rust, and
2. It addresses the immediate need of being able to take heap snapshots.

Refs #298
2020-03-09 10:30:25 -07:00
Bert Belder
e1b59ec736
Implement 'Eq' and 'PartialEq' traits for local handles (#301) 2020-03-05 19:37:58 -08:00
Bert Belder
926f3a19da
Update generated types/traits, and generate more types (#300) 2020-03-05 17:42:55 -08:00
Ryan Dahl
d42099f9cc
Add comments to make_pod (#295)
Remove unused padding.
2020-02-28 17:48:59 -08:00
Bert Belder
5e99489c3b
Use make_pod to convert Global<T> to T* (#297) 2020-02-28 17:31:22 -08:00
Ryan Dahl
816b6ad537
Fix BackingStore segfault (#294) 2020-02-28 18:40:48 -05:00
Bert Belder
3803e07065
Revert "Add HandleScope::new2 hack to construct from const ref (#290)"
It's not pretty, and we currently don't need it in Deno.

This reverts commit 4f0662ed57.
2020-02-25 17:22:05 -08:00
Bert Belder
eba98e7a5e
Revert "Add ability to attach arbitrary state to Isolate (#282)"
This patch introduces a bug that breaks Deno.

This reverts commit 457f7ae779.
2020-02-25 17:21:55 -08:00
Ryan Dahl
4f0662ed57
Add HandleScope::new2 hack to construct from const ref (#290) 2020-02-20 03:14:19 -05:00
Ryan Dahl
d3bbd05634
Add new terminate_execution test (#288) 2020-02-19 22:55:44 -05:00
Ryan Dahl
457f7ae779
Add ability to attach arbitrary state to Isolate (#282) 2020-02-18 23:46:00 -05:00
Ben Noordhuis
5d0b9fd760
Add some Array methods (#283) 2020-02-14 09:42:54 -05:00
Ryan Dahl
554f06f6bc
Fix get_slot and set_slot (#281) 2020-02-13 15:03:25 -05:00
Bert Belder
3dacbd396e
Fix use-after-free bug in IsolateHandle::dispose_isolate() (#280)
This function acquires a mutex lock which, prior to this patch, would be
unlocked _after_ releasing the IsolateAnnex memory allocation where the
mutex was stored.
2020-02-13 02:56:19 -08:00
Bert Belder
ddc8062644
Move get_*_context() methods to scope::Entered, remove InContext trait (#279)
The `get_current_context()` and `get_entered_or_microtask_context()`
methods now return `Option<Local<Context>>` to reflect that an isolate
may not have entered any context.

They're also moved from `Isolate` to `struct Entered` because it turns
out that the underlying V8 API calls actually create new local handles,
hence they should only be used inside an active HandleScope.

The `InContext` trait has been removed.

A test exercising `ContextScope` and the `get_*_context()` methods
mentioned above was added.

Closes: #248.
2020-02-12 22:00:31 -08:00
Ryan Dahl
27277ad801
Add IsolateHandle (#274)
Co-authored-by: Bert Belder <bertbelder@gmail.com>
2020-02-12 11:33:58 -05:00
Ryan Dahl
32abe84dc6
Remove v8::Locker (#272)
This patch clarifies that v8::Isolate is a single threaded creature,
which can only be accessed from other threads in special circumstances.
To ensure optimal operation in Deno, we remove v8::Locker, which ought
to be unnecessary when a thread is dedicated to each Isolate and the
Isolates never move between threads.

There are valid use-cases for v8::Locker, and we hope to address them in
future versions of rusty_v8.

Co-authored-by: Bert Belder <bertbelder@gmail.com>
2020-02-11 17:01:27 -05:00
Ryan Dahl
4f449b6ec6
Upgrade V8 to 8.1.310 (#263)
Co-authored-by: Bert Belder <bertbelder@gmail.com>
2020-01-30 20:44:28 -05:00
Ryan Dahl
62a52e0241
Do not use std::os::raw::c_int in public API (#259) 2020-01-28 17:16:31 -05:00
Ryan Dahl
2e61735f44
add test for schedule_pause_on_next_statement (#258) 2020-01-28 16:33:34 -05:00
Ben Noordhuis
9e14f18347 Add Object::creation_context() (#255)
And also Array::creation_context(), Function::creation_context(), etc.,
because they inherit from Object.
2020-01-26 17:42:28 +01:00
Ben Noordhuis
683aa2b2a9 Add V8InspectorClientImpl::console_api_message() (#252)
This makes it possible to intercept console.log() messages through
the V8 inspector API.
2020-01-24 09:33:54 -05:00
Ryan Dahl
093e09217c SharedArrayBuffer::new_backing_store_from_boxed_slice doesn't need to be unsafe 2020-01-23 14:24:03 -05:00
Ryan Dahl
db33bc9aec Expose TaskBase and TaskImpl 2020-01-23 11:57:25 -05:00
Ryan Dahl
aca89c2055
new_backing_store_from_boxed_slice doesn't need to be unsafe (#247) 2020-01-23 10:17:23 -05:00
Bert Belder
7e27c88708
Remove TODO comment that's no longer relevant (#246) 2020-01-23 00:01:53 +01:00
Bert Belder
5e55cc5a5c
Add binding for Isolate::get_entered_or_microtask_context() (#245)
A test will be added later.
2020-01-22 23:36:52 +01:00
Bert Belder
2286052468
Rename String::new_empty() to String::empty() (#244)
This is more consistent with the C++ API.
2020-01-22 23:21:56 +01:00
Bert Belder
8617f77fd3
Refactor v8::Object bindings (#243)
* Rename `Object::new2()` to `Object::with_prototype_and_properties()`.
* Make `Object::with_prototype_and_properties()` take a slice of keys
  and a slice of values as arguments, instead of using
  `Vec<v8::Local<v8::Name>>` and `Vec<v8::Local<v8::Value>>>`.
* Remove type `MaybeBool` from the public interface. These methods now
  return `Option<bool>` instead.
* Fix parameter type mismatches between Rust and C++ APIs.
2020-01-22 23:13:58 +01:00
Bert Belder
dcb94533f8
Make SharedRef<T> deref to UnsafeCell<T> instead of T (#242)
Closes: #240
2020-01-22 22:29:03 +01:00
Bert Belder
bf128554fc
Implement Clone for SharedRef<T> (#241) 2020-01-22 22:02:44 +01:00
Ben Noordhuis
ab3a086132 Add String::new_empty() (#238) 2020-01-22 17:23:42 +01:00
Andy Finch
d302180ffa remove pub use support::int; #235 (#239) 2020-01-22 11:01:49 -05:00
Bert Belder
9124720c5a
8-bit StringView uses latin-1 encoding, not UTF-8 (#237) 2020-01-22 00:11:29 +01:00
Ben Noordhuis
4b8573a993 Implement fmt::Display for StringView (#236)
Make StringView objects inspectable to make it easier to debug the
V8 inspector's wire protocol.

StringBuffer objects can't be inspected yet because they need a mutable
reference if they want to call `StringBuffer::string()`, which makes
sense because that method calls out to a C++ virtual method that can
modify the object.

For now, instances can be inspected like this:

    let mut sb = StringBuffer::create(...);
    println!("StringBuffer({})", sb.string().unwrap());

Closes #233
2020-01-21 17:33:51 -05:00
Bert Belder
1a1bac3883
Make BackingStore APIs more consistent with C++ (#234) 2020-01-21 16:23:47 +01:00
Ryan Dahl
791cbc627a Add docs about scopes to lib.rs 2020-01-21 09:45:32 -05:00
Bert Belder
b3d93dad78
Some clean-ups after making Locker a Scope (#231) 2020-01-21 03:16:55 +01:00
Bert Belder
44d58f8f48
Make Locker also a Scope (#229) 2020-01-21 02:03:45 +01:00
Bert Belder
36a12142f2
Make EscapableHandleScope::escape() inheritable, tighten lifetimes (#227) 2020-01-20 23:34:28 +01:00
Ben Noordhuis
6efb395fdc Add Object::define_own_property() (#228)
This commit introduces the NONE, READ_ONLY, DONT_ENUM and DONT_DELETE
property attributes.
2020-01-20 11:16:24 -05:00
Ben Noordhuis
42af31ff38
Add Context::new_from_template() (#225) 2020-01-19 21:58:44 +01:00
Ben Noordhuis
2db5e10b9f
Add FunctionTemplate::set_class_name() (#225) 2020-01-19 21:58:35 +01:00
Ben Noordhuis
7b0269b447
Add ObjectTemplate and Template::set() (#225)
The ObjectTemplate type already existed but now it can also be
instantiated.

This commit also adds Template::set() to actually make that useful.
2020-01-19 21:58:20 +01:00
Bert Belder
2a7868daa9
Forgot to delete file (#224) 2020-01-18 15:31:39 +01:00
Bert Belder
6c1d65252a
Add ContextScope and lay foundations for scope inheritance (#223) 2020-01-18 13:41:28 +01:00
Bert Belder
00d8eb8e16
Fix methods that should require '&mut Isolate' but didn't (#222) 2020-01-17 15:40:29 +01:00
Ry Dahl
7a198e0c7e
Reduce nested symbols in API (#220)
- Don't expose empty mod array_buffer_view
- Move v8::platform::new_default_platform() to v8::new_default_platform()
- Move v8::platform::Task to v8::Task
- Move v8::platform::Platform to v8::Platform
2020-01-17 09:26:42 -05:00
Bartek Iwańczuk
bc927c7477 ArrayBuffer::new_backing_store_from_boxed_slice (#202) 2020-01-17 14:41:12 +01:00
Ben Noordhuis
52b8bbaf82 Fix Module::get_module_namespace() doc comment (#219) 2020-01-17 08:01:19 -05:00
Bert Belder
6925e78819
Do not export Isolate::enter() and Isolate::exit() methods (#217) 2020-01-17 08:57:27 +01:00
Bert Belder
fb19eecc31
Rename new_null() to null() and new_undefined() to undefined() (#216)
This is more consistent with V8's C++ API.
2020-01-17 08:34:48 +01:00
Bert Belder
d4cd5d2733
Move error constructors and helper functions under v8::Exception (#215)
* The purpose of this change is to match the C++ API more closely.
* This patch also increases consistency between the 'extern "C"'
  function definitions on the Rust side with those on the C++ side.
* The 'message' parameter (a v8::String) to the various error
  constructors no longer needs to be mutable.
2020-01-17 08:22:16 +01:00
Bert Belder
bed0088550
Make function signature of 'AccessorNameGetterCallback' match C++ (#214) 2020-01-17 07:39:05 +01:00
Bert Belder
7862af65e0
Make Function::call() more efficient and more idiomatic (#213) 2020-01-17 03:59:42 +01:00
Bert Belder
1a65b6cf6b
Format binding.cc (#213) 2020-01-17 03:56:04 +01:00
Bert Belder
b09df9b552
Fix bug in v8::create_message() argument lifetimes (#212) 2020-01-17 02:24:41 +01:00
Bartek Iwańczuk
f650abe44e stub out inspector APIs (#206) 2020-01-16 18:12:25 -05:00
Bert Belder
a230735902
Refactor scopes and callbacks so users don't need to transmute (#183) 2020-01-16 22:48:27 +01:00
Ry Dahl
03cab59c5c
Add Isolate::request_interrupt (#208) 2020-01-15 15:33:47 -05:00
Bert Belder
e6fb4d1a65
Reimplement Module::ResolveCallback ABI fix without global variables (#207) 2020-01-14 21:15:06 +01:00
Bert Belder
bf28a6b2e3
Remove rust-abi wrapper for v8::ResolveCallback (#204)
It will be back, but in a different form.
2020-01-13 06:58:26 +01:00
Ry Dahl
63673c3740
Remove unnecessary derive(Debug) (#195) 2020-01-06 14:57:15 -05:00
Bartek Iwańczuk
bddefbc2b2 Implicitly enter Isolate in v8::error (#191) 2020-01-05 18:07:50 +01:00
Bert Belder
db1c44c9be
Fix: Global::get() now actually creates a new Local handle (#187)
Closes: #182
2020-01-05 06:08:21 +01:00
Bartek Iwańczuk
2aaa62ae41 Add v8::Boolean::new() (#184) 2020-01-05 00:08:27 +01:00
Bert Belder
bd598fe8dc
Improve generated v8::Data type hierarchy and add tests (#180) 2020-01-04 03:27:43 +01:00
Bert Belder
e0b8f2d02c
Fix some issues with v8::StartupData (#178) 2020-01-04 01:26:27 +01:00
Bartek Iwańczuk
2d77996467 add v8::Module::get_module_namespace (#177) 2020-01-03 18:12:45 -05:00
Ry Dahl
19398816ab
SnapshotCreator changes for libdeno (#176) 2020-01-03 16:52:05 -05:00
Ry Dahl
a4f519c643
Add Value::{number_value, integer_value, uint32_value, int32_value}
#174
2020-01-03 12:17:11 -05:00
Ry Dahl
8adf85ea89
add to_uint32, to_int32, to_integer, to_detail_string, to_big_int (#173) 2020-01-03 11:14:50 -05:00
Bartek Iwańczuk
4ffbb7a00b InIsolate for PromiseRejectMessage (#172) 2020-01-03 08:49:43 -05:00
Bert Belder
64136e684e Add safe downcasts for Local<Value> with TryFrom (#166) (#166) 2020-01-03 08:41:16 -05:00
Bartek Iwańczuk
5c9effbeb1 add SharedArrayBuffer deprecated constructor (#171)
needed temporarily for porting deno
2020-01-03 08:40:39 -05:00
Bert Belder
e409030541 Create CallbackScope from Promise and PromiseRejectMessage (#168) 2020-01-02 16:22:33 -05:00
Ry Dahl
45b766c01f
happy new year (#170) 2020-01-02 13:57:00 -05:00
Bartek Iwańczuk
6c5f189063
add Object::get_identity_hash (#169) 2020-01-02 19:56:28 +01:00
Ry Dahl
65f12fbdc0
Add Object::set_accessor (#167) 2020-01-02 12:01:36 -05:00
Bartek Iwańczuk
7b139afbc4 add v8::Array::new() (#165) 2020-01-02 10:41:40 -05:00
Ry Dahl
53fd83a6fa
Add Isolate::RunMicrotasks and Isolate::EnqueueMicrotask (#164) 2020-01-02 10:15:31 -05:00
EnokMan
8d6ad51662 add all value checkers (#163) 2020-01-01 09:56:59 -05:00
Ry Dahl
e501f6d854
Add Value::{ToString, ToNumber, ToObject} (#162) 2019-12-31 15:17:52 -05:00
Ry Dahl
8f9aafe764
add impl_from and impl_deref macros for data.rs (#161) 2019-12-31 13:39:01 -05:00
Bert Belder
c205e73138
Generate Deref implementations for subtypes of v8::Data (#160) 2019-12-31 18:33:45 +01:00
Ry Dahl
1f610ba5a5
Add StackFrame (#159) 2019-12-31 11:17:26 -05:00
Ry Dahl
5467ca9295
Improve v8::Message (#158) 2019-12-31 09:40:34 -05:00
Bartek Iwańczuk
23a49d0fd1 add Isolate::get_current_context() (#155) 2019-12-31 14:07:42 +01:00
Kevin (Kun) "Kassimo" Qian
d31960342f isolate: add termination related methods (#157) 2019-12-31 06:11:43 -05:00
Bert Belder
24286a4d71
Add StartupData constructor (#156) 2019-12-31 02:43:27 +01:00