Get gcc to check that we don't ignore return values of functions that can

fail to allocate because we need a GC.
Review URL: http://codereview.chromium.org/3274008

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5379 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
erik.corry@gmail.com 2010-08-31 08:05:42 +00:00
parent 903571b233
commit 663f378da5
13 changed files with 364 additions and 290 deletions

View File

@ -75,8 +75,10 @@ class Accessors : public AllStatic {
};
// Accessor functions called directly from the runtime system.
static Object* FunctionGetPrototype(Object* object, void*);
static Object* FunctionSetPrototype(JSObject* object, Object* value, void*);
MUST_USE_RESULT static Object* FunctionGetPrototype(Object* object, void*);
MUST_USE_RESULT static Object* FunctionSetPrototype(JSObject* object,
Object* value,
void*);
private:
// Accessor functions only used through the descriptor.
static Object* FunctionGetLength(Object* object, void*);

View File

@ -243,7 +243,7 @@ BUILTIN(ArrayCodeGeneric) {
}
static Object* AllocateJSArray() {
MUST_USE_RESULT static Object* AllocateJSArray() {
JSFunction* array_function =
Top::context()->global_context()->array_function();
Object* result = Heap::AllocateJSObject(array_function);
@ -252,7 +252,7 @@ static Object* AllocateJSArray() {
}
static Object* AllocateEmptyJSArray() {
MUST_USE_RESULT static Object* AllocateEmptyJSArray() {
Object* result = AllocateJSArray();
if (result->IsFailure()) return result;
JSArray* result_array = JSArray::cast(result);

View File

@ -1007,17 +1007,18 @@ Handle<Object> Debug::CheckBreakPoints(Handle<Object> break_point_objects) {
for (int i = 0; i < array->length(); i++) {
Handle<Object> o(array->get(i));
if (CheckBreakPoint(o)) {
break_points_hit->SetElement(break_points_hit_count++, *o);
SetElement(break_points_hit, break_points_hit_count++, o);
}
}
} else {
if (CheckBreakPoint(break_point_objects)) {
break_points_hit->SetElement(break_points_hit_count++,
*break_point_objects);
SetElement(break_points_hit,
break_points_hit_count++,
break_point_objects);
}
}
// Return undefined if no break points where triggered.
// Return undefined if no break points were triggered.
if (break_points_hit_count == 0) {
return Factory::undefined_value();
}

View File

@ -664,7 +664,7 @@ F FUNCTION_CAST(Address addr) {
#define TRACK_MEMORY(name)
#endif
// define used for helping GCC to make better inlining. Don't bother for debug
// Define used for helping GCC to make better inlining. Don't bother for debug
// builds. On GCC 3.4.5 using __attribute__((always_inline)) causes compilation
// errors in debug build.
#if defined(__GNUC__) && !defined(DEBUG)
@ -680,6 +680,14 @@ F FUNCTION_CAST(Address addr) {
#define NO_INLINE(header) header
#endif
#if defined(__GNUC__) && __GNUC__ >= 4
#define MUST_USE_RESULT __attribute__ ((warn_unused_result))
#else
#define MUST_USE_RESULT
#endif
// Feature flags bit positions. They are mostly based on the CPUID spec.
// (We assign CPUID itself to one of the currently reserved bits --
// feel free to change this if needed.)

View File

@ -314,61 +314,64 @@ class Heap : public AllStatic {
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
static Object* AllocateJSObject(JSFunction* constructor,
PretenureFlag pretenure = NOT_TENURED);
MUST_USE_RESULT static Object* AllocateJSObject(
JSFunction* constructor, PretenureFlag pretenure = NOT_TENURED);
// Allocates and initializes a new global object based on a constructor.
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
static Object* AllocateGlobalObject(JSFunction* constructor);
MUST_USE_RESULT static Object* AllocateGlobalObject(JSFunction* constructor);
// Returns a deep copy of the JavaScript object.
// Properties and elements are copied too.
// Returns failure if allocation failed.
static Object* CopyJSObject(JSObject* source);
MUST_USE_RESULT static Object* CopyJSObject(JSObject* source);
// Allocates the function prototype.
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
static Object* AllocateFunctionPrototype(JSFunction* function);
MUST_USE_RESULT static Object* AllocateFunctionPrototype(
JSFunction* function);
// Reinitialize an JSGlobalProxy based on a constructor. The object
// must have the same size as objects allocated using the
// constructor. The object is reinitialized and behaves as an
// object that has been freshly allocated using the constructor.
static Object* ReinitializeJSGlobalProxy(JSFunction* constructor,
JSGlobalProxy* global);
MUST_USE_RESULT static Object* ReinitializeJSGlobalProxy(
JSFunction* constructor,
JSGlobalProxy* global);
// Allocates and initializes a new JavaScript object based on a map.
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
static Object* AllocateJSObjectFromMap(Map* map,
PretenureFlag pretenure = NOT_TENURED);
MUST_USE_RESULT static Object* AllocateJSObjectFromMap(
Map* map, PretenureFlag pretenure = NOT_TENURED);
// Allocates a heap object based on the map.
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this function does not perform a garbage collection.
static Object* Allocate(Map* map, AllocationSpace space);
MUST_USE_RESULT static Object* Allocate(Map* map, AllocationSpace space);
// Allocates a JS Map in the heap.
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this function does not perform a garbage collection.
static Object* AllocateMap(InstanceType instance_type, int instance_size);
MUST_USE_RESULT static Object* AllocateMap(InstanceType instance_type,
int instance_size);
// Allocates a partial map for bootstrapping.
static Object* AllocatePartialMap(InstanceType instance_type,
int instance_size);
MUST_USE_RESULT static Object* AllocatePartialMap(InstanceType instance_type,
int instance_size);
// Allocate a map for the specified function
static Object* AllocateInitialMap(JSFunction* fun);
MUST_USE_RESULT static Object* AllocateInitialMap(JSFunction* fun);
// Allocates an empty code cache.
static Object* AllocateCodeCache();
MUST_USE_RESULT static Object* AllocateCodeCache();
// Clear the Instanceof cache (used when a prototype changes).
static void ClearInstanceofCache() {
@ -393,13 +396,13 @@ class Heap : public AllStatic {
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
static Object* AllocateStringFromAscii(
MUST_USE_RESULT static Object* AllocateStringFromAscii(
Vector<const char> str,
PretenureFlag pretenure = NOT_TENURED);
static Object* AllocateStringFromUtf8(
MUST_USE_RESULT static Object* AllocateStringFromUtf8(
Vector<const char> str,
PretenureFlag pretenure = NOT_TENURED);
static Object* AllocateStringFromTwoByte(
MUST_USE_RESULT static Object* AllocateStringFromTwoByte(
Vector<const uc16> str,
PretenureFlag pretenure = NOT_TENURED);
@ -407,16 +410,15 @@ class Heap : public AllStatic {
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this function does not perform a garbage collection.
static inline Object* AllocateSymbol(Vector<const char> str,
int chars,
uint32_t hash_field);
MUST_USE_RESULT static inline Object* AllocateSymbol(Vector<const char> str,
int chars,
uint32_t hash_field);
static Object* AllocateInternalSymbol(unibrow::CharacterStream* buffer,
int chars,
uint32_t hash_field);
MUST_USE_RESULT static Object* AllocateInternalSymbol(
unibrow::CharacterStream* buffer, int chars, uint32_t hash_field);
static Object* AllocateExternalSymbol(Vector<const char> str,
int chars);
MUST_USE_RESULT static Object* AllocateExternalSymbol(Vector<const char> str,
int chars);
// Allocates and partially initializes a String. There are two String
@ -426,10 +428,10 @@ class Heap : public AllStatic {
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
static Object* AllocateRawAsciiString(
MUST_USE_RESULT static Object* AllocateRawAsciiString(
int length,
PretenureFlag pretenure = NOT_TENURED);
static Object* AllocateRawTwoByteString(
MUST_USE_RESULT static Object* AllocateRawTwoByteString(
int length,
PretenureFlag pretenure = NOT_TENURED);
@ -437,97 +439,103 @@ class Heap : public AllStatic {
// A cache is used for ascii codes.
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed. Please note this does not perform a garbage collection.
static Object* LookupSingleCharacterStringFromCode(uint16_t code);
MUST_USE_RESULT static Object* LookupSingleCharacterStringFromCode(
uint16_t code);
// Allocate a byte array of the specified length
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
static Object* AllocateByteArray(int length, PretenureFlag pretenure);
MUST_USE_RESULT static Object* AllocateByteArray(int length,
PretenureFlag pretenure);
// Allocate a non-tenured byte array of the specified length
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
static Object* AllocateByteArray(int length);
MUST_USE_RESULT static Object* AllocateByteArray(int length);
// Allocate a pixel array of the specified length
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
static Object* AllocatePixelArray(int length,
uint8_t* external_pointer,
PretenureFlag pretenure);
MUST_USE_RESULT static Object* AllocatePixelArray(int length,
uint8_t* external_pointer,
PretenureFlag pretenure);
// Allocates an external array of the specified length and type.
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
static Object* AllocateExternalArray(int length,
ExternalArrayType array_type,
void* external_pointer,
PretenureFlag pretenure);
MUST_USE_RESULT static Object* AllocateExternalArray(
int length,
ExternalArrayType array_type,
void* external_pointer,
PretenureFlag pretenure);
// Allocate a tenured JS global property cell.
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
static Object* AllocateJSGlobalPropertyCell(Object* value);
MUST_USE_RESULT static Object* AllocateJSGlobalPropertyCell(Object* value);
// Allocates a fixed array initialized with undefined values
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
static Object* AllocateFixedArray(int length, PretenureFlag pretenure);
MUST_USE_RESULT static Object* AllocateFixedArray(int length,
PretenureFlag pretenure);
// Allocates a fixed array initialized with undefined values
static Object* AllocateFixedArray(int length);
MUST_USE_RESULT static Object* AllocateFixedArray(int length);
// Allocates an uninitialized fixed array. It must be filled by the caller.
//
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
static Object* AllocateUninitializedFixedArray(int length);
MUST_USE_RESULT static Object* AllocateUninitializedFixedArray(int length);
// Make a copy of src and return it. Returns
// Failure::RetryAfterGC(requested_bytes, space) if the allocation failed.
static Object* CopyFixedArray(FixedArray* src);
MUST_USE_RESULT static Object* CopyFixedArray(FixedArray* src);
// Allocates a fixed array initialized with the hole values.
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
static Object* AllocateFixedArrayWithHoles(
MUST_USE_RESULT static Object* AllocateFixedArrayWithHoles(
int length,
PretenureFlag pretenure = NOT_TENURED);
// AllocateHashTable is identical to AllocateFixedArray except
// that the resulting object has hash_table_map as map.
static Object* AllocateHashTable(int length,
PretenureFlag pretenure = NOT_TENURED);
MUST_USE_RESULT static Object* AllocateHashTable(
int length, PretenureFlag pretenure = NOT_TENURED);
// Allocate a global (but otherwise uninitialized) context.
static Object* AllocateGlobalContext();
MUST_USE_RESULT static Object* AllocateGlobalContext();
// Allocate a function context.
static Object* AllocateFunctionContext(int length, JSFunction* closure);
MUST_USE_RESULT static Object* AllocateFunctionContext(int length,
JSFunction* closure);
// Allocate a 'with' context.
static Object* AllocateWithContext(Context* previous,
JSObject* extension,
bool is_catch_context);
MUST_USE_RESULT static Object* AllocateWithContext(Context* previous,
JSObject* extension,
bool is_catch_context);
// Allocates a new utility object in the old generation.
static Object* AllocateStruct(InstanceType type);
MUST_USE_RESULT static Object* AllocateStruct(InstanceType type);
// Allocates a function initialized with a shared part.
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
static Object* AllocateFunction(Map* function_map,
SharedFunctionInfo* shared,
Object* prototype,
PretenureFlag pretenure = TENURED);
MUST_USE_RESULT static Object* AllocateFunction(
Map* function_map,
SharedFunctionInfo* shared,
Object* prototype,
PretenureFlag pretenure = TENURED);
// Indicies for direct access into argument objects.
static const int kArgumentsObjectSize =
@ -539,47 +547,52 @@ class Heap : public AllStatic {
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
static Object* AllocateArgumentsObject(Object* callee, int length);
MUST_USE_RESULT static Object* AllocateArgumentsObject(Object* callee,
int length);
// Same as NewNumberFromDouble, but may return a preallocated/immutable
// number object (e.g., minus_zero_value_, nan_value_)
static Object* NumberFromDouble(double value,
PretenureFlag pretenure = NOT_TENURED);
MUST_USE_RESULT static Object* NumberFromDouble(
double value, PretenureFlag pretenure = NOT_TENURED);
// Allocated a HeapNumber from value.
static Object* AllocateHeapNumber(double value, PretenureFlag pretenure);
static Object* AllocateHeapNumber(double value); // pretenure = NOT_TENURED
MUST_USE_RESULT static Object* AllocateHeapNumber(double value,
PretenureFlag pretenure);
// pretenure = NOT_TENURED.
MUST_USE_RESULT static Object* AllocateHeapNumber(double value);
// Converts an int into either a Smi or a HeapNumber object.
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
static inline Object* NumberFromInt32(int32_t value);
MUST_USE_RESULT static inline Object* NumberFromInt32(int32_t value);
// Converts an int into either a Smi or a HeapNumber object.
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
static inline Object* NumberFromUint32(uint32_t value);
MUST_USE_RESULT static inline Object* NumberFromUint32(uint32_t value);
// Allocates a new proxy object.
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
static Object* AllocateProxy(Address proxy,
PretenureFlag pretenure = NOT_TENURED);
MUST_USE_RESULT static Object* AllocateProxy(
Address proxy,
PretenureFlag pretenure = NOT_TENURED);
// Allocates a new SharedFunctionInfo object.
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
static Object* AllocateSharedFunctionInfo(Object* name);
MUST_USE_RESULT static Object* AllocateSharedFunctionInfo(Object* name);
// Allocates a new cons string object.
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
static Object* AllocateConsString(String* first, String* second);
MUST_USE_RESULT static Object* AllocateConsString(String* first,
String* second);
// Allocates a new sub string object which is a substring of an underlying
// string buffer stretching from the index start (inclusive) to the index
@ -587,19 +600,20 @@ class Heap : public AllStatic {
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
static Object* AllocateSubString(String* buffer,
int start,
int end,
PretenureFlag pretenure = NOT_TENURED);
MUST_USE_RESULT static Object* AllocateSubString(
String* buffer,
int start,
int end,
PretenureFlag pretenure = NOT_TENURED);
// Allocate a new external string object, which is backed by a string
// resource that resides outside the V8 heap.
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
static Object* AllocateExternalStringFromAscii(
MUST_USE_RESULT static Object* AllocateExternalStringFromAscii(
ExternalAsciiString::Resource* resource);
static Object* AllocateExternalStringFromTwoByte(
MUST_USE_RESULT static Object* AllocateExternalStringFromTwoByte(
ExternalTwoByteString::Resource* resource);
// Finalizes an external string by deleting the associated external
@ -611,9 +625,10 @@ class Heap : public AllStatic {
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this function does not perform a garbage collection.
static inline Object* AllocateRaw(int size_in_bytes,
AllocationSpace space,
AllocationSpace retry_space);
MUST_USE_RESULT static inline Object* AllocateRaw(
int size_in_bytes,
AllocationSpace space,
AllocationSpace retry_space);
// Initialize a filler object to keep the ability to iterate over the heap
// when shortening objects.
@ -625,26 +640,26 @@ class Heap : public AllStatic {
// self_reference. This allows generated code to reference its own Code
// object by containing this pointer.
// Please note this function does not perform a garbage collection.
static Object* CreateCode(const CodeDesc& desc,
Code::Flags flags,
Handle<Object> self_reference);
MUST_USE_RESULT static Object* CreateCode(const CodeDesc& desc,
Code::Flags flags,
Handle<Object> self_reference);
static Object* CopyCode(Code* code);
MUST_USE_RESULT static Object* CopyCode(Code* code);
// Copy the code and scope info part of the code object, but insert
// the provided data as the relocation information.
static Object* CopyCode(Code* code, Vector<byte> reloc_info);
MUST_USE_RESULT static Object* CopyCode(Code* code, Vector<byte> reloc_info);
// Finds the symbol for string in the symbol table.
// If not found, a new symbol is added to the table and returned.
// Returns Failure::RetryAfterGC(requested_bytes, space) if allocation
// failed.
// Please note this function does not perform a garbage collection.
static Object* LookupSymbol(Vector<const char> str);
static Object* LookupAsciiSymbol(const char* str) {
MUST_USE_RESULT static Object* LookupSymbol(Vector<const char> str);
MUST_USE_RESULT static Object* LookupAsciiSymbol(const char* str) {
return LookupSymbol(CStrVector(str));
}
static Object* LookupSymbol(String* str);
MUST_USE_RESULT static Object* LookupSymbol(String* str);
static bool LookupSymbolIfExists(String* str, String** symbol);
static bool LookupTwoCharsSymbolIfExists(String* str, String** symbol);
@ -659,7 +674,7 @@ class Heap : public AllStatic {
// string might stay non-flat even when not a failure is returned.
//
// Please note this function does not perform a garbage collection.
static inline Object* PrepareForCompare(String* str);
MUST_USE_RESULT static inline Object* PrepareForCompare(String* str);
// Converts the given boolean condition to JavaScript boolean value.
static Object* ToBoolean(bool condition) {
@ -865,8 +880,10 @@ class Heap : public AllStatic {
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this function does not perform a garbage collection.
static Object* CreateSymbol(const char* str, int length, int hash);
static Object* CreateSymbol(String* str);
MUST_USE_RESULT static Object* CreateSymbol(const char* str,
int length,
int hash);
MUST_USE_RESULT static Object* CreateSymbol(String* str);
// Write barrier support for address[offset] = o.
static inline void RecordWrite(Address address, int offset);
@ -938,9 +955,9 @@ class Heap : public AllStatic {
static inline int AdjustAmountOfExternalAllocatedMemory(int change_in_bytes);
// Allocate uninitialized fixed array.
static Object* AllocateRawFixedArray(int length);
static Object* AllocateRawFixedArray(int length,
PretenureFlag pretenure);
MUST_USE_RESULT static Object* AllocateRawFixedArray(int length);
MUST_USE_RESULT static Object* AllocateRawFixedArray(int length,
PretenureFlag pretenure);
// True if we have reached the allocation limit in the old generation that
// should force the next GC (caused normally) to be a full one.
@ -983,8 +1000,9 @@ class Heap : public AllStatic {
kRootListLength
};
static Object* NumberToString(Object* number,
bool check_number_string_cache = true);
MUST_USE_RESULT static Object* NumberToString(
Object* number,
bool check_number_string_cache = true);
static Map* MapForExternalArrayType(ExternalArrayType array_type);
static RootListIndex RootIndexForExternalArrayType(
@ -1203,10 +1221,10 @@ class Heap : public AllStatic {
// to Heap::AllocateRaw(size_in_bytes, MAP_SPACE), except that (a) it doesn't
// have to test the allocation space argument and (b) can reduce code size
// (since both AllocateRaw and AllocateRawMap are inlined).
static inline Object* AllocateRawMap();
MUST_USE_RESULT static inline Object* AllocateRawMap();
// Allocate an uninitialized object in the global property cell space.
static inline Object* AllocateRawCell();
MUST_USE_RESULT static inline Object* AllocateRawCell();
// Initializes a JSObject based on its map.
static void InitializeJSObjectFromMap(JSObject* obj,
@ -1267,9 +1285,10 @@ class Heap : public AllStatic {
// other parts of the VM could use it. Specifically, a function that creates
// instances of type JS_FUNCTION_TYPE benefit from the use of this function.
// Please note this does not perform a garbage collection.
static inline Object* InitializeFunction(JSFunction* function,
SharedFunctionInfo* shared,
Object* prototype);
MUST_USE_RESULT static inline Object* InitializeFunction(
JSFunction* function,
SharedFunctionInfo* shared,
Object* prototype);
static GCTracer* tracer_;
@ -1883,7 +1902,7 @@ class TranscendentalCache {
// Returns a heap number with f(input), where f is a math function specified
// by the 'type' argument.
static inline Object* Get(Type type, double input) {
MUST_USE_RESULT static inline Object* Get(Type type, double input) {
TranscendentalCache* cache = caches_[type];
if (cache == NULL) {
caches_[type] = cache = new TranscendentalCache(type);
@ -1896,7 +1915,7 @@ class TranscendentalCache {
static void Clear();
private:
inline Object* Get(double input) {
MUST_USE_RESULT inline Object* Get(double input) {
Converter c;
c.dbl = input;
int hash = Hash(c);

View File

@ -739,7 +739,7 @@ void LiveEdit::WrapSharedFunctionInfos(Handle<JSArray> array) {
Handle<String> name_handle(String::cast(info->name()));
info_wrapper.SetProperties(name_handle, info->start_position(),
info->end_position(), info);
array->SetElement(i, *(info_wrapper.GetJSArray()));
SetElement(array, i, info_wrapper.GetJSArray());
}
}
@ -1359,8 +1359,9 @@ static const char* DropActivationsInActiveThread(
for (int i = 0; i < array_len; i++) {
if (result->GetElement(i) ==
Smi::FromInt(LiveEdit::FUNCTION_BLOCKED_ON_ACTIVE_STACK)) {
result->SetElement(i, Smi::FromInt(
LiveEdit::FUNCTION_REPLACED_ON_ACTIVE_STACK));
Handle<Object> replaced(
Smi::FromInt(LiveEdit::FUNCTION_REPLACED_ON_ACTIVE_STACK));
SetElement(result, i, replaced);
}
}
return NULL;

View File

@ -54,7 +54,8 @@ const int kGetterIndex = 0;
const int kSetterIndex = 1;
static Object* CreateJSValue(JSFunction* constructor, Object* value) {
MUST_USE_RESULT static Object* CreateJSValue(JSFunction* constructor,
Object* value) {
Object* result = Heap::AllocateJSObject(constructor);
if (result->IsFailure()) return result;
JSValue::cast(result)->set_value(value);

View File

@ -1274,7 +1274,7 @@ class JSObject: public HeapObject {
Object* PrepareElementsForSort(uint32_t limit);
// As PrepareElementsForSort, but only on objects where elements is
// a dictionary, and it will stay a dictionary.
Object* PrepareSlowElementsForSort(uint32_t limit);
MUST_USE_RESULT Object* PrepareSlowElementsForSort(uint32_t limit);
Object* SetProperty(String* key,
Object* value,
@ -1312,12 +1312,13 @@ class JSObject: public HeapObject {
// Sets the property value in a normalized object given (key, value, details).
// Handles the special representation of JS global objects.
Object* SetNormalizedProperty(String* name,
Object* value,
PropertyDetails details);
MUST_USE_RESULT Object* SetNormalizedProperty(String* name,
Object* value,
PropertyDetails details);
// Deletes the named property in a normalized object.
Object* DeleteNormalizedProperty(String* name, DeleteMode mode);
MUST_USE_RESULT Object* DeleteNormalizedProperty(String* name,
DeleteMode mode);
// Returns the class name ([[Class]] property in the specification).
String* class_name();
@ -1335,11 +1336,13 @@ class JSObject: public HeapObject {
String* name);
PropertyAttributes GetLocalPropertyAttribute(String* name);
Object* DefineAccessor(String* name, bool is_getter, JSFunction* fun,
PropertyAttributes attributes);
MUST_USE_RESULT Object* DefineAccessor(String* name,
bool is_getter,
JSFunction* fun,
PropertyAttributes attributes);
Object* LookupAccessor(String* name, bool is_getter);
Object* DefineAccessor(AccessorInfo* info);
MUST_USE_RESULT Object* DefineAccessor(AccessorInfo* info);
// Used from Object::GetProperty().
Object* GetPropertyWithFailedAccessCheck(Object* receiver,
@ -1390,8 +1393,8 @@ class JSObject: public HeapObject {
inline Object* GetHiddenPropertiesObject();
inline Object* SetHiddenPropertiesObject(Object* hidden_obj);
Object* DeleteProperty(String* name, DeleteMode mode);
Object* DeleteElement(uint32_t index, DeleteMode mode);
MUST_USE_RESULT Object* DeleteProperty(String* name, DeleteMode mode);
MUST_USE_RESULT Object* DeleteElement(uint32_t index, DeleteMode mode);
// Tests for the fast common case for property enumeration.
bool IsSimpleEnum();
@ -1419,19 +1422,20 @@ class JSObject: public HeapObject {
bool HasElementWithInterceptor(JSObject* receiver, uint32_t index);
bool HasElementPostInterceptor(JSObject* receiver, uint32_t index);
Object* SetFastElement(uint32_t index, Object* value);
MUST_USE_RESULT Object* SetFastElement(uint32_t index, Object* value);
// Set the index'th array element.
// A Failure object is returned if GC is needed.
Object* SetElement(uint32_t index, Object* value);
MUST_USE_RESULT Object* SetElement(uint32_t index, Object* value);
// Returns the index'th element.
// The undefined object if index is out of bounds.
Object* GetElementWithReceiver(JSObject* receiver, uint32_t index);
Object* GetElementWithInterceptor(JSObject* receiver, uint32_t index);
Object* SetFastElementsCapacityAndLength(int capacity, int length);
Object* SetSlowElements(Object* length);
MUST_USE_RESULT Object* SetFastElementsCapacityAndLength(int capacity,
int length);
MUST_USE_RESULT Object* SetSlowElements(Object* length);
// Lookup interceptors are used for handling properties controlled by host
// objects.
@ -1444,7 +1448,7 @@ class JSObject: public HeapObject {
bool HasRealNamedCallbackProperty(String* key);
// Initializes the array to a certain length
Object* SetElementsLength(Object* length);
MUST_USE_RESULT Object* SetElementsLength(Object* length);
// Get the header size for a JSObject. Used to compute the index of
// internal fields as well as the number of internal fields.
@ -1581,7 +1585,7 @@ class JSObject: public HeapObject {
static inline JSObject* cast(Object* obj);
// Disalow further properties to be added to the object.
Object* PreventExtensions();
MUST_USE_RESULT Object* PreventExtensions();
// Dispatched behavior.
@ -1654,16 +1658,20 @@ class JSObject: public HeapObject {
uint32_t index,
Object* value,
JSObject* holder);
Object* SetElementWithInterceptor(uint32_t index, Object* value);
Object* SetElementWithoutInterceptor(uint32_t index, Object* value);
MUST_USE_RESULT Object* SetElementWithInterceptor(uint32_t index,
Object* value);
MUST_USE_RESULT Object* SetElementWithoutInterceptor(uint32_t index,
Object* value);
Object* GetElementPostInterceptor(JSObject* receiver, uint32_t index);
Object* DeletePropertyPostInterceptor(String* name, DeleteMode mode);
Object* DeletePropertyWithInterceptor(String* name);
MUST_USE_RESULT Object* DeletePropertyPostInterceptor(String* name,
DeleteMode mode);
MUST_USE_RESULT Object* DeletePropertyWithInterceptor(String* name);
Object* DeleteElementPostInterceptor(uint32_t index, DeleteMode mode);
Object* DeleteElementWithInterceptor(uint32_t index);
MUST_USE_RESULT Object* DeleteElementPostInterceptor(uint32_t index,
DeleteMode mode);
MUST_USE_RESULT Object* DeleteElementWithInterceptor(uint32_t index);
PropertyAttributes GetPropertyAttributePostInterceptor(JSObject* receiver,
String* name,
@ -1685,13 +1693,14 @@ class JSObject: public HeapObject {
bool HasDenseElements();
bool CanSetCallback(String* name);
Object* SetElementCallback(uint32_t index,
Object* structure,
PropertyAttributes attributes);
Object* SetPropertyCallback(String* name,
Object* structure,
PropertyAttributes attributes);
Object* DefineGetterSetter(String* name, PropertyAttributes attributes);
MUST_USE_RESULT Object* SetElementCallback(uint32_t index,
Object* structure,
PropertyAttributes attributes);
MUST_USE_RESULT Object* SetPropertyCallback(String* name,
Object* structure,
PropertyAttributes attributes);
MUST_USE_RESULT Object* DefineGetterSetter(String* name,
PropertyAttributes attributes);
void LookupInDescriptor(String* name, LookupResult* result);
@ -1730,13 +1739,13 @@ class FixedArray: public HeapObject {
// Copy operations.
inline Object* Copy();
Object* CopySize(int new_length);
MUST_USE_RESULT Object* CopySize(int new_length);
// Add the elements of a JSArray to this FixedArray.
Object* AddKeysFromJSArray(JSArray* array);
MUST_USE_RESULT Object* AddKeysFromJSArray(JSArray* array);
// Compute the union of this and other.
Object* UnionOfKeys(FixedArray* other);
MUST_USE_RESULT Object* UnionOfKeys(FixedArray* other);
// Copy a sub array from the receiver to dest.
void CopyTo(int pos, FixedArray* dest, int dest_pos, int len);
@ -1875,11 +1884,12 @@ class DescriptorArray: public FixedArray {
// or null), its enumeration index is kept as is.
// If adding a real property, map transitions must be removed. If adding
// a transition, they must not be removed. All null descriptors are removed.
Object* CopyInsert(Descriptor* descriptor, TransitionFlag transition_flag);
MUST_USE_RESULT Object* CopyInsert(Descriptor* descriptor,
TransitionFlag transition_flag);
// Remove all transitions. Return a copy of the array with all transitions
// removed, or a Failure object if the new array could not be allocated.
Object* RemoveTransitions();
MUST_USE_RESULT Object* RemoveTransitions();
// Sort the instance descriptors by the hash codes of their keys.
void Sort();
@ -1907,7 +1917,7 @@ class DescriptorArray: public FixedArray {
// Allocates a DescriptorArray, but returns the singleton
// empty descriptor array object if number_of_descriptors is 0.
static Object* Allocate(int number_of_descriptors);
MUST_USE_RESULT static Object* Allocate(int number_of_descriptors);
// Casting.
static inline DescriptorArray* cast(Object* obj);
@ -2047,8 +2057,9 @@ class HashTable: public FixedArray {
}
// Returns a new HashTable object. Might return Failure.
static Object* Allocate(int at_least_space_for,
PretenureFlag pretenure = NOT_TENURED);
MUST_USE_RESULT static Object* Allocate(
int at_least_space_for,
PretenureFlag pretenure = NOT_TENURED);
// Returns the key at entry.
Object* KeyAt(int entry) { return get(EntryToIndex(entry)); }
@ -2142,7 +2153,7 @@ class HashTable: public FixedArray {
}
// Ensure enough space for n additional elements.
Object* EnsureCapacity(int n, Key key);
MUST_USE_RESULT Object* EnsureCapacity(int n, Key key);
};
@ -2158,7 +2169,7 @@ class HashTableKey {
virtual uint32_t HashForObject(Object* key) = 0;
// Returns the key object for storing into the hash table.
// If allocations fails a failure object is returned.
virtual Object* AsObject() = 0;
MUST_USE_RESULT virtual Object* AsObject() = 0;
// Required.
virtual ~HashTableKey() {}
};
@ -2174,7 +2185,7 @@ class SymbolTableShape {
static uint32_t HashForObject(HashTableKey* key, Object* object) {
return key->HashForObject(object);
}
static Object* AsObject(HashTableKey* key) {
MUST_USE_RESULT static Object* AsObject(HashTableKey* key) {
return key->AsObject();
}
@ -2224,7 +2235,7 @@ class MapCacheShape {
return key->HashForObject(object);
}
static Object* AsObject(HashTableKey* key) {
MUST_USE_RESULT static Object* AsObject(HashTableKey* key) {
return key->AsObject();
}
@ -2312,7 +2323,7 @@ class Dictionary: public HashTable<Shape, Key> {
}
// Returns a new array for dictionary usage. Might return Failure.
static Object* Allocate(int at_least_space_for);
MUST_USE_RESULT static Object* Allocate(int at_least_space_for);
// Ensure enough space for n additional elements.
Object* EnsureCapacity(int n, Key key);
@ -2354,7 +2365,7 @@ class StringDictionaryShape {
static inline bool IsMatch(String* key, Object* other);
static inline uint32_t Hash(String* key);
static inline uint32_t HashForObject(String* key, Object* object);
static inline Object* AsObject(String* key);
MUST_USE_RESULT static inline Object* AsObject(String* key);
static const int kPrefixSize = 2;
static const int kEntrySize = 3;
static const bool kIsEnumerable = true;
@ -2386,7 +2397,7 @@ class NumberDictionaryShape {
static inline bool IsMatch(uint32_t key, Object* other);
static inline uint32_t Hash(uint32_t key);
static inline uint32_t HashForObject(uint32_t key, Object* object);
static inline Object* AsObject(uint32_t key);
MUST_USE_RESULT static inline Object* AsObject(uint32_t key);
static const int kPrefixSize = 2;
static const int kEntrySize = 3;
static const bool kIsEnumerable = false;
@ -3152,13 +3163,13 @@ class Map: public HeapObject {
// [stub cache]: contains stubs compiled for this map.
DECL_ACCESSORS(code_cache, Object)
Object* CopyDropDescriptors();
MUST_USE_RESULT Object* CopyDropDescriptors();
Object* CopyNormalized(PropertyNormalizationMode mode);
MUST_USE_RESULT Object* CopyNormalized(PropertyNormalizationMode mode);
// Returns a copy of the map, with all transitions dropped from the
// instance descriptors.
Object* CopyDropTransitions();
MUST_USE_RESULT Object* CopyDropTransitions();
// Returns this map if it has the fast elements bit set, otherwise
// returns a copy of the map, with all transitions dropped from the
@ -3191,7 +3202,7 @@ class Map: public HeapObject {
inline void ClearCodeCache();
// Update code cache.
Object* UpdateCodeCache(String* name, Code* code);
MUST_USE_RESULT Object* UpdateCodeCache(String* name, Code* code);
// Returns the found code or undefined if absent.
Object* FindInCodeCache(String* name, Code::Flags flags);
@ -3720,7 +3731,7 @@ class JSFunction: public JSObject {
inline Object* prototype();
inline Object* instance_prototype();
Object* SetInstancePrototype(Object* value);
Object* SetPrototype(Object* value);
MUST_USE_RESULT Object* SetPrototype(Object* value);
// After prototype is removed, it will not be created when accessed, and
// [[Construct]] from this function will not be allowed.
@ -4061,7 +4072,7 @@ class CompilationCacheShape {
return key->HashForObject(object);
}
static Object* AsObject(HashTableKey* key) {
MUST_USE_RESULT static Object* AsObject(HashTableKey* key) {
return key->AsObject();
}
@ -4094,7 +4105,7 @@ class CodeCache: public Struct {
DECL_ACCESSORS(normal_type_cache, Object)
// Add the code object to the cache.
Object* Update(String* name, Code* code);
MUST_USE_RESULT Object* Update(String* name, Code* code);
// Lookup code object in the cache. Returns code object if found and undefined
// if not.
@ -4122,8 +4133,8 @@ class CodeCache: public Struct {
static const int kSize = kNormalTypeCacheOffset + kPointerSize;
private:
Object* UpdateDefaultCache(String* name, Code* code);
Object* UpdateNormalTypeCache(String* name, Code* code);
MUST_USE_RESULT Object* UpdateDefaultCache(String* name, Code* code);
MUST_USE_RESULT Object* UpdateNormalTypeCache(String* name, Code* code);
Object* LookupDefaultCache(String* name, Code::Flags flags);
Object* LookupNormalTypeCache(String* name, Code::Flags flags);
@ -4151,7 +4162,7 @@ class CodeCacheHashTableShape {
return key->HashForObject(object);
}
static Object* AsObject(HashTableKey* key) {
MUST_USE_RESULT static Object* AsObject(HashTableKey* key) {
return key->AsObject();
}
@ -4164,7 +4175,7 @@ class CodeCacheHashTable: public HashTable<CodeCacheHashTableShape,
HashTableKey*> {
public:
Object* Lookup(String* name, Code::Flags flags);
Object* Put(String* name, Code* code);
MUST_USE_RESULT Object* Put(String* name, Code* code);
int GetIndex(String* name, Code::Flags flags);
void RemoveByIndex(int index);
@ -5031,12 +5042,13 @@ class JSArray: public JSObject {
// is set to a smi. This matches the set function on FixedArray.
inline void set_length(Smi* length);
Object* JSArrayUpdateLengthFromIndex(uint32_t index, Object* value);
MUST_USE_RESULT Object* JSArrayUpdateLengthFromIndex(uint32_t index,
Object* value);
// Initialize the array with the given capacity. The function may
// fail due to out-of-memory situations, but only if the requested
// capacity is non-zero.
Object* Initialize(int capacity);
MUST_USE_RESULT Object* Initialize(int capacity);
// Set the content of the array to the content of storage.
inline void SetContent(FixedArray* storage);

View File

@ -4282,7 +4282,11 @@ Expression* Parser::NewThrowError(Handle<String> constructor,
for (int i = 0; i < argc; i++) {
Handle<Object> element = arguments[i];
if (!element.is_null()) {
array->SetFastElement(i, *element);
Object* ok = array->SetFastElement(i, *element);
USE(ok); // Don't get an unused variable warning.
// We know this doesn't cause a GC here because we allocated the JSArray
// large enough.
ASSERT(!ok->IsFailure());
}
}
ZoneList<Expression*>* args = new ZoneList<Expression*>(2);

View File

@ -98,7 +98,7 @@ namespace internal {
static StaticResource<StringInputBuffer> runtime_string_input_buffer;
static Object* DeepCopyBoilerplate(JSObject* boilerplate) {
MUST_USE_RESULT static Object* DeepCopyBoilerplate(JSObject* boilerplate) {
StackLimitCheck check;
if (check.HasOverflowed()) return Top::StackOverflow();
@ -980,7 +980,9 @@ static Object* Runtime_DeclareContextSlot(Arguments args) {
context->set(index, *initial_value);
}
} else {
Handle<JSObject>::cast(holder)->SetElement(index, *initial_value);
// The holder is an arguments object.
Handle<JSObject> arguments(Handle<JSObject>::cast(holder));
SetElement(arguments, index, initial_value);
}
} else {
// Slow case: The property is not in the FixedArray part of the context.
@ -1238,7 +1240,8 @@ static Object* Runtime_InitializeConstContextSlot(Arguments args) {
} else {
// The holder is an arguments object.
ASSERT((attributes & READ_ONLY) == 0);
Handle<JSObject>::cast(holder)->SetElement(index, *value);
Handle<JSObject> arguments(Handle<JSObject>::cast(holder));
SetElement(arguments, index, value);
}
return *value;
}
@ -4105,7 +4108,8 @@ static Object* Runtime_DefineOrRedefineAccessorProperty(Arguments args) {
if (result.IsProperty() &&
(result.type() == FIELD || result.type() == NORMAL
|| result.type() == CONSTANT_FUNCTION)) {
obj->DeleteProperty(name, JSObject::NORMAL_DELETION);
Object* ok = obj->DeleteProperty(name, JSObject::NORMAL_DELETION);
if (ok->IsFailure()) return ok;
}
return obj->DefineAccessor(name, flag_setter->value() == 0, fun, attr);
}

View File

@ -56,158 +56,167 @@ class StubCache : public AllStatic {
// Computes the right stub matching. Inserts the result in the
// cache before returning. This might compile a stub if needed.
static Object* ComputeLoadNonexistent(String* name, JSObject* receiver);
MUST_USE_RESULT static Object* ComputeLoadNonexistent(String* name,
JSObject* receiver);
static Object* ComputeLoadField(String* name,
JSObject* receiver,
JSObject* holder,
int field_index);
MUST_USE_RESULT static Object* ComputeLoadField(String* name,
JSObject* receiver,
JSObject* holder,
int field_index);
static Object* ComputeLoadCallback(String* name,
JSObject* receiver,
JSObject* holder,
AccessorInfo* callback);
MUST_USE_RESULT static Object* ComputeLoadCallback(String* name,
JSObject* receiver,
JSObject* holder,
AccessorInfo* callback);
static Object* ComputeLoadConstant(String* name,
JSObject* receiver,
JSObject* holder,
Object* value);
MUST_USE_RESULT static Object* ComputeLoadConstant(String* name,
JSObject* receiver,
JSObject* holder,
Object* value);
static Object* ComputeLoadInterceptor(String* name,
JSObject* receiver,
JSObject* holder);
MUST_USE_RESULT static Object* ComputeLoadInterceptor(String* name,
JSObject* receiver,
JSObject* holder);
static Object* ComputeLoadNormal();
MUST_USE_RESULT static Object* ComputeLoadNormal();
static Object* ComputeLoadGlobal(String* name,
JSObject* receiver,
GlobalObject* holder,
JSGlobalPropertyCell* cell,
bool is_dont_delete);
MUST_USE_RESULT static Object* ComputeLoadGlobal(String* name,
JSObject* receiver,
GlobalObject* holder,
JSGlobalPropertyCell* cell,
bool is_dont_delete);
// ---
static Object* ComputeKeyedLoadField(String* name,
JSObject* receiver,
JSObject* holder,
int field_index);
MUST_USE_RESULT static Object* ComputeKeyedLoadField(String* name,
JSObject* receiver,
JSObject* holder,
int field_index);
static Object* ComputeKeyedLoadCallback(String* name,
JSObject* receiver,
JSObject* holder,
AccessorInfo* callback);
MUST_USE_RESULT static Object* ComputeKeyedLoadCallback(
String* name,
JSObject* receiver,
JSObject* holder,
AccessorInfo* callback);
static Object* ComputeKeyedLoadConstant(String* name, JSObject* receiver,
JSObject* holder, Object* value);
MUST_USE_RESULT static Object* ComputeKeyedLoadConstant(String* name,
JSObject* receiver,
JSObject* holder,
Object* value);
static Object* ComputeKeyedLoadInterceptor(String* name,
JSObject* receiver,
JSObject* holder);
MUST_USE_RESULT static Object* ComputeKeyedLoadInterceptor(String* name,
JSObject* receiver,
JSObject* holder);
static Object* ComputeKeyedLoadArrayLength(String* name, JSArray* receiver);
MUST_USE_RESULT static Object* ComputeKeyedLoadArrayLength(String* name,
JSArray* receiver);
static Object* ComputeKeyedLoadStringLength(String* name,
String* receiver);
MUST_USE_RESULT static Object* ComputeKeyedLoadStringLength(String* name,
String* receiver);
static Object* ComputeKeyedLoadFunctionPrototype(String* name,
JSFunction* receiver);
MUST_USE_RESULT static Object* ComputeKeyedLoadFunctionPrototype(
String* name,
JSFunction* receiver);
// ---
static Object* ComputeStoreField(String* name,
JSObject* receiver,
int field_index,
Map* transition = NULL);
MUST_USE_RESULT static Object* ComputeStoreField(String* name,
JSObject* receiver,
int field_index,
Map* transition = NULL);
static Object* ComputeStoreNormal();
MUST_USE_RESULT static Object* ComputeStoreNormal();
static Object* ComputeStoreGlobal(String* name,
GlobalObject* receiver,
JSGlobalPropertyCell* cell);
MUST_USE_RESULT static Object* ComputeStoreGlobal(String* name,
GlobalObject* receiver,
JSGlobalPropertyCell* cell);
static Object* ComputeStoreCallback(String* name,
JSObject* receiver,
AccessorInfo* callback);
MUST_USE_RESULT static Object* ComputeStoreCallback(String* name,
JSObject* receiver,
AccessorInfo* callback);
static Object* ComputeStoreInterceptor(String* name, JSObject* receiver);
MUST_USE_RESULT static Object* ComputeStoreInterceptor(String* name,
JSObject* receiver);
// ---
static Object* ComputeKeyedStoreField(String* name,
JSObject* receiver,
int field_index,
Map* transition = NULL);
MUST_USE_RESULT static Object* ComputeKeyedStoreField(String* name,
JSObject* receiver,
int field_index,
Map* transition = NULL);
// ---
static Object* ComputeCallField(int argc,
InLoopFlag in_loop,
Code::Kind,
String* name,
Object* object,
JSObject* holder,
int index);
MUST_USE_RESULT static Object* ComputeCallField(int argc,
InLoopFlag in_loop,
Code::Kind,
String* name,
Object* object,
JSObject* holder,
int index);
static Object* ComputeCallConstant(int argc,
InLoopFlag in_loop,
Code::Kind,
String* name,
Object* object,
JSObject* holder,
JSFunction* function);
MUST_USE_RESULT static Object* ComputeCallConstant(int argc,
InLoopFlag in_loop,
Code::Kind,
String* name,
Object* object,
JSObject* holder,
JSFunction* function);
static Object* ComputeCallNormal(int argc,
InLoopFlag in_loop,
Code::Kind,
String* name,
JSObject* receiver);
MUST_USE_RESULT static Object* ComputeCallNormal(int argc,
InLoopFlag in_loop,
Code::Kind,
String* name,
JSObject* receiver);
static Object* ComputeCallInterceptor(int argc,
Code::Kind,
String* name,
Object* object,
JSObject* holder);
MUST_USE_RESULT static Object* ComputeCallInterceptor(int argc,
Code::Kind,
String* name,
Object* object,
JSObject* holder);
static Object* ComputeCallGlobal(int argc,
InLoopFlag in_loop,
Code::Kind,
String* name,
JSObject* receiver,
GlobalObject* holder,
JSGlobalPropertyCell* cell,
JSFunction* function);
MUST_USE_RESULT static Object* ComputeCallGlobal(int argc,
InLoopFlag in_loop,
Code::Kind,
String* name,
JSObject* receiver,
GlobalObject* holder,
JSGlobalPropertyCell* cell,
JSFunction* function);
// ---
static Object* ComputeCallInitialize(int argc,
InLoopFlag in_loop,
Code::Kind kind);
MUST_USE_RESULT static Object* ComputeCallInitialize(int argc,
InLoopFlag in_loop,
Code::Kind kind);
static Object* ComputeCallPreMonomorphic(int argc,
InLoopFlag in_loop,
Code::Kind kind);
MUST_USE_RESULT static Object* ComputeCallPreMonomorphic(int argc,
InLoopFlag in_loop,
Code::Kind kind);
static Object* ComputeCallNormal(int argc,
InLoopFlag in_loop,
Code::Kind kind);
MUST_USE_RESULT static Object* ComputeCallNormal(int argc,
InLoopFlag in_loop,
Code::Kind kind);
static Object* ComputeCallMegamorphic(int argc,
InLoopFlag in_loop,
Code::Kind kind);
MUST_USE_RESULT static Object* ComputeCallMegamorphic(int argc,
InLoopFlag in_loop,
Code::Kind kind);
static Object* ComputeCallMiss(int argc, Code::Kind kind);
MUST_USE_RESULT static Object* ComputeCallMiss(int argc, Code::Kind kind);
// Finds the Code object stored in the Heap::non_monomorphic_cache().
static Code* FindCallInitialize(int argc,
InLoopFlag in_loop,
Code::Kind kind);
MUST_USE_RESULT static Code* FindCallInitialize(int argc,
InLoopFlag in_loop,
Code::Kind kind);
#ifdef ENABLE_DEBUGGER_SUPPORT
static Object* ComputeCallDebugBreak(int argc, Code::Kind kind);
MUST_USE_RESULT static Object* ComputeCallDebugBreak(int argc,
Code::Kind kind);
static Object* ComputeCallDebugPrepareStepIn(int argc, Code::Kind kind);
MUST_USE_RESULT static Object* ComputeCallDebugPrepareStepIn(int argc,
Code::Kind kind);
#endif
// Update cache for entry hash(name, map).

View File

@ -637,22 +637,27 @@ TEST(JSArray) {
// Allocate the object.
Handle<JSObject> object = Factory::NewJSObject(function);
Handle<JSArray> array = Handle<JSArray>::cast(object);
array->Initialize(0);
Object* ok = array->Initialize(0);
// We just initialized the VM, no heap allocation failure yet.
CHECK(!ok->IsFailure());
// Set array length to 0.
array->SetElementsLength(Smi::FromInt(0));
ok = array->SetElementsLength(Smi::FromInt(0));
CHECK(!ok->IsFailure());
CHECK_EQ(Smi::FromInt(0), array->length());
CHECK(array->HasFastElements()); // Must be in fast mode.
// array[length] = name.
array->SetElement(0, *name);
ok = array->SetElement(0, *name);
CHECK(!ok->IsFailure());
CHECK_EQ(Smi::FromInt(1), array->length());
CHECK_EQ(array->GetElement(0), *name);
// Set array length with larger than smi value.
Handle<Object> length =
Factory::NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1);
array->SetElementsLength(*length);
ok = array->SetElementsLength(*length);
CHECK(!ok->IsFailure());
uint32_t int_length = 0;
CHECK(length->ToArrayIndex(&int_length));
@ -660,7 +665,8 @@ TEST(JSArray) {
CHECK(array->HasDictionaryElements()); // Must be in slow mode.
// array[length] = name.
array->SetElement(int_length, *name);
ok = array->SetElement(int_length, *name);
CHECK(!ok->IsFailure());
uint32_t new_int_length = 0;
CHECK(array->length()->ToArrayIndex(&new_int_length));
CHECK_EQ(static_cast<double>(int_length), new_int_length - 1);
@ -684,8 +690,11 @@ TEST(JSObjectCopy) {
obj->SetProperty(*first, Smi::FromInt(1), NONE);
obj->SetProperty(*second, Smi::FromInt(2), NONE);
obj->SetElement(0, *first);
obj->SetElement(1, *second);
Object* ok = obj->SetElement(0, *first);
CHECK(!ok->IsFailure());
ok = obj->SetElement(1, *second);
CHECK(!ok->IsFailure());
// Make the clone.
Handle<JSObject> clone = Copy(obj);
@ -701,8 +710,10 @@ TEST(JSObjectCopy) {
clone->SetProperty(*first, Smi::FromInt(2), NONE);
clone->SetProperty(*second, Smi::FromInt(1), NONE);
clone->SetElement(0, *second);
clone->SetElement(1, *first);
ok = clone->SetElement(0, *second);
CHECK(!ok->IsFailure());
ok = clone->SetElement(1, *first);
CHECK(!ok->IsFailure());
CHECK_EQ(obj->GetElement(1), clone->GetElement(0));
CHECK_EQ(obj->GetElement(0), clone->GetElement(1));

View File

@ -67,7 +67,9 @@ function testAssignmentArgument(x) {
assertEquals(7, x);
}
testAssignmentArgument();
for (var i = 0; i < 10000; i++) {
testAssignmentArgument();
}
assertEquals(6, x);
__defineSetter__('x', function() { throw 42; });