summaryrefslogtreecommitdiff
path: root/deps/v8/samples
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2015-06-19 13:23:56 +0200
committerRod Vagg <rod@vagg.org>2015-08-04 11:56:14 -0700
commit70d1f32f5605465a1a630a64f6f0d35f96c7709d (patch)
tree0a349040a686eafcb0a09943ebc733477dce2781 /deps/v8/samples
parent4643b8b6671607a7aff60cbbd0b384dcf2f6959e (diff)
downloadandroid-node-v8-70d1f32f5605465a1a630a64f6f0d35f96c7709d.tar.gz
android-node-v8-70d1f32f5605465a1a630a64f6f0d35f96c7709d.tar.bz2
android-node-v8-70d1f32f5605465a1a630a64f6f0d35f96c7709d.zip
deps: update v8 to 4.4.63.9
Upgrade the bundled V8 and update code in src/ and lib/ to the new API. Notable backwards incompatible changes are the removal of the smalloc module and dropped support for CESU-8 decoding. CESU-8 support can be brought back if necessary by doing UTF-8 decoding ourselves. This commit includes https://codereview.chromium.org/1192973004 to fix a build error on python 2.6 systems. The original commit log follows: Use optparse in js2c.py for python compatibility Without this change, V8 won't build on RHEL/CentOS 6 because the distro python is too old to know about the argparse module. PR-URL: https://github.com/nodejs/io.js/pull/2022 Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'deps/v8/samples')
-rw-r--r--deps/v8/samples/process.cc34
-rw-r--r--deps/v8/samples/shell.cc20
2 files changed, 39 insertions, 15 deletions
diff --git a/deps/v8/samples/process.cc b/deps/v8/samples/process.cc
index f44797066b..8d1cebeab5 100644
--- a/deps/v8/samples/process.cc
+++ b/deps/v8/samples/process.cc
@@ -29,12 +29,26 @@
#include <include/libplatform/libplatform.h>
+#include <stdlib.h>
+#include <string.h>
+
#include <map>
#include <string>
using namespace std;
using namespace v8;
+class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
+ public:
+ virtual void* Allocate(size_t length) {
+ void* data = AllocateUninitialized(length);
+ return data == NULL ? data : memset(data, 0, length);
+ }
+ virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
+ virtual void Free(void* data, size_t) { free(data); }
+};
+
+
// These interfaces represent an existing request processing interface.
// The idea is to imagine a real application that uses these interfaces
// and then add scripting capabilities that allow you to interact with
@@ -595,18 +609,21 @@ Handle<String> ReadFile(Isolate* isolate, const string& name) {
if (file == NULL) return Handle<String>();
fseek(file, 0, SEEK_END);
- int size = ftell(file);
+ size_t size = ftell(file);
rewind(file);
char* chars = new char[size + 1];
chars[size] = '\0';
- for (int i = 0; i < size;) {
- int read = static_cast<int>(fread(&chars[i], 1, size - i, file));
- i += read;
+ for (size_t i = 0; i < size;) {
+ i += fread(&chars[i], 1, size - i, file);
+ if (ferror(file)) {
+ fclose(file);
+ return Handle<String>();
+ }
}
fclose(file);
- Handle<String> result =
- String::NewFromUtf8(isolate, chars, String::kNormalString, size);
+ Handle<String> result = String::NewFromUtf8(
+ isolate, chars, String::kNormalString, static_cast<int>(size));
delete[] chars;
return result;
}
@@ -653,7 +670,10 @@ int main(int argc, char* argv[]) {
fprintf(stderr, "No script was specified.\n");
return 1;
}
- Isolate* isolate = Isolate::New();
+ ArrayBufferAllocator array_buffer_allocator;
+ Isolate::CreateParams create_params;
+ create_params.array_buffer_allocator = &array_buffer_allocator;
+ Isolate* isolate = Isolate::New(create_params);
Isolate::Scope isolate_scope(isolate);
HandleScope scope(isolate);
Handle<String> source = ReadFile(isolate, file);
diff --git a/deps/v8/samples/shell.cc b/deps/v8/samples/shell.cc
index 0ed742d3e3..48c042c795 100644
--- a/deps/v8/samples/shell.cc
+++ b/deps/v8/samples/shell.cc
@@ -82,8 +82,9 @@ int main(int argc, char* argv[]) {
v8::V8::Initialize();
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
ShellArrayBufferAllocator array_buffer_allocator;
- v8::V8::SetArrayBufferAllocator(&array_buffer_allocator);
- v8::Isolate* isolate = v8::Isolate::New();
+ v8::Isolate::CreateParams create_params;
+ create_params.array_buffer_allocator = &array_buffer_allocator;
+ v8::Isolate* isolate = v8::Isolate::New(create_params);
run_shell = (argc == 1);
int result;
{
@@ -238,18 +239,21 @@ v8::Handle<v8::String> ReadFile(v8::Isolate* isolate, const char* name) {
if (file == NULL) return v8::Handle<v8::String>();
fseek(file, 0, SEEK_END);
- int size = ftell(file);
+ size_t size = ftell(file);
rewind(file);
char* chars = new char[size + 1];
chars[size] = '\0';
- for (int i = 0; i < size;) {
- int read = static_cast<int>(fread(&chars[i], 1, size - i, file));
- i += read;
+ for (size_t i = 0; i < size;) {
+ i += fread(&chars[i], 1, size - i, file);
+ if (ferror(file)) {
+ fclose(file);
+ return v8::Handle<v8::String>();
+ }
}
fclose(file);
- v8::Handle<v8::String> result =
- v8::String::NewFromUtf8(isolate, chars, v8::String::kNormalString, size);
+ v8::Handle<v8::String> result = v8::String::NewFromUtf8(
+ isolate, chars, v8::String::kNormalString, static_cast<int>(size));
delete[] chars;
return result;
}