Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Unified Diff: src/runtime.cc

Issue 558041: RFC: Try to be much more careful with where we skip the write barrier by:... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
===================================================================
--- src/runtime.cc (revision 3737)
+++ src/runtime.cc (working copy)
@@ -107,25 +107,23 @@
// Deep copy local properties.
if (copy->HasFastProperties()) {
FixedArray* properties = copy->properties();
- WriteBarrierMode mode = properties->GetWriteBarrierMode();
for (int i = 0; i < properties->length(); i++) {
Object* value = properties->get(i);
if (value->IsJSObject()) {
- JSObject* jsObject = JSObject::cast(value);
- result = DeepCopyBoilerplate(jsObject);
+ JSObject* js_object = JSObject::cast(value);
+ result = DeepCopyBoilerplate(js_object);
if (result->IsFailure()) return result;
- properties->set(i, result, mode);
+ properties->set(i, result);
}
}
- mode = copy->GetWriteBarrierMode();
int nof = copy->map()->inobject_properties();
for (int i = 0; i < nof; i++) {
Object* value = copy->InObjectPropertyAt(i);
if (value->IsJSObject()) {
- JSObject* jsObject = JSObject::cast(value);
- result = DeepCopyBoilerplate(jsObject);
+ JSObject* js_object = JSObject::cast(value);
+ result = DeepCopyBoilerplate(js_object);
if (result->IsFailure()) return result;
- copy->InObjectPropertyAtPut(i, result, mode);
+ copy->InObjectPropertyAtPut(i, result);
}
}
} else {
@@ -135,20 +133,20 @@
copy->GetLocalPropertyNames(names, 0);
for (int i = 0; i < names->length(); i++) {
ASSERT(names->get(i)->IsString());
- String* keyString = String::cast(names->get(i));
+ String* key_string = String::cast(names->get(i));
PropertyAttributes attributes =
- copy->GetLocalPropertyAttribute(keyString);
+ copy->GetLocalPropertyAttribute(key_string);
// Only deep copy fields from the object literal expression.
// In particular, don't try to copy the length attribute of
// an array.
if (attributes != NONE) continue;
- Object* value = copy->GetProperty(keyString, &attributes);
+ Object* value = copy->GetProperty(key_string, &attributes);
ASSERT(!value->IsFailure());
if (value->IsJSObject()) {
- JSObject* jsObject = JSObject::cast(value);
- result = DeepCopyBoilerplate(jsObject);
+ JSObject* js_object = JSObject::cast(value);
+ result = DeepCopyBoilerplate(js_object);
if (result->IsFailure()) return result;
- result = copy->SetProperty(keyString, result, NONE);
+ result = copy->SetProperty(key_string, result, NONE);
if (result->IsFailure()) return result;
}
}
@@ -160,14 +158,13 @@
switch (copy->GetElementsKind()) {
case JSObject::FAST_ELEMENTS: {
FixedArray* elements = FixedArray::cast(copy->elements());
- WriteBarrierMode mode = elements->GetWriteBarrierMode();
for (int i = 0; i < elements->length(); i++) {
Object* value = elements->get(i);
if (value->IsJSObject()) {
- JSObject* jsObject = JSObject::cast(value);
- result = DeepCopyBoilerplate(jsObject);
+ JSObject* js_object = JSObject::cast(value);
+ result = DeepCopyBoilerplate(js_object);
if (result->IsFailure()) return result;
- elements->set(i, result, mode);
+ elements->set(i, result);
}
}
break;
@@ -180,8 +177,8 @@
if (element_dictionary->IsKey(k)) {
Object* value = element_dictionary->ValueAt(i);
if (value->IsJSObject()) {
- JSObject* jsObject = JSObject::cast(value);
- result = DeepCopyBoilerplate(jsObject);
+ JSObject* js_object = JSObject::cast(value);
+ result = DeepCopyBoilerplate(js_object);
if (result->IsFailure()) return result;
element_dictionary->ValueAtPut(i, result);
}
@@ -1437,6 +1434,8 @@
literals->set(JSFunction::kLiteralGlobalContextIndex,
context->global_context());
}
+ // It's okay to skip the write barrier here because the literals
+ // are guaranteed to be in old space.
target->set_literals(*literals, SKIP_WRITE_BARRIER);
}
@@ -4715,7 +4714,9 @@
if (obj->IsFailure()) return obj;
FixedArray* array = FixedArray::cast(obj);
ASSERT(array->length() == length);
- WriteBarrierMode mode = array->GetWriteBarrierMode();
+
+ AssertNoAllocation no_gc;
+ WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc);
for (int i = 0; i < length; i++) {
array->set(i, frame->GetParameter(i), mode);
}
@@ -4740,10 +4741,13 @@
// Allocate the fixed array.
Object* obj = Heap::AllocateRawFixedArray(length);
if (obj->IsFailure()) return obj;
+
+ AssertNoAllocation no_gc;
reinterpret_cast<Array*>(obj)->set_map(Heap::fixed_array_map());
FixedArray* array = FixedArray::cast(obj);
array->set_length(length);
- WriteBarrierMode mode = array->GetWriteBarrierMode();
+
+ WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc);
for (int i = 0; i < length; i++) {
array->set(i, *--parameters, mode);
}
@@ -6032,7 +6036,7 @@
to->SetContent(FixedArray::cast(from->elements()));
to->set_length(from->length());
from->SetContent(Heap::empty_fixed_array());
- from->set_length(0);
+ from->set_length(Smi::FromInt(0));
return to;
}
@@ -6075,9 +6079,7 @@
} else {
Handle<FixedArray> single_interval = Factory::NewFixedArray(2);
// -1 means start of array.
- single_interval->set(0,
- Smi::FromInt(-1),
- SKIP_WRITE_BARRIER);
+ single_interval->set(0, Smi::FromInt(-1));
uint32_t actual_length = static_cast<uint32_t>(array->elements()->length());
uint32_t min_length = actual_length < length ? actual_length : length;
Handle<Object> length_object =
@@ -7450,7 +7452,9 @@
const int length = frame->GetProvidedParametersCount();
Handle<JSObject> arguments = Factory::NewArgumentsObject(function, length);
Handle<FixedArray> array = Factory::NewFixedArray(length);
- WriteBarrierMode mode = array->GetWriteBarrierMode();
+
+ AssertNoAllocation no_gc;
+ WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc);
for (int i = 0; i < length; i++) {
array->set(i, frame->GetParameter(i), mode);
}
@@ -8032,7 +8036,7 @@
if (cursor + 2 < elements->length()) {
elements->set(cursor++, recv);
elements->set(cursor++, fun);
- elements->set(cursor++, offset, SKIP_WRITE_BARRIER);
+ elements->set(cursor++, offset);
} else {
HandleScope scope;
Handle<Object> recv_handle(recv);
@@ -8045,8 +8049,7 @@
iter.Advance();
}
- result->set_length(Smi::FromInt(cursor), SKIP_WRITE_BARRIER);
-
+ result->set_length(Smi::FromInt(cursor));
return *result;
}
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698