Update V8 to r3121 as required for WebKit update.
Change-Id: Ic53e0aef9a9eb9b71ee7d25a8aef61520bba899c
diff --git a/src/api.cc b/src/api.cc
index fd3d921..b457aad 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -342,10 +342,10 @@
bool SetResourceConstraints(ResourceConstraints* constraints) {
- int semispace_size = constraints->max_young_space_size();
+ int young_space_size = constraints->max_young_space_size();
int old_gen_size = constraints->max_old_space_size();
- if (semispace_size != 0 || old_gen_size != 0) {
- bool result = i::Heap::ConfigureHeap(semispace_size, old_gen_size);
+ if (young_space_size != 0 || old_gen_size != 0) {
+ bool result = i::Heap::ConfigureHeap(young_space_size / 2, old_gen_size);
if (!result) return false;
}
if (constraints->stack_limit() != NULL) {
@@ -2290,7 +2290,7 @@
ON_BAILOUT("v8::SetElementsToPixelData()", return);
ENTER_V8;
HandleScope scope;
- if (!ApiCheck(i::Smi::IsValid(length),
+ if (!ApiCheck(length <= i::PixelArray::kMaxLength,
"v8::Object::SetIndexedPropertiesToPixelData()",
"length exceeds max acceptable value")) {
return;
@@ -2306,6 +2306,30 @@
}
+void v8::Object::SetIndexedPropertiesToExternalArrayData(
+ void* data,
+ ExternalArrayType array_type,
+ int length) {
+ ON_BAILOUT("v8::SetIndexedPropertiesToExternalArrayData()", return);
+ ENTER_V8;
+ HandleScope scope;
+ if (!ApiCheck(length <= i::ExternalArray::kMaxLength,
+ "v8::Object::SetIndexedPropertiesToExternalArrayData()",
+ "length exceeds max acceptable value")) {
+ return;
+ }
+ i::Handle<i::JSObject> self = Utils::OpenHandle(this);
+ if (!ApiCheck(!self->IsJSArray(),
+ "v8::Object::SetIndexedPropertiesToExternalArrayData()",
+ "JSArray is not supported")) {
+ return;
+ }
+ i::Handle<i::ExternalArray> array =
+ i::Factory::NewExternalArray(length, array_type, data);
+ self->set_elements(*array);
+}
+
+
Local<v8::Object> Function::NewInstance() const {
return NewInstance(0, NULL);
}
@@ -2578,7 +2602,16 @@
void v8::Object::SetPointerInInternalField(int index, void* value) {
- SetInternalField(index, External::Wrap(value));
+ i::Object* as_object = reinterpret_cast<i::Object*>(value);
+ if (as_object->IsSmi()) {
+ Utils::OpenHandle(this)->SetInternalField(index, as_object);
+ return;
+ }
+ HandleScope scope;
+ i::Handle<i::Proxy> proxy =
+ i::Factory::NewProxy(reinterpret_cast<i::Address>(value), i::TENURED);
+ if (!proxy.is_null())
+ Utils::OpenHandle(this)->SetInternalField(index, *proxy);
}
@@ -2602,11 +2635,20 @@
}
-bool v8::V8::IdleNotification(bool is_high_priority) {
+HeapStatistics::HeapStatistics(): total_heap_size_(0), used_heap_size_(0) { }
+
+
+void v8::V8::GetHeapStatistics(HeapStatistics* heap_statistics) {
+ heap_statistics->set_total_heap_size(i::Heap::CommittedMemory());
+ heap_statistics->set_used_heap_size(i::Heap::SizeOfObjects());
+}
+
+
+bool v8::V8::IdleNotification() {
// Returning true tells the caller that it need not
// continue to call IdleNotification.
if (!i::V8::IsRunning()) return true;
- return i::V8::IdleNotification(is_high_priority);
+ return i::V8::IdleNotification();
}
@@ -2760,7 +2802,9 @@
v8::Local<v8::Context> Context::GetCurrent() {
if (IsDeadCheck("v8::Context::GetCurrent()")) return Local<Context>();
- i::Handle<i::Context> context(i::Top::global_context());
+ i::Handle<i::Object> current = i::Top::global_context();
+ if (current.is_null()) return Local<Context>();
+ i::Handle<i::Context> context = i::Handle<i::Context>::cast(current);
return Utils::ToLocal(context);
}
@@ -2837,36 +2881,39 @@
}
-static const intptr_t kAlignedPointerMask = 3;
-
Local<Value> v8::External::Wrap(void* data) {
STATIC_ASSERT(sizeof(data) == sizeof(i::Address));
LOG_API("External::Wrap");
EnsureInitialized("v8::External::Wrap()");
ENTER_V8;
- if ((reinterpret_cast<intptr_t>(data) & kAlignedPointerMask) == 0) {
- uintptr_t data_ptr = reinterpret_cast<uintptr_t>(data);
- intptr_t data_value =
- static_cast<intptr_t>(data_ptr >> i::Internals::kAlignedPointerShift);
- STATIC_ASSERT(sizeof(data_ptr) == sizeof(data_value));
- if (i::Smi::IsIntptrValid(data_value)) {
- i::Handle<i::Object> obj(i::Smi::FromIntptr(data_value));
- return Utils::ToLocal(obj);
- }
+ i::Object* as_object = reinterpret_cast<i::Object*>(data);
+ if (as_object->IsSmi()) {
+ return Utils::ToLocal(i::Handle<i::Object>(as_object));
}
return ExternalNewImpl(data);
}
+void* v8::Object::SlowGetPointerFromInternalField(int index) {
+ i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
+ i::Object* value = obj->GetInternalField(index);
+ if (value->IsSmi()) {
+ return value;
+ } else if (value->IsProxy()) {
+ return reinterpret_cast<void*>(i::Proxy::cast(value)->proxy());
+ } else {
+ return NULL;
+ }
+}
+
+
void* v8::External::FullUnwrap(v8::Handle<v8::Value> wrapper) {
if (IsDeadCheck("v8::External::Unwrap()")) return 0;
i::Handle<i::Object> obj = Utils::OpenHandle(*wrapper);
void* result;
if (obj->IsSmi()) {
// The external value was an aligned pointer.
- uintptr_t value = static_cast<uintptr_t>(
- i::Smi::cast(*obj)->value()) << i::Internals::kAlignedPointerShift;
- result = reinterpret_cast<void*>(value);
+ result = *obj;
} else if (obj->IsProxy()) {
result = ExternalValueImpl(obj);
} else {
@@ -2912,6 +2959,18 @@
}
+Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) {
+ EnsureInitialized("v8::String::New()");
+ LOG_API("String::New(char)");
+ ENTER_V8;
+ i::Handle<i::String> left_string = Utils::OpenHandle(*left);
+ i::Handle<i::String> right_string = Utils::OpenHandle(*right);
+ i::Handle<i::String> result = i::Factory::NewConsString(left_string,
+ right_string);
+ return Utils::ToLocal(result);
+}
+
+
Local<String> v8::String::NewUndetectable(const char* data, int length) {
EnsureInitialized("v8::String::NewUndetectable()");
LOG_API("String::NewUndetectable(char)");
@@ -3215,6 +3274,17 @@
}
+Local<Integer> Integer::NewFromUnsigned(uint32_t value) {
+ bool fits_into_int32_t = (value & (1 << 31)) == 0;
+ if (fits_into_int32_t) {
+ return Integer::New(static_cast<int32_t>(value));
+ }
+ ENTER_V8;
+ i::Handle<i::Object> result = i::Factory::NewNumber(value);
+ return Utils::IntegerToLocal(result);
+}
+
+
void V8::IgnoreOutOfMemoryException() {
thread_local.set_ignore_out_of_memory(true);
}