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