}
-Object* CallStubCompiler::GenerateMissBranch() {
- Object* obj = StubCache::ComputeCallMiss(arguments().immediate(), kind_);
- if (obj->IsFailure()) return obj;
- __ Jump(Handle<Code>(Code::cast(obj)), RelocInfo::CODE_TARGET);
- return obj;
+void CallStubCompiler::GenerateMissBranch() {
+ Handle<Code> ic = ComputeCallMiss(arguments().immediate(), kind_);
+ __ Jump(ic, RelocInfo::CODE_TARGET);
}
// Handle call cache miss.
__ bind(&miss);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ GenerateMissBranch();
// Return the generated code.
return GetCode(FIELD, name);
// Handle call cache miss.
__ bind(&miss);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ GenerateMissBranch();
// Return the generated code.
return GetCode(function);
// Handle call cache miss.
__ bind(&miss);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ GenerateMissBranch();
// Return the generated code.
return GetCode(function);
}
__ bind(&miss_in_smi_check);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ GenerateMissBranch();
// Return the generated code.
return GetCode(function);
// Handle call cache miss.
__ bind(&miss);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ GenerateMissBranch();
// Return the generated code.
return GetCode(INTERCEPTOR, name);
// Handle call cache miss.
__ bind(&miss);
__ IncrementCounter(&Counters::call_global_inline_miss, 1, r1, r3);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ GenerateMissBranch();
// Return the generated code.
return GetCode(NORMAL, name);
return old;
}
-inline bool Heap::allow_gc(bool new_state) {
- bool old = gc_allowed_;
- gc_allowed_ = new_state;
- return old;
-}
-
#endif
#ifdef DEBUG
bool Heap::allocation_allowed_ = true;
-bool Heap::gc_allowed_ = true;
int Heap::allocation_timeout_ = 0;
bool Heap::disallow_allocation_failure_ = false;
void Heap::GarbageCollectionPrologue() {
-#ifdef DEBUG
- ASSERT(gc_allowed_);
-#endif
TranscendentalCache::Clear();
ClearJSFunctionResultCaches();
gc_count_++;
#ifdef DEBUG
static bool IsAllocationAllowed() { return allocation_allowed_; }
static inline bool allow_allocation(bool enable);
- static bool IsGCAllowed() { return gc_allowed_; }
- static inline bool allow_gc(bool enable);
static bool disallow_allocation_failure() {
return disallow_allocation_failure_;
#ifdef DEBUG
static bool allocation_allowed_;
- static bool gc_allowed_;
// If the --gc-interval flag is set to a positive value, this
// variable holds the value indicating the number of allocations
bool old_state_;
};
-class AssertNoGC {
- public:
- AssertNoGC() {
- old_state_ = Heap::allow_gc(false);
- }
-
- ~AssertNoGC() {
- Heap::allow_gc(old_state_);
- }
-
- private:
- bool old_state_;
-};
-
class DisableAssertNoAllocation {
public:
DisableAssertNoAllocation() {
~AssertNoAllocation() { }
};
-class AssertNoGC {
- public:
- AssertNoGC() { }
- ~AssertNoGC() { }
-};
-
class DisableAssertNoAllocation {
public:
DisableAssertNoAllocation() { }
}
-Object* CallStubCompiler::GenerateMissBranch() {
- Object* obj = StubCache::ComputeCallMiss(arguments().immediate(), kind_);
- if (obj->IsFailure()) return obj;
- __ jmp(Handle<Code>(Code::cast(obj)), RelocInfo::CODE_TARGET);
- return obj;
+void CallStubCompiler::GenerateMissBranch() {
+ Handle<Code> ic = ComputeCallMiss(arguments().immediate(), kind_);
+ __ jmp(ic, RelocInfo::CODE_TARGET);
}
// Handle call cache miss.
__ bind(&miss);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ GenerateMissBranch();
// Return the generated code.
return GetCode(FIELD, name);
}
__ bind(&miss);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ GenerateMissBranch();
// Return the generated code.
return GetCode(function);
1);
__ bind(&miss);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ GenerateMissBranch();
// Return the generated code.
return GetCode(function);
__ ret((argc + 1) * kPointerSize);
__ bind(&miss);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+
+ GenerateMissBranch();
// Return the generated code.
return GetCode(function);
__ ret((argc + 1) * kPointerSize);
__ bind(&miss);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ // Restore function name in ecx.
+
+ GenerateMissBranch();
// Return the generated code.
return GetCode(function);
FreeSpaceForFastApiCall(masm(), eax);
}
__ bind(&miss_in_smi_check);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ GenerateMissBranch();
// Return the generated code.
return GetCode(function);
// Handle load cache miss.
__ bind(&miss);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ GenerateMissBranch();
// Return the generated code.
return GetCode(INTERCEPTOR, name);
// Handle call cache miss.
__ bind(&miss);
__ IncrementCounter(&Counters::call_global_inline_miss, 1);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ GenerateMissBranch();
// Return the generated code.
return GetCode(NORMAL, name);
// Lookup the property in the object.
LookupResult lookup;
- {
- AssertNoGC nogc; // GC could invalidate the pointers held in lookup.
+ LookupForRead(*object, *name, &lookup);
- LookupForRead(*object, *name, &lookup);
-
- if (!lookup.IsProperty()) {
- // If the object does not have the requested property, check which
- // exception we need to throw.
- if (IsContextual(object)) {
- return ReferenceError("not_defined", name);
- }
- return TypeError("undefined_method", object, name);
+ if (!lookup.IsProperty()) {
+ // If the object does not have the requested property, check which
+ // exception we need to throw.
+ if (IsContextual(object)) {
+ return ReferenceError("not_defined", name);
}
+ return TypeError("undefined_method", object, name);
+ }
- // Lookup is valid: Update inline cache and stub cache.
- if (FLAG_use_ic) {
- UpdateCaches(&lookup, state, object, name);
- }
+ // Lookup is valid: Update inline cache and stub cache.
+ if (FLAG_use_ic) {
+ UpdateCaches(&lookup, state, object, name);
}
// Get the property.
// Named lookup in the object.
LookupResult lookup;
- {
- AssertNoGC nogc; // GC could invalidate the pointers held in lookup.
-
- LookupForRead(*object, *name, &lookup);
+ LookupForRead(*object, *name, &lookup);
- // If we did not find a property, check if we need to throw an exception.
- if (!lookup.IsProperty()) {
- if (FLAG_strict || IsContextual(object)) {
- return ReferenceError("not_defined", name);
- }
- LOG(SuspectReadEvent(*name, *object));
+ // If we did not find a property, check if we need to throw an exception.
+ if (!lookup.IsProperty()) {
+ if (FLAG_strict || IsContextual(object)) {
+ return ReferenceError("not_defined", name);
}
+ LOG(SuspectReadEvent(*name, *object));
+ }
- bool can_be_inlined =
- FLAG_use_ic &&
- state == PREMONOMORPHIC &&
- lookup.IsProperty() &&
- lookup.IsCacheable() &&
- lookup.holder() == *object &&
- lookup.type() == FIELD &&
- !object->IsAccessCheckNeeded();
-
- if (can_be_inlined) {
- Map* map = lookup.holder()->map();
- // Property's index in the properties array. If negative we have
- // an inobject property.
- int index = lookup.GetFieldIndex() - map->inobject_properties();
- if (index < 0) {
- // Index is an offset from the end of the object.
- int offset = map->instance_size() + (index * kPointerSize);
- if (PatchInlinedLoad(address(), map, offset)) {
- set_target(megamorphic_stub());
- #ifdef DEBUG
- if (FLAG_trace_ic) {
- PrintF("[LoadIC : inline patch %s]\n", *name->ToCString());
- }
- #endif
- return lookup.holder()->FastPropertyAt(lookup.GetFieldIndex());
- #ifdef DEBUG
- } else {
- if (FLAG_trace_ic) {
- PrintF("[LoadIC : no inline patch %s (patching failed)]\n",
- *name->ToCString());
- }
+ bool can_be_inlined =
+ FLAG_use_ic &&
+ state == PREMONOMORPHIC &&
+ lookup.IsProperty() &&
+ lookup.IsCacheable() &&
+ lookup.holder() == *object &&
+ lookup.type() == FIELD &&
+ !object->IsAccessCheckNeeded();
+
+ if (can_be_inlined) {
+ Map* map = lookup.holder()->map();
+ // Property's index in the properties array. If negative we have
+ // an inobject property.
+ int index = lookup.GetFieldIndex() - map->inobject_properties();
+ if (index < 0) {
+ // Index is an offset from the end of the object.
+ int offset = map->instance_size() + (index * kPointerSize);
+ if (PatchInlinedLoad(address(), map, offset)) {
+ set_target(megamorphic_stub());
+#ifdef DEBUG
+ if (FLAG_trace_ic) {
+ PrintF("[LoadIC : inline patch %s]\n", *name->ToCString());
}
+#endif
+ return lookup.holder()->FastPropertyAt(lookup.GetFieldIndex());
+#ifdef DEBUG
} else {
if (FLAG_trace_ic) {
- PrintF("[LoadIC : no inline patch %s (not inobject)]\n",
+ PrintF("[LoadIC : no inline patch %s (patching failed)]\n",
*name->ToCString());
}
}
} else {
- if (FLAG_use_ic && state == PREMONOMORPHIC) {
- if (FLAG_trace_ic) {
- PrintF("[LoadIC : no inline patch %s (not inlinable)]\n",
- *name->ToCString());
- #endif
- }
+ if (FLAG_trace_ic) {
+ PrintF("[LoadIC : no inline patch %s (not inobject)]\n",
+ *name->ToCString());
}
}
-
- // Update inline cache and stub cache.
- if (FLAG_use_ic) {
- UpdateCaches(&lookup, state, object, name);
+ } else {
+ if (FLAG_use_ic && state == PREMONOMORPHIC) {
+ if (FLAG_trace_ic) {
+ PrintF("[LoadIC : no inline patch %s (not inlinable)]\n",
+ *name->ToCString());
+#endif
+ }
}
}
+ // Update inline cache and stub cache.
+ if (FLAG_use_ic) {
+ UpdateCaches(&lookup, state, object, name);
+ }
+
PropertyAttributes attr;
if (lookup.IsProperty() && lookup.type() == INTERCEPTOR) {
// Get the property.
// Named lookup.
LookupResult lookup;
- {
- AssertNoGC nogc; // GC could invalidate the pointers held in lookup.
-
- LookupForRead(*object, *name, &lookup);
+ LookupForRead(*object, *name, &lookup);
- // If we did not find a property, check if we need to throw an exception.
- if (!lookup.IsProperty()) {
- if (FLAG_strict || IsContextual(object)) {
- return ReferenceError("not_defined", name);
- }
+ // If we did not find a property, check if we need to throw an exception.
+ if (!lookup.IsProperty()) {
+ if (FLAG_strict || IsContextual(object)) {
+ return ReferenceError("not_defined", name);
}
+ }
- if (FLAG_use_ic) {
- UpdateCaches(&lookup, state, object, name);
- }
+ if (FLAG_use_ic) {
+ UpdateCaches(&lookup, state, object, name);
}
PropertyAttributes attr;
// Lookup the property locally in the receiver.
if (FLAG_use_ic && !receiver->IsJSGlobalProxy()) {
- AssertNoGC nogc; // GC could invalidate the pointers held in lookup.
-
LookupResult lookup;
if (LookupForWrite(*receiver, *name, &lookup)) {
return *value;
}
- {
- AssertNoGC nogc; // GC could invalidate the pointers held in lookup.
-
- // Lookup the property locally in the receiver.
- LookupResult lookup;
- receiver->LocalLookup(*name, &lookup);
+ // Lookup the property locally in the receiver.
+ LookupResult lookup;
+ receiver->LocalLookup(*name, &lookup);
- // Update inline cache and stub cache.
- if (FLAG_use_ic) {
- UpdateCaches(&lookup, state, receiver, name, value);
- }
+ // Update inline cache and stub cache.
+ if (FLAG_use_ic) {
+ UpdateCaches(&lookup, state, receiver, name, value);
}
// Set the property.
// StubCompiler implementation.
+// Support function for computing call IC miss stubs.
+Handle<Code> ComputeCallMiss(int argc, Code::Kind kind) {
+ CALL_HEAP_FUNCTION(StubCache::ComputeCallMiss(argc, kind), Code);
+}
+
+
+
Object* LoadCallbackProperty(Arguments args) {
ASSERT(args[0]->IsJSObject());
ASSERT(args[1]->IsJSObject());
Object* KeyedLoadPropertyWithInterceptor(Arguments args);
+// Support function for computing call IC miss stubs.
+Handle<Code> ComputeCallMiss(int argc, Code::Kind kind);
+
+
// The stub compiler compiles stubs for the stub cache.
class StubCompiler BASE_EMBEDDED {
public:
void GenerateNameCheck(String* name, Label* miss);
- // Generates a jump to CallIC miss stub. Returns Failure if the jump cannot
- // be generated.
- Object* GenerateMissBranch();
+ void GenerateMissBranch();
};
}
-Object* CallStubCompiler::GenerateMissBranch() {
- Object* obj = StubCache::ComputeCallMiss(arguments().immediate(), kind_);
- if (obj->IsFailure()) return obj;
- __ Jump(Handle<Code>(Code::cast(obj)), RelocInfo::CODE_TARGET);
- return obj;
+void CallStubCompiler::GenerateMissBranch() {
+ Handle<Code> ic = ComputeCallMiss(arguments().immediate(), kind_);
+ __ Jump(ic, RelocInfo::CODE_TARGET);
}
// Handle call cache miss.
__ bind(&miss_in_smi_check);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ GenerateMissBranch();
// Return the generated code.
return GetCode(function);
// Handle call cache miss.
__ bind(&miss);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ GenerateMissBranch();
// Return the generated code.
return GetCode(FIELD, name);
}
__ bind(&miss);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+
+ GenerateMissBranch();
// Return the generated code.
return GetCode(function);
argc + 1,
1);
__ bind(&miss);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+
+ GenerateMissBranch();
// Return the generated code.
return GetCode(function);
// Handle load cache miss.
__ bind(&miss);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ GenerateMissBranch();
// Return the generated code.
return GetCode(INTERCEPTOR, name);
// Handle call cache miss.
__ bind(&miss);
__ IncrementCounter(&Counters::call_global_inline_miss, 1);
- Object* obj = GenerateMissBranch();
- if (obj->IsFailure()) return obj;
+ GenerateMissBranch();
// Return the generated code.
return GetCode(NORMAL, name);