Commit dceb5f6a authored by mads.s.ager@gmail.com's avatar mads.s.ager@gmail.com

Improved test support.

Fixed issue with building samples and cctests on 64-bit machines.



git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@23 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 968facb9
...@@ -33,8 +33,8 @@ ...@@ -33,8 +33,8 @@
#ifdef _WIN32 #ifdef _WIN32
typedef int int32_t; typedef int int32_t;
typedef unsigned int uint32_t; typedef unsigned int uint32_t;
typedef unsigned short uint16_t; typedef unsigned short uint16_t; // NOLINT
typedef long long int64_t; typedef long long int64_t; // NOLINT
// Setup for Windows DLL export/import. See v8.h in this directory for // Setup for Windows DLL export/import. See v8.h in this directory for
// information on how to build/use V8 as a DLL. // information on how to build/use V8 as a DLL.
......
...@@ -41,8 +41,8 @@ ...@@ -41,8 +41,8 @@
#ifdef _WIN32 #ifdef _WIN32
typedef int int32_t; typedef int int32_t;
typedef unsigned int uint32_t; typedef unsigned int uint32_t;
typedef unsigned short uint16_t; typedef unsigned short uint16_t; // NOLINT
typedef long long int64_t; typedef long long int64_t; // NOLINT
// Setup for Windows DLL export/import. When building the V8 DLL the // Setup for Windows DLL export/import. When building the V8 DLL the
// BUILDING_V8_SHARED needs to be defined. When building a program which uses // BUILDING_V8_SHARED needs to be defined. When building a program which uses
...@@ -486,7 +486,7 @@ class EXPORT Data { ...@@ -486,7 +486,7 @@ class EXPORT Data {
* compiling it, and stored between compilations. When script data * compiling it, and stored between compilations. When script data
* is given to the compile method compilation will be faster. * is given to the compile method compilation will be faster.
*/ */
class EXPORT ScriptData { class EXPORT ScriptData { // NOLINT
public: public:
virtual ~ScriptData() { } virtual ~ScriptData() { }
static ScriptData* PreCompile(const char* input, int length); static ScriptData* PreCompile(const char* input, int length);
...@@ -730,7 +730,7 @@ class EXPORT String : public Primitive { ...@@ -730,7 +730,7 @@ class EXPORT String : public Primitive {
* ExternalStringResource to manage the life cycle of the underlying * ExternalStringResource to manage the life cycle of the underlying
* buffer. * buffer.
*/ */
class EXPORT ExternalStringResource { class EXPORT ExternalStringResource { // NOLINT
public: public:
/** /**
* Override the destructor to manage the life cycle of the underlying * Override the destructor to manage the life cycle of the underlying
...@@ -755,7 +755,7 @@ class EXPORT String : public Primitive { ...@@ -755,7 +755,7 @@ class EXPORT String : public Primitive {
* underlying buffer. * underlying buffer.
*/ */
class EXPORT ExternalAsciiStringResource { class EXPORT ExternalAsciiStringResource { // NOLINT
public: public:
/** /**
* Override the destructor to manage the life cycle of the underlying * Override the destructor to manage the life cycle of the underlying
...@@ -1504,7 +1504,7 @@ class EXPORT TypeSwitch : public Data { ...@@ -1504,7 +1504,7 @@ class EXPORT TypeSwitch : public Data {
/** /**
* Ignore * Ignore
*/ */
class EXPORT Extension { class EXPORT Extension { // NOLINT
public: public:
Extension(const char* name, Extension(const char* name,
const char* source = 0, const char* source = 0,
......
...@@ -420,7 +420,7 @@ class HandleScopeImplementer { ...@@ -420,7 +420,7 @@ class HandleScopeImplementer {
char* RestoreThreadHelper(char* from); char* RestoreThreadHelper(char* from);
char* ArchiveThreadHelper(char* to); char* ArchiveThreadHelper(char* to);
DISALLOW_EVIL_CONSTRUCTORS(HandleScopeImplementer); DISALLOW_COPY_AND_ASSIGN(HandleScopeImplementer);
}; };
......
...@@ -329,7 +329,7 @@ class RelocInfoWriter BASE_EMBEDDED { ...@@ -329,7 +329,7 @@ class RelocInfoWriter BASE_EMBEDDED {
byte* pos_; byte* pos_;
byte* last_pc_; byte* last_pc_;
intptr_t last_data_; intptr_t last_data_;
DISALLOW_EVIL_CONSTRUCTORS(RelocInfoWriter); DISALLOW_COPY_AND_ASSIGN(RelocInfoWriter);
}; };
...@@ -388,7 +388,7 @@ class RelocIterator: public Malloced { ...@@ -388,7 +388,7 @@ class RelocIterator: public Malloced {
RelocInfo rinfo_; RelocInfo rinfo_;
bool done_; bool done_;
int mode_mask_; int mode_mask_;
DISALLOW_EVIL_CONSTRUCTORS(RelocIterator); DISALLOW_COPY_AND_ASSIGN(RelocIterator);
}; };
......
...@@ -95,7 +95,7 @@ class SourceCodeCache BASE_EMBEDDED { ...@@ -95,7 +95,7 @@ class SourceCodeCache BASE_EMBEDDED {
private: private:
ScriptType type_; ScriptType type_;
FixedArray* cache_; FixedArray* cache_;
DISALLOW_EVIL_CONSTRUCTORS(SourceCodeCache); DISALLOW_COPY_AND_ASSIGN(SourceCodeCache);
}; };
static SourceCodeCache natives_cache(SCRIPT_TYPE_NATIVE); static SourceCodeCache natives_cache(SCRIPT_TYPE_NATIVE);
......
...@@ -4170,12 +4170,17 @@ void ArmCodeGenerator::VisitUnaryOperation(UnaryOperation* node) { ...@@ -4170,12 +4170,17 @@ void ArmCodeGenerator::VisitUnaryOperation(UnaryOperation* node) {
__ mov(r0, Operand(Factory::undefined_value())); __ mov(r0, Operand(Factory::undefined_value()));
break; break;
case Token::ADD: case Token::ADD: {
// Smi check.
Label continue_label;
__ tst(r0, Operand(kSmiTagMask));
__ b(eq, &continue_label);
__ push(r0); __ push(r0);
__ mov(r0, Operand(0)); // not counting receiver __ mov(r0, Operand(0)); // not counting receiver
__ InvokeBuiltin("TO_NUMBER", 0, CALL_JS); __ InvokeBuiltin("TO_NUMBER", 0, CALL_JS);
__ bind(&continue_label);
break; break;
}
default: default:
UNREACHABLE(); UNREACHABLE();
} }
......
...@@ -257,8 +257,11 @@ class Ia32CodeGenerator: public CodeGenerator { ...@@ -257,8 +257,11 @@ class Ia32CodeGenerator: public CodeGenerator {
const OverwriteMode overwrite_mode = NO_OVERWRITE); const OverwriteMode overwrite_mode = NO_OVERWRITE);
void Comparison(Condition cc, bool strict = false); void Comparison(Condition cc, bool strict = false);
// Inline small integer literals. To prevent long attacker-controlled byte
// sequences, we only inline small Smi:s.
static const int kMaxSmiInlinedBits = 16;
bool IsInlineSmi(Literal* literal);
void SmiComparison(Condition cc, Handle<Object> value, bool strict = false); void SmiComparison(Condition cc, Handle<Object> value, bool strict = false);
void SmiOperation(Token::Value op, void SmiOperation(Token::Value op,
Handle<Object> value, Handle<Object> value,
bool reversed, bool reversed,
...@@ -1993,6 +1996,7 @@ void Ia32CodeGenerator::SmiOperation(Token::Value op, ...@@ -1993,6 +1996,7 @@ void Ia32CodeGenerator::SmiOperation(Token::Value op,
// Get the literal value. // Get the literal value.
int int_value = Smi::cast(*value)->value(); int int_value = Smi::cast(*value)->value();
ASSERT(is_intn(int_value, kMaxSmiInlinedBits));
switch (op) { switch (op) {
case Token::ADD: { case Token::ADD: {
...@@ -2357,8 +2361,11 @@ void Ia32CodeGenerator::SmiComparison(Condition cc, ...@@ -2357,8 +2361,11 @@ void Ia32CodeGenerator::SmiComparison(Condition cc,
// Strict only makes sense for equality comparisons. // Strict only makes sense for equality comparisons.
ASSERT(!strict || cc == equal); ASSERT(!strict || cc == equal);
int int_value = Smi::cast(*value)->value();
ASSERT(is_intn(int_value, kMaxSmiInlinedBits));
SmiComparisonDeferred* deferred = SmiComparisonDeferred* deferred =
new SmiComparisonDeferred(this, cc, strict, Smi::cast(*value)->value()); new SmiComparisonDeferred(this, cc, strict, int_value);
__ pop(eax); __ pop(eax);
__ test(eax, Immediate(kSmiTagMask)); __ test(eax, Immediate(kSmiTagMask));
__ j(not_zero, deferred->enter(), not_taken); __ j(not_zero, deferred->enter(), not_taken);
...@@ -2815,6 +2822,7 @@ void Ia32CodeGenerator::VisitLoopStatement(LoopStatement* node) { ...@@ -2815,6 +2822,7 @@ void Ia32CodeGenerator::VisitLoopStatement(LoopStatement* node) {
// body // body
__ bind(&loop); __ bind(&loop);
CheckStack(); // TODO(1222600): ignore if body contains calls.
Visit(node->body()); Visit(node->body());
// next // next
...@@ -2832,13 +2840,11 @@ void Ia32CodeGenerator::VisitLoopStatement(LoopStatement* node) { ...@@ -2832,13 +2840,11 @@ void Ia32CodeGenerator::VisitLoopStatement(LoopStatement* node) {
__ bind(&entry); __ bind(&entry);
switch (info) { switch (info) {
case ALWAYS_TRUE: case ALWAYS_TRUE:
CheckStack(); // TODO(1222600): ignore if body contains calls.
__ jmp(&loop); __ jmp(&loop);
break; break;
case ALWAYS_FALSE: case ALWAYS_FALSE:
break; break;
case DONT_KNOW: case DONT_KNOW:
CheckStack(); // TODO(1222600): ignore if body contains calls.
LoadCondition(node->cond(), CodeGenState::LOAD, &loop, LoadCondition(node->cond(), CodeGenState::LOAD, &loop,
node->break_target(), true); node->break_target(), true);
Branch(true, &loop); Branch(true, &loop);
...@@ -3426,21 +3432,21 @@ void Ia32CodeGenerator::VisitSlot(Slot* node) { ...@@ -3426,21 +3432,21 @@ void Ia32CodeGenerator::VisitSlot(Slot* node) {
break; break;
case CodeGenState::STORE: case CodeGenState::STORE:
// Storing a variable must keep the (new) value on the stack. This
// is necessary for compiling assignment expressions.
// ecx may be loaded with context; used below in RecordWrite.
//
// Note: We will reach here even with node->var()->mode() == // Note: We will reach here even with node->var()->mode() ==
// Variable::CONST because of const declarations which will // Variable::CONST because of const declarations which will
// initialize consts to 'the hole' value and by doing so, end // initialize consts to 'the hole' value and by doing so, end
// up calling this code. // up calling this code.
__ mov(eax, TOS); __ pop(eax);
__ mov(SlotOperand(node, ecx), eax); __ mov(SlotOperand(node, ecx), eax);
if (node->type() == Slot::CONTEXT) { if (node->type() == Slot::CONTEXT) {
// ecx is loaded with context when calling SlotOperand above. // ecx is loaded with context when calling SlotOperand above.
int offset = FixedArray::kHeaderSize + node->index() * kPointerSize; int offset = FixedArray::kHeaderSize + node->index() * kPointerSize;
__ RecordWrite(ecx, offset, eax, ebx); __ RecordWrite(ecx, offset, eax, ebx);
} }
// Storing a variable must keep the (new) value on the stack. This
// is necessary for compiling assignment expressions.
// ecx may be loaded with context; used below in RecordWrite.
__ push(eax);
break; break;
} }
} }
...@@ -3475,7 +3481,16 @@ void Ia32CodeGenerator::VisitVariableProxy(VariableProxy* proxy_node) { ...@@ -3475,7 +3481,16 @@ void Ia32CodeGenerator::VisitVariableProxy(VariableProxy* proxy_node) {
void Ia32CodeGenerator::VisitLiteral(Literal* node) { void Ia32CodeGenerator::VisitLiteral(Literal* node) {
Comment cmnt(masm_, "[ Literal"); Comment cmnt(masm_, "[ Literal");
if (node->handle()->IsSmi() && !IsInlineSmi(node)) {
// To prevent long attacker-controlled byte sequences in code, larger
// Smis are loaded in two steps.
int bits = reinterpret_cast<int>(*node->handle());
__ mov(eax, bits & 0x0000FFFF);
__ xor_(eax, bits & 0xFFFF0000);
__ push(eax);
} else {
__ push(Immediate(node->handle())); __ push(Immediate(node->handle()));
}
} }
...@@ -3701,6 +3716,13 @@ void Ia32CodeGenerator::VisitArrayLiteral(ArrayLiteral* node) { ...@@ -3701,6 +3716,13 @@ void Ia32CodeGenerator::VisitArrayLiteral(ArrayLiteral* node) {
} }
bool Ia32CodeGenerator::IsInlineSmi(Literal* literal) {
if (literal == NULL || !literal->handle()->IsSmi()) return false;
int int_value = Smi::cast(*literal->handle())->value();
return is_intn(int_value, kMaxSmiInlinedBits);
}
void Ia32CodeGenerator::VisitAssignment(Assignment* node) { void Ia32CodeGenerator::VisitAssignment(Assignment* node) {
Comment cmnt(masm_, "[ Assignment"); Comment cmnt(masm_, "[ Assignment");
...@@ -3716,7 +3738,7 @@ void Ia32CodeGenerator::VisitAssignment(Assignment* node) { ...@@ -3716,7 +3738,7 @@ void Ia32CodeGenerator::VisitAssignment(Assignment* node) {
} else { } else {
GetValue(&target); GetValue(&target);
Literal* literal = node->value()->AsLiteral(); Literal* literal = node->value()->AsLiteral();
if (literal != NULL && literal->handle()->IsSmi()) { if (IsInlineSmi(literal)) {
SmiOperation(node->binary_op(), literal->handle(), false, NO_OVERWRITE); SmiOperation(node->binary_op(), literal->handle(), false, NO_OVERWRITE);
} else { } else {
Load(node->value()); Load(node->value());
...@@ -4687,11 +4709,11 @@ void Ia32CodeGenerator::VisitBinaryOperation(BinaryOperation* node) { ...@@ -4687,11 +4709,11 @@ void Ia32CodeGenerator::VisitBinaryOperation(BinaryOperation* node) {
Literal* lliteral = node->left()->AsLiteral(); Literal* lliteral = node->left()->AsLiteral();
Literal* rliteral = node->right()->AsLiteral(); Literal* rliteral = node->right()->AsLiteral();
if (rliteral != NULL && rliteral->handle()->IsSmi()) { if (IsInlineSmi(rliteral)) {
Load(node->left()); Load(node->left());
SmiOperation(node->op(), rliteral->handle(), false, overwrite_mode); SmiOperation(node->op(), rliteral->handle(), false, overwrite_mode);
} else if (lliteral != NULL && lliteral->handle()->IsSmi()) { } else if (IsInlineSmi(lliteral)) {
Load(node->right()); Load(node->right());
SmiOperation(node->op(), lliteral->handle(), true, overwrite_mode); SmiOperation(node->op(), lliteral->handle(), true, overwrite_mode);
...@@ -4899,12 +4921,12 @@ void Ia32CodeGenerator::VisitCompareOperation(CompareOperation* node) { ...@@ -4899,12 +4921,12 @@ void Ia32CodeGenerator::VisitCompareOperation(CompareOperation* node) {
// Optimize for the case where (at least) one of the expressions // Optimize for the case where (at least) one of the expressions
// is a literal small integer. // is a literal small integer.
if (left->AsLiteral() != NULL && left->AsLiteral()->handle()->IsSmi()) { if (IsInlineSmi(left->AsLiteral())) {
Load(right); Load(right);
SmiComparison(ReverseCondition(cc), left->AsLiteral()->handle(), strict); SmiComparison(ReverseCondition(cc), left->AsLiteral()->handle(), strict);
return; return;
} }
if (right->AsLiteral() != NULL && right->AsLiteral()->handle()->IsSmi()) { if (IsInlineSmi(right->AsLiteral())) {
Load(left); Load(left);
SmiComparison(cc, right->AsLiteral()->handle(), strict); SmiComparison(cc, right->AsLiteral()->handle(), strict);
return; return;
......
...@@ -90,7 +90,7 @@ class DeferredCode: public ZoneObject { ...@@ -90,7 +90,7 @@ class DeferredCode: public ZoneObject {
#ifdef DEBUG #ifdef DEBUG
const char* comment_; const char* comment_;
#endif #endif
DISALLOW_EVIL_CONSTRUCTORS(DeferredCode); DISALLOW_COPY_AND_ASSIGN(DeferredCode);
}; };
......
...@@ -121,7 +121,7 @@ class BreakLocationIterator { ...@@ -121,7 +121,7 @@ class BreakLocationIterator {
void SetDebugBreak(); void SetDebugBreak();
void ClearDebugBreak(); void ClearDebugBreak();
DISALLOW_EVIL_CONSTRUCTORS(BreakLocationIterator); DISALLOW_COPY_AND_ASSIGN(BreakLocationIterator);
}; };
...@@ -317,7 +317,7 @@ class Debug { ...@@ -317,7 +317,7 @@ class Debug {
// Code to call for handling debug break on return. // Code to call for handling debug break on return.
static Code* debug_break_return_; static Code* debug_break_return_;
DISALLOW_EVIL_CONSTRUCTORS(Debug); DISALLOW_COPY_AND_ASSIGN(Debug);
}; };
...@@ -422,7 +422,7 @@ class LockingMessageQueue BASE_EMBEDDED { ...@@ -422,7 +422,7 @@ class LockingMessageQueue BASE_EMBEDDED {
private: private:
MessageQueue queue_; MessageQueue queue_;
Mutex* lock_; Mutex* lock_;
DISALLOW_EVIL_CONSTRUCTORS(LockingMessageQueue); DISALLOW_COPY_AND_ASSIGN(LockingMessageQueue);
}; };
...@@ -465,7 +465,7 @@ class DebugMessageThread: public Thread { ...@@ -465,7 +465,7 @@ class DebugMessageThread: public Thread {
static const int kQueueInitialSize = 4; static const int kQueueInitialSize = 4;
LockingMessageQueue command_queue_; LockingMessageQueue command_queue_;
LockingMessageQueue message_queue_; LockingMessageQueue message_queue_;
DISALLOW_EVIL_CONSTRUCTORS(DebugMessageThread); DISALLOW_COPY_AND_ASSIGN(DebugMessageThread);
}; };
......
...@@ -331,7 +331,7 @@ int FlagList::SetFlagsFromCommandLine(int* argc, ...@@ -331,7 +331,7 @@ int FlagList::SetFlagsFromCommandLine(int* argc,
*flag->bool_variable() = !is_bool; *flag->bool_variable() = !is_bool;
break; break;
case Flag::INT: case Flag::INT:
*flag->int_variable() = strtol(value, &endp, 10); *flag->int_variable() = strtol(value, &endp, 10); // NOLINT
break; break;
case Flag::FLOAT: case Flag::FLOAT:
*flag->float_variable() = strtod(value, &endp); *flag->float_variable() = strtod(value, &endp);
......
...@@ -532,7 +532,7 @@ class StackFrameIterator BASE_EMBEDDED { ...@@ -532,7 +532,7 @@ class StackFrameIterator BASE_EMBEDDED {
StackFrame* SingletonFor(StackFrame::Type type, StackFrame::State* state); StackFrame* SingletonFor(StackFrame::Type type, StackFrame::State* state);
friend class StackFrame; friend class StackFrame;
DISALLOW_EVIL_CONSTRUCTORS(StackFrameIterator); DISALLOW_COPY_AND_ASSIGN(StackFrameIterator);
}; };
......
...@@ -33,8 +33,8 @@ ...@@ -33,8 +33,8 @@
#ifdef WIN32 #ifdef WIN32
typedef signed char int8_t; typedef signed char int8_t;
typedef unsigned char uint8_t; typedef unsigned char uint8_t;
typedef short int16_t; typedef short int16_t; // NOLINT
typedef unsigned short uint16_t; typedef unsigned short uint16_t; // NOLINT
typedef int int32_t; typedef int int32_t;
typedef unsigned int uint32_t; typedef unsigned int uint32_t;
typedef __int64 int64_t; typedef __int64 int64_t;
...@@ -96,11 +96,11 @@ const int GB = KB * KB * KB; ...@@ -96,11 +96,11 @@ const int GB = KB * KB * KB;
const int kMaxInt = 0x7FFFFFFF; const int kMaxInt = 0x7FFFFFFF;
const int kMinInt = -kMaxInt - 1; const int kMinInt = -kMaxInt - 1;
const int kCharSize = sizeof(char); const int kCharSize = sizeof(char); // NOLINT
const int kShortSize = sizeof(short); const int kShortSize = sizeof(short); // NOLINT
const int kIntSize = sizeof(int); const int kIntSize = sizeof(int); // NOLINT
const int kDoubleSize = sizeof(double); const int kDoubleSize = sizeof(double); // NOLINT
const int kPointerSize = sizeof(void*); const int kPointerSize = sizeof(void*); // NOLINT
const int kPointerSizeLog2 = 2; const int kPointerSizeLog2 = 2;
...@@ -414,7 +414,7 @@ F FUNCTION_CAST(Address addr) { ...@@ -414,7 +414,7 @@ F FUNCTION_CAST(Address addr) {
// A macro to disallow the evil copy constructor and operator= functions // A macro to disallow the evil copy constructor and operator= functions
// This should be used in the private: declarations for a class // This should be used in the private: declarations for a class
#define DISALLOW_EVIL_CONSTRUCTORS(TypeName) \ #define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&); \ TypeName(const TypeName&); \
void operator=(const TypeName&) void operator=(const TypeName&)
...@@ -427,7 +427,7 @@ F FUNCTION_CAST(Address addr) { ...@@ -427,7 +427,7 @@ F FUNCTION_CAST(Address addr) {
// especially useful for classes containing only static methods. // especially useful for classes containing only static methods.
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ #define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
TypeName(); \ TypeName(); \
DISALLOW_EVIL_CONSTRUCTORS(TypeName) DISALLOW_COPY_AND_ASSIGN(TypeName)
// Support for tracking C++ memory allocation. Insert TRACK_MEMORY("Fisk") // Support for tracking C++ memory allocation. Insert TRACK_MEMORY("Fisk")
......
...@@ -215,7 +215,7 @@ Handle<Object> GetProperty(Handle<JSObject> obj, ...@@ -215,7 +215,7 @@ Handle<Object> GetProperty(Handle<JSObject> obj,
Handle<Object> GetProperty(Handle<Object> obj, Handle<Object> GetProperty(Handle<Object> obj,
Handle<Object> key) { Handle<Object> key) {
CALL_HEAP_FUNCTION(Runtime::GetObjectProperty(obj, *key), Object); CALL_HEAP_FUNCTION(Runtime::GetObjectProperty(obj, key), Object);
} }
...@@ -256,22 +256,7 @@ Handle<String> SubString(Handle<String> str, int start, int end) { ...@@ -256,22 +256,7 @@ Handle<String> SubString(Handle<String> str, int start, int end) {
Handle<Object> SetElement(Handle<JSObject> object, Handle<Object> SetElement(Handle<JSObject> object,
uint32_t index, uint32_t index,
Handle<Object> value) { Handle<Object> value) {
GC_GREEDY_CHECK(); CALL_HEAP_FUNCTION(object->SetElement(index, *value), Object);
Object* obj = object->SetElement(index, *value);
// If you set an element then the object may need to get a new map
// which will cause it to grow, which will cause an allocation.
// If you know that the object will not grow then perhaps this check
// does not apply and you may have to split this method into two
// versions.
ASSERT(Heap::IsAllocationAllowed());
if (obj->IsFailure()) {
CALL_GC(obj);
obj = object->SetElement(index, *value);
if (obj->IsFailure()) {
V8::FatalProcessOutOfMemory("Handles"); // TODO(1181417): Fix this.
}
}
return value;
} }
......
...@@ -706,7 +706,7 @@ Object* KeyedLoadIC::Load(State state, ...@@ -706,7 +706,7 @@ Object* KeyedLoadIC::Load(State state,
if (use_ic) set_target(generic_stub()); if (use_ic) set_target(generic_stub());
// Get the property. // Get the property.
return Runtime::GetObjectProperty(object, *key); return Runtime::GetObjectProperty(object, key);
} }
...@@ -801,7 +801,9 @@ Object* StoreIC::Store(State state, ...@@ -801,7 +801,9 @@ Object* StoreIC::Store(State state,
// Check if the given name is an array index. // Check if the given name is an array index.
uint32_t index; uint32_t index;
if (name->AsArrayIndex(&index)) { if (name->AsArrayIndex(&index)) {
SetElement(receiver, index, value); HandleScope scope;
Handle<Object> result = SetElement(receiver, index, value);
if (result.is_null()) return Failure::Exception();
return *value; return *value;
} }
...@@ -910,7 +912,9 @@ Object* KeyedStoreIC::Store(State state, ...@@ -910,7 +912,9 @@ Object* KeyedStoreIC::Store(State state,
// Check if the given name is an array index. // Check if the given name is an array index.
uint32_t index; uint32_t index;
if (name->AsArrayIndex(&index)) { if (name->AsArrayIndex(&index)) {
SetElement(receiver, index, value); HandleScope scope;
Handle<Object> result = SetElement(receiver, index, value);
if (result.is_null()) return Failure::Exception();
return *value; return *value;
} }
......
...@@ -108,7 +108,7 @@ class List { ...@@ -108,7 +108,7 @@ class List {
INLINE(T* NewData(int n)) { return static_cast<T*>(P::New(n * sizeof(T))); } INLINE(T* NewData(int n)) { return static_cast<T*>(P::New(n * sizeof(T))); }
INLINE(void DeleteData(T* data)) { P::Delete(data); } INLINE(void DeleteData(T* data)) { P::Delete(data); }
DISALLOW_EVIL_CONSTRUCTORS(List); DISALLOW_COPY_AND_ASSIGN(List);
}; };
......
...@@ -270,7 +270,7 @@ PosixMemoryMappedFile::~PosixMemoryMappedFile() { ...@@ -270,7 +270,7 @@ PosixMemoryMappedFile::~PosixMemoryMappedFile() {
#ifdef ENABLE_LOGGING_AND_PROFILING #ifdef ENABLE_LOGGING_AND_PROFILING
static unsigned StringToLongLong(char* buffer) { static unsigned StringToLongLong(char* buffer) {
return static_cast<unsigned>(strtoll(buffer, NULL, 16)); return static_cast<unsigned>(strtoll(buffer, NULL, 16)); // NOLINT
} }
#endif #endif
......
...@@ -320,7 +320,7 @@ class Thread: public ThreadHandle { ...@@ -320,7 +320,7 @@ class Thread: public ThreadHandle {
private: private:
class PlatformData; class PlatformData;
PlatformData* data_; PlatformData* data_;
DISALLOW_EVIL_CONSTRUCTORS(Thread); DISALLOW_COPY_AND_ASSIGN(Thread);
}; };
...@@ -362,7 +362,7 @@ class ScopedLock { ...@@ -362,7 +362,7 @@ class ScopedLock {
private: private:
Mutex* mutex_; Mutex* mutex_;
DISALLOW_EVIL_CONSTRUCTORS(ScopedLock); DISALLOW_COPY_AND_ASSIGN(ScopedLock);
}; };
......
...@@ -1207,11 +1207,11 @@ Object* Runtime::GetElementOrCharAt(Handle<Object> object, uint32_t index) { ...@@ -1207,11 +1207,11 @@ Object* Runtime::GetElementOrCharAt(Handle<Object> object, uint32_t index) {
} }
Object* Runtime::GetObjectProperty(Handle<Object> object, Object* key) { Object* Runtime::GetObjectProperty(Handle<Object> object, Handle<Object> key) {
if (object->IsUndefined() || object->IsNull()) {
HandleScope scope; HandleScope scope;
Handle<Object> key_handle(key);
Handle<Object> args[2] = { key_handle, object }; if (object->IsUndefined() || object->IsNull()) {
Handle<Object> args[2] = { key, object };
Handle<Object> error = Handle<Object> error =
Factory::NewTypeError("non_object_property_load", Factory::NewTypeError("non_object_property_load",
HandleVector(args, 2)); HandleVector(args, 2));
...@@ -1220,32 +1220,29 @@ Object* Runtime::GetObjectProperty(Handle<Object> object, Object* key) { ...@@ -1220,32 +1220,29 @@ Object* Runtime::GetObjectProperty(Handle<Object> object, Object* key) {
// Check if the given key is an array index. // Check if the given key is an array index.
uint32_t index; uint32_t index;
if (Array::IndexFromObject(key, &index)) { if (Array::IndexFromObject(*key, &index)) {
HandleScope scope;
return GetElementOrCharAt(object, index); return GetElementOrCharAt(object, index);
} }
// Convert the key to a string - possibly by calling back into JavaScript. // Convert the key to a string - possibly by calling back into JavaScript.
String* name; Handle<String> name;
if (key->IsString()) { if (key->IsString()) {
name = String::cast(key); name = Handle<String>::cast(key);
} else { } else {
HandleScope scope;
bool has_pending_exception = false; bool has_pending_exception = false;
Handle<Object> converted = Handle<Object> converted =
Execution::ToString(Handle<Object>(key), &has_pending_exception); Execution::ToString(key, &has_pending_exception);
if (has_pending_exception) return Failure::Exception(); if (has_pending_exception) return Failure::Exception();
name = String::cast(*converted); name = Handle<String>::cast(converted);
} }
// Check if the name is trivially convertable to an index and get // Check if the name is trivially convertable to an index and get
// the element if so. // the element if so.
if (name->AsArrayIndex(&index)) { if (name->AsArrayIndex(&index)) {
HandleScope scope;
return GetElementOrCharAt(object, index); return GetElementOrCharAt(object, index);
} else { } else {
PropertyAttributes attr; PropertyAttributes attr;
return object->GetProperty(name, &attr); return object->GetProperty(*name, &attr);
} }
} }
...@@ -1255,7 +1252,7 @@ static Object* Runtime_GetProperty(Arguments args) { ...@@ -1255,7 +1252,7 @@ static Object* Runtime_GetProperty(Arguments args) {
ASSERT(args.length() == 2); ASSERT(args.length() == 2);
Handle<Object> object = args.at<Object>(0); Handle<Object> object = args.at<Object>(0);
Object* key = args[1]; Handle<Object> key = args.at<Object>(1);
return Runtime::GetObjectProperty(object, key); return Runtime::GetObjectProperty(object, key);
} }
...@@ -1265,10 +1262,10 @@ Object* Runtime::SetObjectProperty(Handle<Object> object, ...@@ -1265,10 +1262,10 @@ Object* Runtime::SetObjectProperty(Handle<Object> object,
Handle<Object> key, Handle<Object> key,
Handle<Object> value, Handle<Object> value,
PropertyAttributes attr) { PropertyAttributes attr) {
if (object->IsUndefined() || object->IsNull()) {
HandleScope scope; HandleScope scope;
Handle<Object> obj(object);
Handle<Object> args[2] = { key, obj }; if (object->IsUndefined() || object->IsNull()) {
Handle<Object> args[2] = { key, object };
Handle<Object> error = Handle<Object> error =
Factory::NewTypeError("non_object_property_store", Factory::NewTypeError("non_object_property_store",
HandleVector(args, 2)); HandleVector(args, 2));
...@@ -1278,6 +1275,8 @@ Object* Runtime::SetObjectProperty(Handle<Object> object, ...@@ -1278,6 +1275,8 @@ Object* Runtime::SetObjectProperty(Handle<Object> object,
// If the object isn't a JavaScript object, we ignore the store. // If the object isn't a JavaScript object, we ignore the store.
if (!object->IsJSObject()) return *value; if (!object->IsJSObject()) return *value;
Handle<JSObject> js_object = Handle<JSObject>::cast(object);
// Check if the given key is an array index. // Check if the given key is an array index.
uint32_t index; uint32_t index;
if (Array::IndexFromObject(*key, &index)) { if (Array::IndexFromObject(*key, &index)) {
...@@ -1290,35 +1289,29 @@ Object* Runtime::SetObjectProperty(Handle<Object> object, ...@@ -1290,35 +1289,29 @@ Object* Runtime::SetObjectProperty(Handle<Object> object,
// the underlying string if the index is in range. Since the underlying // the underlying string if the index is in range. Since the underlying
// string does nothing with the assignment then we can ignore such // string does nothing with the assignment then we can ignore such
// assignments. // assignments.
if (object->IsStringObjectWithCharacterAt(index)) if (js_object->IsStringObjectWithCharacterAt(index)) {
return *value; return *value;
}
Object* result = JSObject::cast(*object)->SetElement(index, *value); Handle<Object> result = SetElement(js_object, index, value);
if (result->IsFailure()) return result; if (result.is_null()) return Failure::Exception();
return *value; return *value;
} }
if (key->IsString()) { if (key->IsString()) {
Object* result; Handle<Object> result;
if (String::cast(*key)->AsArrayIndex(&index)) { if (Handle<String>::cast(key)->AsArrayIndex(&index)) {
ASSERT(attr == NONE); ASSERT(attr == NONE);
result = JSObject::cast(*object)->SetElement(index, *value); result = SetElement(js_object, index, value);
} else { } else {
String::cast(*key)->TryFlatten(); Handle<String> key_string = Handle<String>::cast(key);
result = key_string->TryFlatten();
JSObject::cast(*object)->SetProperty(String::cast(*key), *value, result = SetProperty(js_object, key_string, value, attr);
attr);
} }
if (result->IsFailure()) return result; if (result.is_null()) return Failure::Exception();
return *value; return *value;
} }
HandleScope scope;
// Handlify object and value before calling into JavaScript again.
Handle<JSObject> object_handle = Handle<JSObject>::cast(object);
Handle<Object> value_handle = value;
// Call-back into JavaScript to convert the key to a string. // Call-back into JavaScript to convert the key to a string.
bool has_pending_exception = false; bool has_pending_exception = false;
Handle<Object> converted = Execution::ToString(key, &has_pending_exception); Handle<Object> converted = Execution::ToString(key, &has_pending_exception);
...@@ -1327,9 +1320,9 @@ Object* Runtime::SetObjectProperty(Handle<Object> object, ...@@ -1327,9 +1320,9 @@ Object* Runtime::SetObjectProperty(Handle<Object> object,
if (name->AsArrayIndex(&index)) { if (name->AsArrayIndex(&index)) {
ASSERT(attr == NONE); ASSERT(attr == NONE);
return object_handle->SetElement(index, *value_handle); return js_object->SetElement(index, *value);
} else { } else {
return object_handle->SetProperty(*name, *value_handle, attr); return js_object->SetProperty(*name, *value, attr);
} }
} }
......
...@@ -340,7 +340,7 @@ class Runtime : public AllStatic { ...@@ -340,7 +340,7 @@ class Runtime : public AllStatic {
Handle<Object> value, Handle<Object> value,
PropertyAttributes attr); PropertyAttributes attr);
static Object* GetObjectProperty(Handle<Object> object, Object* key); static Object* GetObjectProperty(Handle<Object> object, Handle<Object> key);
// Helper functions used stubs. // Helper functions used stubs.
static void PerformGC(Object* result); static void PerformGC(Object* result);
......
...@@ -204,7 +204,7 @@ class Serializer: public ObjectVisitor { ...@@ -204,7 +204,7 @@ class Serializer: public ObjectVisitor {
HashMap saved_addresses_; HashMap saved_addresses_;
DISALLOW_EVIL_CONSTRUCTORS(Serializer); DISALLOW_COPY_AND_ASSIGN(Serializer);
}; };
// Helper class to read the bytes of the serialized heap. // Helper class to read the bytes of the serialized heap.
...@@ -325,7 +325,7 @@ class Deserializer: public ObjectVisitor { ...@@ -325,7 +325,7 @@ class Deserializer: public ObjectVisitor {
bool expect_debug_information_; bool expect_debug_information_;
#endif #endif
DISALLOW_EVIL_CONSTRUCTORS(Deserializer); DISALLOW_COPY_AND_ASSIGN(Deserializer);
}; };
} } // namespace v8::internal } } // namespace v8::internal
......
...@@ -132,7 +132,7 @@ bool Debugger::GetValue(char* desc, int32_t* value) { ...@@ -132,7 +132,7 @@ bool Debugger::GetValue(char* desc, int32_t* value) {
} }
return true; return true;
} else { } else {
return sscanf(desc, "%i", value) == 1; return sscanf(desc, "%i", value) == 1; // NOLINT
} }
return false; return false;
} }
...@@ -216,7 +216,7 @@ void Debugger::Debug() { ...@@ -216,7 +216,7 @@ void Debugger::Debug() {
} else { } else {
// Use sscanf to parse the individual parts of the command line. At the // Use sscanf to parse the individual parts of the command line. At the
// moment no command expects more than two parameters. // moment no command expects more than two parameters.
int args = sscanf(line, int args = sscanf(line, // NOLINT
"%" XSTR(COMMAND_SIZE) "s " "%" XSTR(COMMAND_SIZE) "s "
"%" XSTR(ARG_SIZE) "s " "%" XSTR(ARG_SIZE) "s "
"%" XSTR(ARG_SIZE) "s", "%" XSTR(ARG_SIZE) "s",
......
...@@ -1294,7 +1294,7 @@ class OldSpaceFreeList BASE_EMBEDDED { ...@@ -1294,7 +1294,7 @@ class OldSpaceFreeList BASE_EMBEDDED {
bool Contains(FreeListNode* node); bool Contains(FreeListNode* node);
#endif #endif
DISALLOW_EVIL_CONSTRUCTORS(OldSpaceFreeList); DISALLOW_COPY_AND_ASSIGN(OldSpaceFreeList);
}; };
...@@ -1330,7 +1330,7 @@ class MapSpaceFreeList BASE_EMBEDDED { ...@@ -1330,7 +1330,7 @@ class MapSpaceFreeList BASE_EMBEDDED {
// objects. // objects.
AllocationSpace owner_; AllocationSpace owner_;
DISALLOW_EVIL_CONSTRUCTORS(MapSpaceFreeList); DISALLOW_COPY_AND_ASSIGN(MapSpaceFreeList);
}; };
......
...@@ -72,11 +72,11 @@ class NoAllocationStringAllocator: public StringAllocator { ...@@ -72,11 +72,11 @@ class NoAllocationStringAllocator: public StringAllocator {
class FmtElm { class FmtElm {
public: public:
FmtElm(int value) : type_(INT) { data_.u_int_ = value; } FmtElm(int value) : type_(INT) { data_.u_int_ = value; } // NOLINT
FmtElm(const char* value) : type_(C_STR) { data_.u_c_str_ = value; } FmtElm(const char* value) : type_(C_STR) { data_.u_c_str_ = value; } // NOLINT
FmtElm(Object* value) : type_(OBJ) { data_.u_obj_ = value; } FmtElm(Object* value) : type_(OBJ) { data_.u_obj_ = value; } // NOLINT
FmtElm(Handle<Object> value) : type_(HANDLE) { data_.u_handle_ = value.location(); } FmtElm(Handle<Object> value) : type_(HANDLE) { data_.u_handle_ = value.location(); } // NOLINT
FmtElm(void* value) : type_(INT) { data_.u_int_ = reinterpret_cast<int>(value); } FmtElm(void* value) : type_(INT) { data_.u_int_ = reinterpret_cast<int>(value); } // NOLINT
private: private:
friend class StringStream; friend class StringStream;
enum Type { INT, C_STR, OBJ, HANDLE }; enum Type { INT, C_STR, OBJ, HANDLE };
......
...@@ -210,7 +210,7 @@ class PreallocatedMemoryThread: public Thread { ...@@ -210,7 +210,7 @@ class PreallocatedMemoryThread: public Thread {
static char* data_; static char* data_;
static unsigned length_; static unsigned length_;
DISALLOW_EVIL_CONSTRUCTORS(PreallocatedMemoryThread); DISALLOW_COPY_AND_ASSIGN(PreallocatedMemoryThread);
}; };
PreallocatedMemoryThread* PreallocatedMemoryThread::the_thread_ = NULL; PreallocatedMemoryThread* PreallocatedMemoryThread::the_thread_ = NULL;
......
This diff is collapsed.
...@@ -327,7 +327,7 @@ static void PrepareStep(StepAction step_action) { ...@@ -327,7 +327,7 @@ static void PrepareStep(StepAction step_action) {
// This function is in namespace v8::internal to be friend with class // This function is in namespace v8::internal to be friend with class
// v8::internal::Debug. // v8::internal::Debug.
namespace v8 { namespace internal { namespace v8 { namespace internal { // NOLINT
// Collect the currently debugged functions. // Collect the currently debugged functions.
Handle<FixedArray> GetDebuggedFunctions() { Handle<FixedArray> GetDebuggedFunctions() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment