Skip to content

Commit

Permalink
Upgrade V8 to 3.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Dec 17, 2010
1 parent 9eaf232 commit 7d425a0
Show file tree
Hide file tree
Showing 159 changed files with 11,579 additions and 8,047 deletions.
12 changes: 12 additions & 0 deletions deps/v8/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
2010-12-17: Version 3.0.3

Reapplied all changes for version 3.0.1.

Improved debugger protocol for remote debugging.

Added experimental support for using gyp to generate build files
for V8.

Fixed implementation of String::Write in the API (issue 975).


2010-12-15: Version 3.0.2

Revert version 3.0.1 and patch 3.0.1.1.
Expand Down
7 changes: 0 additions & 7 deletions deps/v8/include/v8-preparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,6 @@ class UnicodeInputStream {
// Returns the next Unicode code-point in the input, or a negative value when
// there is no more input in the stream.
virtual int32_t Next() = 0;

// Pushes a read character back into the stream, so that it will be the next
// to be read by Advance(). The character pushed back must be the most
// recently read character that hasn't already been pushed back (i.e., if
// pushing back more than one character, they must occur in the opposite order
// of the one they were read in).
virtual void PushBack(int32_t ch) = 0;
};


Expand Down
4 changes: 2 additions & 2 deletions deps/v8/include/v8-profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ class V8EXPORT HeapGraphPath {
class V8EXPORT HeapGraphNode {
public:
enum Type {
kInternal = 0, // For compatibility, will be removed.
kHidden = 0, // Hidden node, may be filtered when shown to user.
kArray = 1, // An array of elements.
kString = 2, // A string.
Expand Down Expand Up @@ -413,7 +412,8 @@ class V8EXPORT HeapProfiler {
*/
static const HeapSnapshot* TakeSnapshot(
Handle<String> title,
HeapSnapshot::Type type = HeapSnapshot::kFull);
HeapSnapshot::Type type = HeapSnapshot::kFull,
ActivityControl* control = NULL);
};


Expand Down
29 changes: 26 additions & 3 deletions deps/v8/include/v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -992,18 +992,23 @@ class String : public Primitive {
* the contents of the string and the NULL terminator into the
* buffer.
*
* WriteUtf8 will not write partial UTF-8 sequences, preferring to stop
* before the end of the buffer.
*
* Copies up to length characters into the output buffer.
* Only null-terminates if there is enough space in the buffer.
*
* \param buffer The buffer into which the string will be copied.
* \param start The starting position within the string at which
* copying begins.
* \param length The number of bytes to copy from the string.
* \param length The number of characters to copy from the string. For
* WriteUtf8 the number of bytes in the buffer.
* \param nchars_ref The number of characters written, can be NULL.
* \param hints Various hints that might affect performance of this or
* subsequent operations.
* \return The number of bytes copied to the buffer
* excluding the NULL terminator.
* \return The number of characters copied to the buffer excluding the null
* terminator. For WriteUtf8: The number of bytes copied to the buffer
* including the null terminator.
*/
enum WriteHints {
NO_HINTS = 0,
Expand Down Expand Up @@ -3281,6 +3286,24 @@ class V8EXPORT OutputStream { // NOLINT
};


/**
* An interface for reporting progress and controlling long-running
* activities.
*/
class V8EXPORT ActivityControl { // NOLINT
public:
enum ControlOption {
kContinue = 0,
kAbort = 1
};
virtual ~ActivityControl() {}
/**
* Notify about current progress. The activity can be stopped by
* returning kAbort as the callback result.
*/
virtual ControlOption ReportProgressValue(int done, int total) = 0;
};


// --- I m p l e m e n t a t i o n ---

Expand Down
26 changes: 19 additions & 7 deletions deps/v8/preparser/preparser-process.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ uint32_t ReadUInt32(FILE* source, bool* ok) {


bool ReadBuffer(FILE* source, void* buffer, size_t length) {
size_t actually_read = fread(buffer, 1, length, stdin);
size_t actually_read = fread(buffer, 1, length, source);
return (actually_read == length);
}

Expand All @@ -150,29 +150,34 @@ class ScopedPointer {
};


// Preparse stdin and output result on stdout.
int PreParseIO() {
// Preparse input and output result on stdout.
int PreParseIO(FILE* input) {
fprintf(stderr, "LOG: Enter parsing loop\n");
bool ok = true;
uint32_t length = ReadUInt32(stdin, &ok);
uint32_t length = ReadUInt32(input, &ok);
fprintf(stderr, "LOG: Input length: %d\n", length);
if (!ok) return kErrorReading;
ScopedPointer<uint8_t> buffer(new uint8_t[length]);

if (!ReadBuffer(stdin, *buffer, length)) {
if (!ReadBuffer(input, *buffer, length)) {
return kErrorReading;
}
UTF8InputStream input_buffer(*buffer, static_cast<size_t>(length));

v8::PreParserData data =
v8::Preparse(&input_buffer, 64 * sizeof(void*)); // NOLINT
v8::Preparse(&input_buffer, 64 * 1024 * sizeof(void*)); // NOLINT
if (data.stack_overflow()) {
fprintf(stderr, "LOG: Stack overflow\n");
fflush(stderr);
// Report stack overflow error/no-preparser-data.
WriteUInt32(stdout, 0, &ok);
if (!ok) return kErrorWriting;
return 0;
}

uint32_t size = data.size();
fprintf(stderr, "LOG: Success, data size: %u\n", size);
fflush(stderr);
WriteUInt32(stdout, size, &ok);
if (!ok) return kErrorWriting;
if (!WriteBuffer(stdout, data.data(), size)) {
Expand All @@ -185,10 +190,17 @@ int PreParseIO() {


int main(int argc, char* argv[]) {
FILE* input = stdin;
if (argc > 1) {
char* arg = argv[1];
input = fopen(arg, "rb");
if (input == NULL) return EXIT_FAILURE;
}
int status = 0;
do {
status = v8::internal::PreParseIO();
status = v8::internal::PreParseIO(input);
} while (status == 0);
fprintf(stderr, "EXIT: Failure %d\n", status);
fflush(stderr);
return EXIT_FAILURE;
}
51 changes: 51 additions & 0 deletions deps/v8/samples/samples.gyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright 2010 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.

{
'targets': [
{
'target_name': 'shell',
'type': 'executable',
'dependencies': [
'../tools/gyp/v8.gyp:v8',
],
'sources': [
'shell.cc',
],
},
{
'target_name': 'process',
'type': 'executable',
'dependencies': [
'../tools/gyp/v8.gyp:v8',
],
'sources': [
'process.cc',
],
}
],
}
6 changes: 0 additions & 6 deletions deps/v8/samples/shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ v8::Handle<v8::Value> Quit(const v8::Arguments& args);
v8::Handle<v8::Value> Version(const v8::Arguments& args);
v8::Handle<v8::String> ReadFile(const char* name);
void ReportException(v8::TryCatch* handler);
void SetFlagsFromString(const char* flags);


int RunMain(int argc, char* argv[]) {
Expand Down Expand Up @@ -345,8 +344,3 @@ void ReportException(v8::TryCatch* try_catch) {
}
}
}


void SetFlagsFromString(const char* flags) {
v8::V8::SetFlagsFromString(flags, strlen(flags));
}
3 changes: 3 additions & 0 deletions deps/v8/src/allocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
#ifndef V8_ALLOCATION_H_
#define V8_ALLOCATION_H_

#include "checks.h"
#include "globals.h"

namespace v8 {
namespace internal {

Expand Down
34 changes: 23 additions & 11 deletions deps/v8/src/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1165,14 +1165,22 @@ void ObjectTemplate::SetInternalFieldCount(int value) {


ScriptData* ScriptData::PreCompile(const char* input, int length) {
unibrow::Utf8InputBuffer<> buf(input, length);
return i::ParserApi::PreParse(i::Handle<i::String>(), &buf, NULL);
i::Utf8ToUC16CharacterStream stream(
reinterpret_cast<const unsigned char*>(input), length);
return i::ParserApi::PreParse(&stream, NULL);
}


ScriptData* ScriptData::PreCompile(v8::Handle<String> source) {
i::Handle<i::String> str = Utils::OpenHandle(*source);
return i::ParserApi::PreParse(str, NULL, NULL);
if (str->IsExternalTwoByteString()) {
i::ExternalTwoByteStringUC16CharacterStream stream(
i::Handle<i::ExternalTwoByteString>::cast(str), 0, str->length());
return i::ParserApi::PreParse(&stream, NULL);
} else {
i::GenericStringUC16CharacterStream stream(str, 0, str->length());
return i::ParserApi::PreParse(&stream, NULL);
}
}


Expand Down Expand Up @@ -3119,14 +3127,15 @@ int String::Write(uint16_t* buffer,
// using StringInputBuffer or Get(i) to access the characters.
str->TryFlatten();
}
int end = length;
if ( (length == -1) || (length > str->length() - start) )
end = str->length() - start;
int end = start + length;
if ((length == -1) || (length > str->length() - start) )
end = str->length();
if (end < 0) return 0;
i::String::WriteToFlat(*str, buffer, start, end);
if (length == -1 || end < length)
buffer[end] = '\0';
return end;
if (length == -1 || end - start < length) {
buffer[end - start] = '\0';
}
return end - start;
}


Expand Down Expand Up @@ -4939,7 +4948,8 @@ const HeapSnapshot* HeapProfiler::FindSnapshot(unsigned uid) {


const HeapSnapshot* HeapProfiler::TakeSnapshot(Handle<String> title,
HeapSnapshot::Type type) {
HeapSnapshot::Type type,
ActivityControl* control) {
IsDeadCheck("v8::HeapProfiler::TakeSnapshot");
i::HeapSnapshot::Type internal_type = i::HeapSnapshot::kFull;
switch (type) {
Expand All @@ -4953,7 +4963,8 @@ const HeapSnapshot* HeapProfiler::TakeSnapshot(Handle<String> title,
UNREACHABLE();
}
return reinterpret_cast<const HeapSnapshot*>(
i::HeapProfiler::TakeSnapshot(*Utils::OpenHandle(*title), internal_type));
i::HeapProfiler::TakeSnapshot(
*Utils::OpenHandle(*title), internal_type, control));
}

#endif // ENABLE_LOGGING_AND_PROFILING
Expand All @@ -4968,6 +4979,7 @@ void Testing::SetStressRunType(Testing::StressType type) {
}

int Testing::GetStressRuns() {
if (internal::FLAG_stress_runs != 0) return internal::FLAG_stress_runs;
#ifdef DEBUG
// In debug mode the code runs much slower so stressing will only make two
// runs.
Expand Down
8 changes: 7 additions & 1 deletion deps/v8/src/arm/codegen-arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5592,6 +5592,12 @@ void CodeGenerator::GenerateSwapElements(ZoneList<Expression*>* args) {
__ tst(tmp2, Operand(kSmiTagMask));
deferred->Branch(nz);

// Check that both indices are valid.
__ ldr(tmp2, FieldMemOperand(object, JSArray::kLengthOffset));
__ cmp(tmp2, index1);
__ cmp(tmp2, index2, hi);
deferred->Branch(ls);

// Bring the offsets into the fixed array in tmp1 into index1 and
// index2.
__ mov(tmp2, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
Expand Down Expand Up @@ -6463,7 +6469,7 @@ void CodeGenerator::VisitCompareOperation(CompareOperation* node) {
case Token::INSTANCEOF: {
Load(left);
Load(right);
InstanceofStub stub;
InstanceofStub stub(InstanceofStub::kNoFlags);
frame_->CallStub(&stub, 2);
// At this point if instanceof succeeded then r0 == 0.
__ tst(r0, Operand(r0));
Expand Down
Loading

0 comments on commit 7d425a0

Please sign in to comment.