Revert r14310 due to isolate tests failure.

R=mstarzinger@chromium.org
BUG=

Review URL: https://chromiumcodereview.appspot.com/14021004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14334 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
yangguo@chromium.org 2013-04-18 14:41:24 +00:00
parent ecbbf528c0
commit 72a05845ec
5 changed files with 78 additions and 353 deletions

354
src/d8.cc
View File

@ -83,7 +83,7 @@ const char kArrayBufferMarkerPropName[] = "d8::_is_array_buffer_";
const char kArrayMarkerPropName[] = "d8::_is_typed_array_";
#define FOR_EACH_STRING(V) \
#define FOR_EACH_SYMBOL(V) \
V(ArrayBuffer, "ArrayBuffer") \
V(ArrayBufferMarkerPropName, kArrayBufferMarkerPropName) \
V(ArrayMarkerPropName, kArrayMarkerPropName) \
@ -94,50 +94,36 @@ const char kArrayMarkerPropName[] = "d8::_is_typed_array_";
V(length, "length")
class PerIsolateData {
class Symbols {
public:
explicit PerIsolateData(Isolate* isolate) : isolate_(isolate), realms_(NULL) {
explicit Symbols(Isolate* isolate) : isolate_(isolate) {
HandleScope scope(isolate);
#define INIT_STRING(name, value) \
name##_string_ = Persistent<String>::New(isolate, String::NewSymbol(value));
FOR_EACH_STRING(INIT_STRING)
#undef INIT_STRING
#define INIT_SYMBOL(name, value) \
name##_ = Persistent<String>::New(isolate, String::NewSymbol(value));
FOR_EACH_SYMBOL(INIT_SYMBOL)
#undef INIT_SYMBOL
isolate->SetData(this);
}
~PerIsolateData() {
#define DISPOSE_STRING(name, value) name##_string_.Dispose(isolate_);
FOR_EACH_STRING(DISPOSE_STRING)
#undef DISPOSE_STRING
~Symbols() {
#define DISPOSE_SYMBOL(name, value) name##_.Dispose(isolate_);
FOR_EACH_SYMBOL(DISPOSE_SYMBOL)
#undef DISPOSE_SYMBOL
isolate_->SetData(NULL); // Not really needed, just to be sure...
}
inline static PerIsolateData* Get(Isolate* isolate) {
return reinterpret_cast<PerIsolateData*>(isolate->GetData());
#define DEFINE_SYMBOL_GETTER(name, value) \
static Persistent<String> name(Isolate* isolate) { \
return reinterpret_cast<Symbols*>(isolate->GetData())->name##_; \
}
#define DEFINE_STRING_GETTER(name, value) \
static Persistent<String> name##_string(Isolate* isolate) { \
return Get(isolate)->name##_string_; \
}
FOR_EACH_STRING(DEFINE_STRING_GETTER)
#undef DEFINE_STRING_GETTER
FOR_EACH_SYMBOL(DEFINE_SYMBOL_GETTER)
#undef DEFINE_SYMBOL_GETTER
private:
friend class Shell;
Isolate* isolate_;
int realm_count_;
int realm_current_;
int realm_switch_;
Persistent<Context>* realms_;
Persistent<Value> realm_shared_;
#define DEFINE_MEMBER(name, value) Persistent<String> name##_string_;
FOR_EACH_STRING(DEFINE_MEMBER)
#define DEFINE_MEMBER(name, value) Persistent<String> name##_;
FOR_EACH_SYMBOL(DEFINE_MEMBER)
#undef DEFINE_MEMBER
void RealmInit();
int RealmFind(Handle<Context> context);
};
@ -221,20 +207,14 @@ bool Shell::ExecuteString(Isolate* isolate,
// When debugging make exceptions appear to be uncaught.
try_catch.SetVerbose(true);
}
Handle<Script> script = Script::New(source, name);
Handle<Script> script = Script::Compile(source, name);
if (script.IsEmpty()) {
// Print errors that happened during compilation.
if (report_exceptions && !FLAG_debugger)
ReportException(isolate, &try_catch);
return false;
} else {
PerIsolateData* data = PerIsolateData::Get(isolate);
Local<Context> realm =
Local<Context>::New(data->realms_[data->realm_current_]);
realm->Enter();
Handle<Value> result = script->Run();
realm->Exit();
data->realm_current_ = data->realm_switch_;
if (result.IsEmpty()) {
ASSERT(try_catch.HasCaught());
// Print errors that happened during execution.
@ -275,159 +255,6 @@ bool Shell::ExecuteString(Isolate* isolate,
}
void PerIsolateData::RealmInit() {
if (realms_ != NULL) {
// Drop realms from previous run.
for (int i = 0; i < realm_count_; ++i) realms_[i].Dispose(isolate_);
delete[] realms_;
if (!realm_shared_.IsEmpty()) realm_shared_.Dispose(isolate_);
}
realm_count_ = 1;
realm_current_ = 0;
realm_switch_ = 0;
realms_ = new Persistent<Context>[1];
realms_[0] = Persistent<Context>::New(isolate_, Context::GetEntered());
realm_shared_.Clear();
}
int PerIsolateData::RealmFind(Handle<Context> context) {
for (int i = 0; i < realm_count_; ++i) {
if (realms_[i] == context) return i;
}
return -1;
}
// Realm.current() returns the index of the currently active realm.
Handle<Value> Shell::RealmCurrent(const Arguments& args) {
Isolate* isolate = args.GetIsolate();
PerIsolateData* data = PerIsolateData::Get(isolate);
int index = data->RealmFind(Context::GetEntered());
if (index == -1) return Undefined(isolate);
return Number::New(index);
}
// Realm.owner(o) returns the index of the realm that created o.
Handle<Value> Shell::RealmOwner(const Arguments& args) {
Isolate* isolate = args.GetIsolate();
PerIsolateData* data = PerIsolateData::Get(isolate);
if (args.Length() < 1 || !args[0]->IsObject()) {
return Throw("Invalid argument");
}
int index = data->RealmFind(args[0]->ToObject()->CreationContext());
if (index == -1) return Undefined(isolate);
return Number::New(index);
}
// Realm.global(i) returns the global object of realm i.
// (Note that properties of global objects cannot be read/written cross-realm.)
Handle<Value> Shell::RealmGlobal(const Arguments& args) {
PerIsolateData* data = PerIsolateData::Get(args.GetIsolate());
if (args.Length() < 1 || !args[0]->IsNumber()) {
return Throw("Invalid argument");
}
int index = args[0]->Uint32Value();
if (index >= data->realm_count_ || data->realms_[index].IsEmpty()) {
return Throw("Invalid realm index");
}
return data->realms_[index]->Global();
}
// Realm.create() creates a new realm and returns its index.
Handle<Value> Shell::RealmCreate(const Arguments& args) {
Isolate* isolate = args.GetIsolate();
PerIsolateData* data = PerIsolateData::Get(isolate);
Persistent<Context>* old_realms = data->realms_;
int index = data->realm_count_;
data->realms_ = new Persistent<Context>[++data->realm_count_];
for (int i = 0; i < index; ++i) data->realms_[i] = old_realms[i];
delete[] old_realms;
Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate);
data->realms_[index] = Persistent<Context>::New(
isolate, Context::New(isolate, NULL, global_template));
return Number::New(index);
}
// Realm.dispose(i) disposes the reference to the realm i.
Handle<Value> Shell::RealmDispose(const Arguments& args) {
Isolate* isolate = args.GetIsolate();
PerIsolateData* data = PerIsolateData::Get(isolate);
if (args.Length() < 1 || !args[0]->IsNumber()) {
return Throw("Invalid argument");
}
int index = args[0]->Uint32Value();
if (index >= data->realm_count_ || data->realms_[index].IsEmpty() ||
index == 0 ||
index == data->realm_current_ || index == data->realm_switch_) {
return Throw("Invalid realm index");
}
data->realms_[index].Dispose(isolate);
data->realms_[index].Clear();
return Undefined(isolate);
}
// Realm.switch(i) switches to the realm i for consecutive interactive inputs.
Handle<Value> Shell::RealmSwitch(const Arguments& args) {
Isolate* isolate = args.GetIsolate();
PerIsolateData* data = PerIsolateData::Get(isolate);
if (args.Length() < 1 || !args[0]->IsNumber()) {
return Throw("Invalid argument");
}
int index = args[0]->Uint32Value();
if (index >= data->realm_count_ || data->realms_[index].IsEmpty()) {
return Throw("Invalid realm index");
}
data->realm_switch_ = index;
return Undefined(isolate);
}
// Realm.eval(i, s) evaluates s in realm i and returns the result.
Handle<Value> Shell::RealmEval(const Arguments& args) {
Isolate* isolate = args.GetIsolate();
PerIsolateData* data = PerIsolateData::Get(isolate);
if (args.Length() < 2 || !args[0]->IsNumber() || !args[1]->IsString()) {
return Throw("Invalid argument");
}
int index = args[0]->Uint32Value();
if (index >= data->realm_count_ || data->realms_[index].IsEmpty()) {
return Throw("Invalid realm index");
}
Handle<Script> script = Script::New(args[1]->ToString());
if (script.IsEmpty()) return Undefined(isolate);
Local<Context> realm = Local<Context>::New(data->realms_[index]);
realm->Enter();
Handle<Value> result = script->Run();
realm->Exit();
return result;
}
// Realm.shared is an accessor for a single shared value across realms.
Handle<Value> Shell::RealmSharedGet(Local<String> property,
const AccessorInfo& info) {
Isolate* isolate = info.GetIsolate();
PerIsolateData* data = PerIsolateData::Get(isolate);
if (data->realm_shared_.IsEmpty()) return Undefined(isolate);
return data->realm_shared_;
}
void Shell::RealmSharedSet(Local<String> property,
Local<Value> value,
const AccessorInfo& info) {
Isolate* isolate = info.GetIsolate();
PerIsolateData* data = PerIsolateData::Get(isolate);
if (!data->realm_shared_.IsEmpty()) data->realm_shared_.Dispose(isolate);
data->realm_shared_ = Persistent<Value>::New(isolate, value);
}
Handle<Value> Shell::Print(const Arguments& args) {
Handle<Value> val = Write(args);
printf("\n");
@ -589,8 +416,7 @@ Handle<Value> Shell::CreateExternalArrayBuffer(Isolate* isolate,
}
memset(data, 0, length);
buffer->SetHiddenValue(
PerIsolateData::ArrayBufferMarkerPropName_string(isolate), True());
buffer->SetHiddenValue(Symbols::ArrayBufferMarkerPropName(isolate), True());
Persistent<Object> persistent_array =
Persistent<Object>::New(isolate, buffer);
persistent_array.MakeWeak(isolate, data, ExternalArrayWeakCallback);
@ -599,7 +425,7 @@ Handle<Value> Shell::CreateExternalArrayBuffer(Isolate* isolate,
buffer->SetIndexedPropertiesToExternalArrayData(
data, v8::kExternalByteArray, length);
buffer->Set(PerIsolateData::byteLength_string(isolate),
buffer->Set(Symbols::byteLength(isolate),
Int32::New(length, isolate),
ReadOnly);
@ -644,20 +470,20 @@ Handle<Object> Shell::CreateExternalArray(Isolate* isolate,
array->SetIndexedPropertiesToExternalArrayData(
static_cast<uint8_t*>(data) + byteOffset, type, length);
array->SetHiddenValue(PerIsolateData::ArrayMarkerPropName_string(isolate),
array->SetHiddenValue(Symbols::ArrayMarkerPropName(isolate),
Int32::New(type, isolate));
array->Set(PerIsolateData::byteLength_string(isolate),
array->Set(Symbols::byteLength(isolate),
Int32::New(byteLength, isolate),
ReadOnly);
array->Set(PerIsolateData::byteOffset_string(isolate),
array->Set(Symbols::byteOffset(isolate),
Int32::New(byteOffset, isolate),
ReadOnly);
array->Set(PerIsolateData::length_string(isolate),
array->Set(Symbols::length(isolate),
Int32::New(length, isolate),
ReadOnly);
array->Set(PerIsolateData::BYTES_PER_ELEMENT_string(isolate),
array->Set(Symbols::BYTES_PER_ELEMENT(isolate),
Int32::New(element_size, isolate));
array->Set(PerIsolateData::buffer_string(isolate),
array->Set(Symbols::buffer(isolate),
buffer,
ReadOnly);
@ -698,11 +524,11 @@ Handle<Value> Shell::CreateExternalArray(const Arguments& args,
}
if (args[0]->IsObject() &&
!args[0]->ToObject()->GetHiddenValue(
PerIsolateData::ArrayBufferMarkerPropName_string(isolate)).IsEmpty()) {
Symbols::ArrayBufferMarkerPropName(isolate)).IsEmpty()) {
// Construct from ArrayBuffer.
buffer = args[0]->ToObject();
int32_t bufferLength = convertToUint(
buffer->Get(PerIsolateData::byteLength_string(isolate)), &try_catch);
int32_t bufferLength =
convertToUint(buffer->Get(Symbols::byteLength(isolate)), &try_catch);
if (try_catch.HasCaught()) return try_catch.ReThrow();
if (args.Length() < 2 || args[1]->IsUndefined()) {
@ -734,10 +560,9 @@ Handle<Value> Shell::CreateExternalArray(const Arguments& args,
}
} else {
if (args[0]->IsObject() &&
args[0]->ToObject()->Has(PerIsolateData::length_string(isolate))) {
args[0]->ToObject()->Has(Symbols::length(isolate))) {
// Construct from array.
Local<Value> value =
args[0]->ToObject()->Get(PerIsolateData::length_string(isolate));
Local<Value> value = args[0]->ToObject()->Get(Symbols::length(isolate));
if (try_catch.HasCaught()) return try_catch.ReThrow();
length = convertToUint(value, &try_catch);
if (try_catch.HasCaught()) return try_catch.ReThrow();
@ -751,8 +576,7 @@ Handle<Value> Shell::CreateExternalArray(const Arguments& args,
byteOffset = 0;
Handle<Object> global = Context::GetCurrent()->Global();
Handle<Value> array_buffer =
global->Get(PerIsolateData::ArrayBuffer_string(isolate));
Handle<Value> array_buffer = global->Get(Symbols::ArrayBuffer(isolate));
ASSERT(!try_catch.HasCaught() && array_buffer->IsFunction());
Handle<Value> buffer_args[] = { Uint32::New(byteLength, isolate) };
Handle<Value> result = Handle<Function>::Cast(array_buffer)->NewInstance(
@ -787,14 +611,14 @@ Handle<Value> Shell::ArrayBufferSlice(const Arguments& args) {
Isolate* isolate = args.GetIsolate();
Local<Object> self = args.This();
Local<Value> marker = self->GetHiddenValue(
PerIsolateData::ArrayBufferMarkerPropName_string(isolate));
Local<Value> marker =
self->GetHiddenValue(Symbols::ArrayBufferMarkerPropName(isolate));
if (marker.IsEmpty()) {
return Throw("'slice' invoked on wrong receiver type");
}
int32_t length = convertToUint(
self->Get(PerIsolateData::byteLength_string(isolate)), &try_catch);
int32_t length =
convertToUint(self->Get(Symbols::byteLength(isolate)), &try_catch);
if (try_catch.HasCaught()) return try_catch.ReThrow();
if (args.Length() == 0) {
@ -843,22 +667,21 @@ Handle<Value> Shell::ArraySubArray(const Arguments& args) {
Isolate* isolate = args.GetIsolate();
Local<Object> self = args.This();
Local<Value> marker =
self->GetHiddenValue(PerIsolateData::ArrayMarkerPropName_string(isolate));
self->GetHiddenValue(Symbols::ArrayMarkerPropName(isolate));
if (marker.IsEmpty()) {
return Throw("'subarray' invoked on wrong receiver type");
}
Handle<Object> buffer =
self->Get(PerIsolateData::buffer_string(isolate))->ToObject();
Handle<Object> buffer = self->Get(Symbols::buffer(isolate))->ToObject();
if (try_catch.HasCaught()) return try_catch.ReThrow();
int32_t length = convertToUint(
self->Get(PerIsolateData::length_string(isolate)), &try_catch);
int32_t length =
convertToUint(self->Get(Symbols::length(isolate)), &try_catch);
if (try_catch.HasCaught()) return try_catch.ReThrow();
int32_t byteOffset = convertToUint(
self->Get(PerIsolateData::byteOffset_string(isolate)), &try_catch);
int32_t byteOffset =
convertToUint(self->Get(Symbols::byteOffset(isolate)), &try_catch);
if (try_catch.HasCaught()) return try_catch.ReThrow();
int32_t element_size = convertToUint(
self->Get(PerIsolateData::BYTES_PER_ELEMENT_string(isolate)), &try_catch);
int32_t element_size =
convertToUint(self->Get(Symbols::BYTES_PER_ELEMENT(isolate)), &try_catch);
if (try_catch.HasCaught()) return try_catch.ReThrow();
if (args.Length() == 0) {
@ -903,27 +726,27 @@ Handle<Value> Shell::ArraySet(const Arguments& args) {
Isolate* isolate = args.GetIsolate();
Local<Object> self = args.This();
Local<Value> marker =
self->GetHiddenValue(PerIsolateData::ArrayMarkerPropName_string(isolate));
self->GetHiddenValue(Symbols::ArrayMarkerPropName(isolate));
if (marker.IsEmpty()) {
return Throw("'set' invoked on wrong receiver type");
}
int32_t length = convertToUint(
self->Get(PerIsolateData::length_string(isolate)), &try_catch);
int32_t length =
convertToUint(self->Get(Symbols::length(isolate)), &try_catch);
if (try_catch.HasCaught()) return try_catch.ReThrow();
int32_t element_size = convertToUint(
self->Get(PerIsolateData::BYTES_PER_ELEMENT_string(isolate)), &try_catch);
int32_t element_size =
convertToUint(self->Get(Symbols::BYTES_PER_ELEMENT(isolate)), &try_catch);
if (try_catch.HasCaught()) return try_catch.ReThrow();
if (args.Length() == 0) {
return Throw("'set' must have at least one argument");
}
if (!args[0]->IsObject() ||
!args[0]->ToObject()->Has(PerIsolateData::length_string(isolate))) {
!args[0]->ToObject()->Has(Symbols::length(isolate))) {
return Throw("'set' invoked with non-array argument");
}
Handle<Object> source = args[0]->ToObject();
int32_t source_length = convertToUint(
source->Get(PerIsolateData::length_string(isolate)), &try_catch);
int32_t source_length =
convertToUint(source->Get(Symbols::length(isolate)), &try_catch);
if (try_catch.HasCaught()) return try_catch.ReThrow();
int32_t offset;
@ -938,30 +761,28 @@ Handle<Value> Shell::ArraySet(const Arguments& args) {
}
int32_t source_element_size;
if (source->GetHiddenValue(
PerIsolateData::ArrayMarkerPropName_string(isolate)).IsEmpty()) {
if (source->GetHiddenValue(Symbols::ArrayMarkerPropName(isolate)).IsEmpty()) {
source_element_size = 0;
} else {
source_element_size = convertToUint(
source->Get(PerIsolateData::BYTES_PER_ELEMENT_string(isolate)),
&try_catch);
source_element_size =
convertToUint(source->Get(Symbols::BYTES_PER_ELEMENT(isolate)),
&try_catch);
if (try_catch.HasCaught()) return try_catch.ReThrow();
}
if (element_size == source_element_size &&
self->GetConstructor()->StrictEquals(source->GetConstructor())) {
// Use memmove on the array buffers.
Handle<Object> buffer =
self->Get(PerIsolateData::buffer_string(isolate))->ToObject();
Handle<Object> buffer = self->Get(Symbols::buffer(isolate))->ToObject();
if (try_catch.HasCaught()) return try_catch.ReThrow();
Handle<Object> source_buffer =
source->Get(PerIsolateData::buffer_string(isolate))->ToObject();
source->Get(Symbols::buffer(isolate))->ToObject();
if (try_catch.HasCaught()) return try_catch.ReThrow();
int32_t byteOffset = convertToUint(
self->Get(PerIsolateData::byteOffset_string(isolate)), &try_catch);
int32_t byteOffset =
convertToUint(self->Get(Symbols::byteOffset(isolate)), &try_catch);
if (try_catch.HasCaught()) return try_catch.ReThrow();
int32_t source_byteOffset = convertToUint(
source->Get(PerIsolateData::byteOffset_string(isolate)), &try_catch);
int32_t source_byteOffset =
convertToUint(source->Get(Symbols::byteOffset(isolate)), &try_catch);
if (try_catch.HasCaught()) return try_catch.ReThrow();
uint8_t* dest = byteOffset + offset * element_size + static_cast<uint8_t*>(
@ -977,22 +798,21 @@ Handle<Value> Shell::ArraySet(const Arguments& args) {
}
} else {
// Need to copy element-wise to make the right conversions.
Handle<Object> buffer =
self->Get(PerIsolateData::buffer_string(isolate))->ToObject();
Handle<Object> buffer = self->Get(Symbols::buffer(isolate))->ToObject();
if (try_catch.HasCaught()) return try_catch.ReThrow();
Handle<Object> source_buffer =
source->Get(PerIsolateData::buffer_string(isolate))->ToObject();
source->Get(Symbols::buffer(isolate))->ToObject();
if (try_catch.HasCaught()) return try_catch.ReThrow();
if (buffer->StrictEquals(source_buffer)) {
// Same backing store, need to handle overlap correctly.
// This gets a bit tricky in the case of different element sizes
// (which, of course, is extremely unlikely to ever occur in practice).
int32_t byteOffset = convertToUint(
self->Get(PerIsolateData::byteOffset_string(isolate)), &try_catch);
int32_t byteOffset =
convertToUint(self->Get(Symbols::byteOffset(isolate)), &try_catch);
if (try_catch.HasCaught()) return try_catch.ReThrow();
int32_t source_byteOffset = convertToUint(
source->Get(PerIsolateData::byteOffset_string(isolate)), &try_catch);
int32_t source_byteOffset =
convertToUint(source->Get(Symbols::byteOffset(isolate)), &try_catch);
if (try_catch.HasCaught()) return try_catch.ReThrow();
// Copy as much as we can from left to right.
@ -1040,8 +860,8 @@ void Shell::ExternalArrayWeakCallback(v8::Isolate* isolate,
Persistent<Value> object,
void* data) {
HandleScope scope(isolate);
int32_t length = object->ToObject()->Get(
PerIsolateData::byteLength_string(isolate))->Uint32Value();
int32_t length =
object->ToObject()->Get(Symbols::byteLength(isolate))->Uint32Value();
isolate->AdjustAmountOfExternalAllocatedMemory(-length);
delete[] static_cast<uint8_t*>(data);
object.Dispose(isolate);
@ -1418,30 +1238,10 @@ Handle<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
global_template->Set(String::New("disableProfiler"),
FunctionTemplate::New(DisableProfiler));
// Bind the Realm object.
Handle<ObjectTemplate> realm_template = ObjectTemplate::New();
realm_template->Set(String::New("current"),
FunctionTemplate::New(RealmCurrent));
realm_template->Set(String::New("owner"),
FunctionTemplate::New(RealmOwner));
realm_template->Set(String::New("global"),
FunctionTemplate::New(RealmGlobal));
realm_template->Set(String::New("create"),
FunctionTemplate::New(RealmCreate));
realm_template->Set(String::New("dispose"),
FunctionTemplate::New(RealmDispose));
realm_template->Set(String::New("switch"),
FunctionTemplate::New(RealmSwitch));
realm_template->Set(String::New("eval"),
FunctionTemplate::New(RealmEval));
realm_template->SetAccessor(String::New("shared"),
RealmSharedGet, RealmSharedSet);
global_template->Set(String::New("Realm"), realm_template);
// Bind the handlers for external arrays.
PropertyAttribute attr =
static_cast<PropertyAttribute>(ReadOnly | DontDelete);
global_template->Set(PerIsolateData::ArrayBuffer_string(isolate),
global_template->Set(Symbols::ArrayBuffer(isolate),
CreateArrayBufferTemplate(ArrayBuffer), attr);
global_template->Set(String::New("Int8Array"),
CreateArrayTemplate(Int8Array), attr);
@ -1525,7 +1325,6 @@ Persistent<Context> Shell::CreateEvaluationContext(Isolate* isolate) {
Persistent<Context> context = Context::New(NULL, global_template);
ASSERT(!context.IsEmpty());
Context::Scope scope(context);
PerIsolateData::Get(isolate)->RealmInit();
#ifndef V8_SHARED
i::JSArguments js_args = i::FLAG_js_arguments;
@ -1670,8 +1469,7 @@ Handle<Value> Shell::ReadBuffer(const Arguments& args) {
}
Isolate* isolate = args.GetIsolate();
Handle<Object> buffer = Object::New();
buffer->SetHiddenValue(
PerIsolateData::ArrayBufferMarkerPropName_string(isolate), True());
buffer->SetHiddenValue(Symbols::ArrayBufferMarkerPropName(isolate), True());
Persistent<Object> persistent_buffer =
Persistent<Object>::New(isolate, buffer);
persistent_buffer.MakeWeak(isolate, data, ExternalArrayWeakCallback);
@ -1680,7 +1478,7 @@ Handle<Value> Shell::ReadBuffer(const Arguments& args) {
buffer->SetIndexedPropertiesToExternalArrayData(
data, kExternalUnsignedByteArray, length);
buffer->Set(PerIsolateData::byteLength_string(isolate),
buffer->Set(Symbols::byteLength(isolate),
Int32::New(static_cast<int32_t>(length), isolate), ReadOnly);
return buffer;
}
@ -1873,7 +1671,7 @@ void SourceGroup::ExecuteInThread() {
Isolate::Scope iscope(isolate);
Locker lock(isolate);
HandleScope scope(isolate);
PerIsolateData data(isolate);
Symbols symbols(isolate);
Persistent<Context> context = Shell::CreateEvaluationContext(isolate);
{
Context::Scope cscope(context);
@ -2135,7 +1933,7 @@ int Shell::Main(int argc, char* argv[]) {
#ifdef ENABLE_VTUNE_JIT_INTERFACE
vTune::InitilizeVtuneForV8();
#endif
PerIsolateData data(isolate);
Symbols symbols(isolate);
InitializeDebugger(isolate);
if (options.stress_opt || options.stress_deopt) {

View File

@ -298,19 +298,6 @@ class Shell : public i::AllStatic {
#endif // ENABLE_DEBUGGER_SUPPORT
#endif // V8_SHARED
static Handle<Value> RealmCurrent(const Arguments& args);
static Handle<Value> RealmOwner(const Arguments& args);
static Handle<Value> RealmGlobal(const Arguments& args);
static Handle<Value> RealmCreate(const Arguments& args);
static Handle<Value> RealmDispose(const Arguments& args);
static Handle<Value> RealmSwitch(const Arguments& args);
static Handle<Value> RealmEval(const Arguments& args);
static Handle<Value> RealmSharedGet(Local<String> property,
const AccessorInfo& info);
static void RealmSharedSet(Local<String> property,
Local<Value> value,
const AccessorInfo& info);
static Handle<Value> Print(const Arguments& args);
static Handle<Value> Write(const Arguments& args);
static Handle<Value> Quit(const Arguments& args);

View File

@ -612,6 +612,7 @@ void ScriptCache::Add(Handle<Script> script) {
ASSERT(*script == *reinterpret_cast<Script**>(entry->value));
return;
}
// Globalize the script object, make it weak and use the location of the
// global handle as the value in the hash map.
Handle<Script> script_ =

View File

@ -8554,7 +8554,7 @@ class JSWeakMap: public JSObject {
class JSArrayBuffer: public JSObject {
public:
// [backing_store]: backing memory for this array
// [backing_store]: backing memory for thsi array
DECL_ACCESSORS(backing_store, void)
// [byte_length]: length in bytes

View File

@ -1,61 +0,0 @@
// Copyright 2013 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
var realmA = Realm.current();
var realmB = Realm.create();
assertEquals(0, realmA);
assertEquals(1, realmB);
// The global objects match the realms' this binding.
assertSame(this, Realm.global(realmA));
assertSame(Realm.eval(realmB, "this"), Realm.global(realmB));
assertFalse(this === Realm.global(realmB));
// The global object is not accessible cross-realm.
var x = 3;
Realm.shared = this;
assertThrows("Realm.eval(realmB, 'x')");
assertSame(undefined, Realm.eval(realmB, "this.x"));
assertSame(undefined, Realm.eval(realmB, "Realm.shared.x"));
Realm.eval(realmB, "Realm.global(0).y = 1");
assertThrows("y");
assertSame(undefined, this.y);
// Can get or set other objects' properties cross-realm.
var p = {a: 1};
var o = {__proto__: p, b: 2};
Realm.shared = o;
assertSame(1, Realm.eval(realmB, "Realm.shared.a"));
assertSame(2, Realm.eval(realmB, "Realm.shared.b"));
// Cannot get or set a prototype cross-realm.
assertSame(undefined, Realm.eval(realmB, "Realm.shared.__proto__"));
Realm.eval(realmB, "Realm.shared.__proto__ = {c: 3}");
assertSame(1, o.a);
assertSame(undefined, o.c);