Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Runtime::new safe #267

Merged
merged 2 commits into from May 30, 2016
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

Remove dead code

  • Loading branch information
nox committed May 30, 2016
commit a301cffc5f2fb7c33ba03d52cdb6b9869881995e
@@ -39,7 +39,7 @@ use jsval::{BooleanValue, Int32Value, NullValue, UInt32Value, UndefinedValue};
use jsval::{JSVal, ObjectValue, ObjectOrNullValue, StringValue};
use rust::{ToBoolean, ToNumber, ToUint16, ToInt32, ToUint32, ToInt64, ToUint64, ToString};
use libc;
use num_traits::{Bounded, Float, Zero};
use num_traits::{Bounded, Zero};
use std::rc::Rc;
use std::{ptr, slice};

@@ -3,7 +3,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */


use jsapi::{__BindgenUnionField, JSObject, JSString, TraceKind};
use jsapi::{JSObject, JSString, TraceKind};
use jsapi::Value;
use jsapi::jsval_layout;
use jsapi::JSValueType;
@@ -24,10 +24,10 @@ use jsapi::{JSContext, JSRuntime, JSObject, JSFlatString, JSFunction, JSString,
use jsapi::{RuntimeOptionsRef, ContextOptionsRef, ReadOnlyCompileOptions};
use jsapi::{JS_SetErrorReporter, Evaluate2, JSErrorReport};
use jsapi::{JS_SetGCParameter, JSGCParamKey};
use jsapi::{JSWhyMagic, Heap, Cell, HeapObjectPostBarrier, HeapValuePostBarrier};
use jsapi::{Heap, HeapObjectPostBarrier, HeapValuePostBarrier};
use jsapi::{ContextFriendFields};
use jsapi::{CustomAutoRooter, AutoGCRooter, _vftable_CustomAutoRooter, AutoGCRooter_jspubtd_h_unnamed_1};
use jsapi::{Rooted, RootedValue, Handle, MutableHandle, MutableHandleBase, RootedBase};
use jsapi::{Rooted, Handle, MutableHandle, MutableHandleBase, RootedBase};
use jsapi::{MutableHandleValue, HandleValue, HandleObject, HandleBase};
use jsapi::AutoObjectVector;
use jsapi::{ToBooleanSlow, ToNumberSlow, ToStringSlow};
@@ -456,30 +456,10 @@ impl Default for CompartmentOptions {

const ChunkShift: usize = 20;
const ChunkSize: usize = 1 << ChunkShift;
const ChunkMask: usize = ChunkSize - 1;

#[cfg(target_pointer_width = "32")]
const ChunkLocationOffset: usize = ChunkSize - 2 * 4 - 8;

#[cfg(target_pointer_width = "64")]
const ChunkLocationOffset: usize = ChunkSize - 2 * 8 - 8;

const ChunkLocationBitNursery: usize = 1;

fn IsInsideNursery(p: *mut Cell) -> bool {
if p.is_null() {
return false;
}

let mut addr: usize = unsafe { mem::transmute(p) };
addr = (addr & !ChunkMask) | ChunkLocationOffset;

let location: *const u32 = unsafe { mem::transmute(addr) };
let location = unsafe { *location };
assert!(location != 0);
(location & ChunkLocationBitNursery as u32) != 0
}

pub trait GCMethods<T> {
unsafe fn initial() -> T;
unsafe fn is_dropped(self) -> bool;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.