Revision: 11566
Author: [email protected]
Date: Tue May 15 05:16:38 2012
Log: Version 3.11.1
Added a readbuffer function to d8 that reads a file into an ArrayBuffer.
Fix freebsd build. (V8 issue 2126)
Performance and stability improvements on all platforms.
http://code.google.com/p/v8/source/detail?r=11566
Modified:
/trunk/ChangeLog
/trunk/src/d8.cc
/trunk/src/d8.h
/trunk/src/flag-definitions.h
/trunk/src/heap.cc
/trunk/src/platform-freebsd.cc
/trunk/src/platform-linux.cc
/trunk/src/profile-generator.cc
/trunk/src/version.cc
/trunk/tools/grokdump.py
=======================================
--- /trunk/ChangeLog Fri May 11 08:02:09 2012
+++ /trunk/ChangeLog Tue May 15 05:16:38 2012
@@ -1,3 +1,12 @@
+2012-05-15: Version 3.11.1
+
+ Added a readbuffer function to d8 that reads a file into an
ArrayBuffer.
+
+ Fix freebsd build. (V8 issue 2126)
+
+ Performance and stability improvements on all platforms.
+
+
2012-05-11: Version 3.11.0
Fixed compose-discard crasher from r11524 (issue 2123).
=======================================
--- /trunk/src/d8.cc Fri Apr 13 02:58:30 2012
+++ /trunk/src/d8.cc Tue May 15 05:16:38 2012
@@ -315,8 +315,8 @@
}
-const char kArrayBufferReferencePropName[] = "_is_array_buffer_";
-const char kArrayBufferMarkerPropName[] = "_array_buffer_ref_";
+const char kArrayBufferMarkerPropName[] = "_is_array_buffer_";
+const char kArrayBufferReferencePropName[] = "_array_buffer_ref_";
static const int kExternalArrayAllocationHeaderSize = 2;
@@ -353,10 +353,11 @@
Local<Value> length_value = (args.Length() < 3)
? (first_arg_is_array_buffer
- ? args[0]->ToObject()->Get(String::New("length"))
+ ? args[0]->ToObject()->Get(String::New("byteLength"))
: args[0])
: args[2];
- size_t length = convertToUint(length_value, &try_catch);
+ size_t byteLength = convertToUint(length_value, &try_catch);
+ size_t length = byteLength;
if (try_catch.HasCaught()) return try_catch.Exception();
void* data = NULL;
@@ -368,7 +369,7 @@
data = derived_from->GetIndexedPropertiesExternalArrayData();
size_t array_buffer_length = convertToUint(
- derived_from->Get(String::New("length")),
+ derived_from->Get(String::New("byteLength")),
&try_catch);
if (try_catch.HasCaught()) return try_catch.Exception();
@@ -451,10 +452,20 @@
array->SetIndexedPropertiesToExternalArrayData(
reinterpret_cast<uint8_t*>(data) + offset, type,
static_cast<int>(length));
- array->Set(String::New("length"),
- Int32::New(static_cast<int32_t>(length)), ReadOnly);
- array->Set(String::New("BYTES_PER_ELEMENT"),
- Int32::New(static_cast<int32_t>(element_size)));
+ array->Set(String::New("byteLength"),
+ Int32::New(static_cast<int32_t>(byteLength)), ReadOnly);
+ if (!is_array_buffer_construct) {
+ array->Set(String::New("length"),
+ Int32::New(static_cast<int32_t>(length)), ReadOnly);
+ array->Set(String::New("byteOffset"),
+ Int32::New(static_cast<int32_t>(offset)), ReadOnly);
+ array->Set(String::New("BYTES_PER_ELEMENT"),
+ Int32::New(static_cast<int32_t>(element_size)));
+ // We currently support 'buffer' property only if constructed from a
buffer.
+ if (first_arg_is_array_buffer) {
+ array->Set(String::New("buffer"), args[0], ReadOnly);
+ }
+ }
return array;
}
@@ -824,6 +835,8 @@
global_template->Set(String::New("read"), FunctionTemplate::New(Read));
global_template->Set(String::New("readbinary"),
FunctionTemplate::New(ReadBinary));
+ global_template->Set(String::New("readbuffer"),
+ FunctionTemplate::New(ReadBuffer));
global_template->Set(String::New("readline"),
FunctionTemplate::New(ReadLine));
global_template->Set(String::New("load"), FunctionTemplate::New(Load));
@@ -1057,6 +1070,32 @@
BinaryResource* resource = new BinaryResource(chars, size);
return String::NewExternal(resource);
}
+
+
+Handle<Value> Shell::ReadBuffer(const Arguments& args) {
+ String::Utf8Value filename(args[0]);
+ int length;
+ if (*filename == NULL) {
+ return ThrowException(String::New("Error loading file"));
+ }
+ char* data = ReadChars(*filename, &length);
+ if (data == NULL) {
+ return ThrowException(String::New("Error reading file"));
+ }
+
+ Handle<Object> buffer = Object::New();
+ buffer->Set(String::New(kArrayBufferMarkerPropName), True(), ReadOnly);
+
+ Persistent<Object> persistent_buffer = Persistent<Object>::New(buffer);
+ persistent_buffer.MakeWeak(data, ExternalArrayWeakCallback);
+ persistent_buffer.MarkIndependent();
+
+ buffer->SetIndexedPropertiesToExternalArrayData(
+ reinterpret_cast<uint8_t*>(data), kExternalUnsignedByteArray,
length);
+ buffer->Set(String::New("byteLength"),
+ Int32::New(static_cast<int32_t>(length)), ReadOnly);
+ return buffer;
+}
#ifndef V8_SHARED
=======================================
--- /trunk/src/d8.h Wed Jan 25 23:37:54 2012
+++ /trunk/src/d8.h Tue May 15 05:16:38 2012
@@ -308,6 +308,7 @@
static Handle<Value> DisableProfiler(const Arguments& args);
static Handle<Value> Read(const Arguments& args);
static Handle<Value> ReadBinary(const Arguments& args);
+ static Handle<Value> ReadBuffer(const Arguments& args);
static Handle<String> ReadFromStdin();
static Handle<Value> ReadLine(const Arguments& args) {
return ReadFromStdin();
=======================================
--- /trunk/src/flag-definitions.h Fri May 11 08:02:09 2012
+++ /trunk/src/flag-definitions.h Tue May 15 05:16:38 2012
@@ -132,7 +132,7 @@
// Flags for language modes and experimental language features.
DEFINE_bool(use_strict, false, "enforce strict mode")
-DEFINE_bool(es52_globals, true,
+DEFINE_bool(es52_globals, false,
"activate new semantics for global var declarations")
DEFINE_bool(harmony_typeof, false, "enable harmony semantics for typeof")
=======================================
--- /trunk/src/heap.cc Fri May 11 08:02:09 2012
+++ /trunk/src/heap.cc Tue May 15 05:16:38 2012
@@ -171,6 +171,9 @@
global_contexts_list_ = NULL;
mark_compact_collector_.heap_ = this;
external_string_table_.heap_ = this;
+ // Put a dummy entry in the remembered pages so we can find the list the
+ // minidump even if there are no real unmapped pages.
+ RememberUnmappedPage(NULL, false);
}
=======================================
--- /trunk/src/platform-freebsd.cc Tue Apr 17 04:57:53 2012
+++ /trunk/src/platform-freebsd.cc Tue May 15 05:16:38 2012
@@ -554,6 +554,7 @@
ASSERT(result == 0);
result = pthread_mutex_init(&mutex_, &attrs);
ASSERT(result == 0);
+ USE(result);
}
virtual ~FreeBSDMutex() { pthread_mutex_destroy(&mutex_); }
=======================================
--- /trunk/src/platform-linux.cc Tue Apr 17 04:57:53 2012
+++ /trunk/src/platform-linux.cc Tue May 15 05:16:38 2012
@@ -966,43 +966,22 @@
#elif !defined(__GLIBC__) && defined(__i386__)
// x86 version for Android.
-struct _libc_fpreg {
- uint16_t significand[4];
- uint16_t exponent;
+struct sigcontext {
+ uint32_t gregs[19];
+ void* fpregs;
+ uint32_t oldmask;
+ uint32_t cr2;
};
-struct _libc_fpstate {
- uint64_t cw;
- uint64_t sw;
- uint64_t tag;
- uint64_t ipoff;
- uint64_t cssel;
- uint64_t dataoff;
- uint64_t datasel;
- struct _libc_fpreg _st[8];
- uint64_t status;
-};
-
-typedef struct _libc_fpstate *fpregset_t;
-
-typedef struct mcontext {
- int32_t gregs[19];
- fpregset_t fpregs;
- int64_t oldmask;
- int64_t cr2;
-} mcontext_t;
-
-typedef uint64_t __sigset_t;
-
+typedef uint32_t __sigset_t;
+typedef struct sigcontext mcontext_t;
typedef struct ucontext {
- uint64_t uc_flags;
- struct ucontext *uc_link;
+ uint32_t uc_flags;
+ struct ucontext* uc_link;
stack_t uc_stack;
mcontext_t uc_mcontext;
__sigset_t uc_sigmask;
- struct _libc_fpstate __fpregs_mem;
} ucontext_t;
-
enum { REG_EBP = 6, REG_ESP = 7, REG_EIP = 14 };
#endif
=======================================
--- /trunk/src/profile-generator.cc Fri May 11 08:02:09 2012
+++ /trunk/src/profile-generator.cc Tue May 15 05:16:38 2012
@@ -3499,16 +3499,9 @@
}
-// This function won't work correctly for MIN_INT but this is not
-// a problem in case of heap snapshots serialization.
-static int itoa(int value, const Vector<char>& buffer, int buffer_pos) {
- if (value < 0) {
- buffer[buffer_pos++] = '-';
- value = -value;
- }
-
+static int utoa(unsigned value, const Vector<char>& buffer, int
buffer_pos) {
int number_of_digits = 0;
- int t = value;
+ unsigned t = value;
do {
++number_of_digits;
} while (t /= 10);
@@ -3538,11 +3531,11 @@
if (!first_edge) {
buffer[buffer_pos++] = ',';
}
- buffer_pos = itoa(edge->type(), buffer, buffer_pos);
+ buffer_pos = utoa(edge->type(), buffer, buffer_pos);
buffer[buffer_pos++] = ',';
- buffer_pos = itoa(edge_name_or_index, buffer, buffer_pos);
+ buffer_pos = utoa(edge_name_or_index, buffer, buffer_pos);
buffer[buffer_pos++] = ',';
- buffer_pos = itoa(entry_index(edge->to()), buffer, buffer_pos);
+ buffer_pos = utoa(entry_index(edge->to()), buffer, buffer_pos);
buffer[buffer_pos++] = '\0';
writer_->AddString(buffer.start());
}
@@ -3571,23 +3564,23 @@
+ 7 + 1 + 1;
EmbeddedVector<char, kBufferSize> buffer;
int buffer_pos = 0;
- buffer[buffer_pos++] = '\n';
if (entry_index(entry) != 0) {
buffer[buffer_pos++] = ',';
}
- buffer_pos = itoa(entry->type(), buffer, buffer_pos);
+ buffer_pos = utoa(entry->type(), buffer, buffer_pos);
buffer[buffer_pos++] = ',';
- buffer_pos = itoa(GetStringId(entry->name()), buffer, buffer_pos);
+ buffer_pos = utoa(GetStringId(entry->name()), buffer, buffer_pos);
buffer[buffer_pos++] = ',';
- buffer_pos = itoa(entry->id(), buffer, buffer_pos);
+ buffer_pos = utoa(entry->id(), buffer, buffer_pos);
buffer[buffer_pos++] = ',';
- buffer_pos = itoa(entry->self_size(), buffer, buffer_pos);
+ buffer_pos = utoa(entry->self_size(), buffer, buffer_pos);
buffer[buffer_pos++] = ',';
- buffer_pos = itoa(entry->retained_size(), buffer, buffer_pos);
+ buffer_pos = utoa(entry->retained_size(), buffer, buffer_pos);
buffer[buffer_pos++] = ',';
- buffer_pos = itoa(entry_index(entry->dominator()), buffer, buffer_pos);
+ buffer_pos = utoa(entry_index(entry->dominator()), buffer, buffer_pos);
buffer[buffer_pos++] = ',';
- buffer_pos = itoa(edges_index, buffer, buffer_pos);
+ buffer_pos = utoa(edges_index, buffer, buffer_pos);
+ buffer[buffer_pos++] = '\n';
buffer[buffer_pos++] = '\0';
writer_->AddString(buffer.start());
}
=======================================
--- /trunk/src/version.cc Fri May 11 08:02:09 2012
+++ /trunk/src/version.cc Tue May 15 05:16:38 2012
@@ -34,7 +34,7 @@
// cannot be changed without changing the SCons build script.
#define MAJOR_VERSION 3
#define MINOR_VERSION 11
-#define BUILD_NUMBER 0
+#define BUILD_NUMBER 1
#define PATCH_LEVEL 0
// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
=======================================
--- /trunk/tools/grokdump.py Fri May 11 08:02:09 2012
+++ /trunk/tools/grokdump.py Tue May 15 05:16:38 2012
@@ -108,6 +108,24 @@
return Raw
+def do_dump(reader, heap):
+ """Dump all available memory regions."""
+ def dump_region(reader, start, size, location):
+ print "%s - %s" % (reader.FormatIntPtr(start),
+ reader.FormatIntPtr(start + size))
+ for slot in xrange(start,
+ start + size,
+ reader.PointerSize()):
+ maybe_address = reader.ReadUIntPtr(slot)
+ heap_object = heap.FindObject(maybe_address)
+ print "%s: %s" % (reader.FormatIntPtr(slot),
+ reader.FormatIntPtr(maybe_address))
+ if heap_object:
+ heap_object.Print(Printer())
+ print
+
+ reader.ForEachMemoryRegion(dump_region)
+
# Set of structures and constants that describe the layout of minidump
# files. Based on MSDN and Google Breakpad.
@@ -774,7 +792,10 @@
self.right = self.ObjectField(self.RightOffset())
def GetChars(self):
- return self.left.GetChars() + self.right.GetChars()
+ try:
+ return self.left.GetChars() + self.right.GetChars()
+ except:
+ return "***CAUGHT EXCEPTION IN GROKDUMP***"
class Oddball(HeapObject):
@@ -1110,6 +1131,9 @@
print FormatDisasmLine(start, heap, line)
print
+ if options.full:
+ do_dump(reader, heap)
+
if options.shell:
InspectionShell(reader, heap).cmdloop("type help to get help")
else:
@@ -1129,6 +1153,7 @@
if __name__ == "__main__":
parser = optparse.OptionParser(USAGE)
parser.add_option("-s", "--shell", dest="shell", action="store_true")
+ parser.add_option("-f", "--full", dest="full", action="store_true")
options, args = parser.parse_args()
if len(args) != 1:
parser.print_help()
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev