Commit 8c2c7fde authored by antonm@chromium.org's avatar antonm@chromium.org

Fixing style of variable names.

Review URL: http://codereview.chromium.org/668149

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4034 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent d103ae66
...@@ -514,21 +514,21 @@ BUILTIN(ArraySlice) { ...@@ -514,21 +514,21 @@ BUILTIN(ArraySlice) {
int n_arguments = args.length() - 1; int n_arguments = args.length() - 1;
// Note carefully choosen defaults---if argument is missing, // Note carefully choosen defaults---if argument is missing,
// it's undefined which gets converted to 0 for relativeStart // it's undefined which gets converted to 0 for relative_start
// and to len for relativeEnd. // and to len for relative_end.
int relativeStart = 0; int relative_start = 0;
int relativeEnd = len; int relative_end = len;
if (n_arguments > 0) { if (n_arguments > 0) {
Object* arg1 = args[1]; Object* arg1 = args[1];
if (arg1->IsSmi()) { if (arg1->IsSmi()) {
relativeStart = Smi::cast(arg1)->value(); relative_start = Smi::cast(arg1)->value();
} else if (!arg1->IsUndefined()) { } else if (!arg1->IsUndefined()) {
return CallJsBuiltin("ArraySlice", args); return CallJsBuiltin("ArraySlice", args);
} }
if (n_arguments > 1) { if (n_arguments > 1) {
Object* arg2 = args[2]; Object* arg2 = args[2];
if (arg2->IsSmi()) { if (arg2->IsSmi()) {
relativeEnd = Smi::cast(arg2)->value(); relative_end = Smi::cast(arg2)->value();
} else if (!arg2->IsUndefined()) { } else if (!arg2->IsUndefined()) {
return CallJsBuiltin("ArraySlice", args); return CallJsBuiltin("ArraySlice", args);
} }
...@@ -536,12 +536,12 @@ BUILTIN(ArraySlice) { ...@@ -536,12 +536,12 @@ BUILTIN(ArraySlice) {
} }
// ECMAScript 232, 3rd Edition, Section 15.4.4.10, step 6. // ECMAScript 232, 3rd Edition, Section 15.4.4.10, step 6.
int k = (relativeStart < 0) ? Max(len + relativeStart, 0) int k = (relative_start < 0) ? Max(len + relative_start, 0)
: Min(relativeStart, len); : Min(relative_start, len);
// ECMAScript 232, 3rd Edition, Section 15.4.4.10, step 8. // ECMAScript 232, 3rd Edition, Section 15.4.4.10, step 8.
int final = (relativeEnd < 0) ? Max(len + relativeEnd, 0) int final = (relative_end < 0) ? Max(len + relative_end, 0)
: Min(relativeEnd, len); : Min(relative_end, len);
// Calculate the length of result array. // Calculate the length of result array.
int result_len = final - k; int result_len = final - k;
...@@ -592,35 +592,35 @@ BUILTIN(ArraySplice) { ...@@ -592,35 +592,35 @@ BUILTIN(ArraySplice) {
return Heap::undefined_value(); return Heap::undefined_value();
} }
int relativeStart = 0; int relative_start = 0;
Object* arg1 = args[1]; Object* arg1 = args[1];
if (arg1->IsSmi()) { if (arg1->IsSmi()) {
relativeStart = Smi::cast(arg1)->value(); relative_start = Smi::cast(arg1)->value();
} else if (!arg1->IsUndefined()) { } else if (!arg1->IsUndefined()) {
return CallJsBuiltin("ArraySplice", args); return CallJsBuiltin("ArraySplice", args);
} }
int actualStart = (relativeStart < 0) ? Max(len + relativeStart, 0) int actual_start = (relative_start < 0) ? Max(len + relative_start, 0)
: Min(relativeStart, len); : Min(relative_start, len);
// SpiderMonkey, TraceMonkey and JSC treat the case where no delete count is // SpiderMonkey, TraceMonkey and JSC treat the case where no delete count is
// given differently from when an undefined delete count is given. // given differently from when an undefined delete count is given.
// This does not follow ECMA-262, but we do the same for // This does not follow ECMA-262, but we do the same for
// compatibility. // compatibility.
int deleteCount = len; int delete_count = len;
if (n_arguments > 1) { if (n_arguments > 1) {
Object* arg2 = args[2]; Object* arg2 = args[2];
if (arg2->IsSmi()) { if (arg2->IsSmi()) {
deleteCount = Smi::cast(arg2)->value(); delete_count = Smi::cast(arg2)->value();
} else { } else {
return CallJsBuiltin("ArraySplice", args); return CallJsBuiltin("ArraySplice", args);
} }
} }
int actualDeleteCount = Min(Max(deleteCount, 0), len - actualStart); int actual_delete_count = Min(Max(delete_count, 0), len - actual_start);
FixedArray* elms = FixedArray::cast(array->elements()); FixedArray* elms = FixedArray::cast(array->elements());
JSArray* result_array = NULL; JSArray* result_array = NULL;
if (actualDeleteCount == 0) { if (actual_delete_count == 0) {
Object* result = AllocateEmptyJSArray(); Object* result = AllocateEmptyJSArray();
if (result->IsFailure()) return result; if (result->IsFailure()) return result;
result_array = JSArray::cast(result); result_array = JSArray::cast(result);
...@@ -630,37 +630,40 @@ BUILTIN(ArraySplice) { ...@@ -630,37 +630,40 @@ BUILTIN(ArraySplice) {
if (result->IsFailure()) return result; if (result->IsFailure()) return result;
result_array = JSArray::cast(result); result_array = JSArray::cast(result);
result = Heap::AllocateUninitializedFixedArray(actualDeleteCount); result = Heap::AllocateUninitializedFixedArray(actual_delete_count);
if (result->IsFailure()) return result; if (result->IsFailure()) return result;
FixedArray* result_elms = FixedArray::cast(result); FixedArray* result_elms = FixedArray::cast(result);
AssertNoAllocation no_gc; AssertNoAllocation no_gc;
// Fill newly created array. // Fill newly created array.
CopyElements(&no_gc, result_elms, 0, elms, actualStart, actualDeleteCount); CopyElements(&no_gc,
result_elms, 0,
elms, actual_start,
actual_delete_count);
// Set elements. // Set elements.
result_array->set_elements(result_elms); result_array->set_elements(result_elms);
// Set the length. // Set the length.
result_array->set_length(Smi::FromInt(actualDeleteCount)); result_array->set_length(Smi::FromInt(actual_delete_count));
} }
int itemCount = (n_arguments > 1) ? (n_arguments - 2) : 0; int item_count = (n_arguments > 1) ? (n_arguments - 2) : 0;
int new_length = len - actualDeleteCount + itemCount; int new_length = len - actual_delete_count + item_count;
if (itemCount < actualDeleteCount) { if (item_count < actual_delete_count) {
// Shrink the array. // Shrink the array.
AssertNoAllocation no_gc; AssertNoAllocation no_gc;
MoveElements(&no_gc, MoveElements(&no_gc,
elms, actualStart + itemCount, elms, actual_start + item_count,
elms, actualStart + actualDeleteCount, elms, actual_start + actual_delete_count,
(len - actualDeleteCount - actualStart)); (len - actual_delete_count - actual_start));
FillWithHoles(elms, new_length, len); FillWithHoles(elms, new_length, len);
} else if (itemCount > actualDeleteCount) { } else if (item_count > actual_delete_count) {
// Currently fixed arrays cannot grow too big, so // Currently fixed arrays cannot grow too big, so
// we should never hit this case. // we should never hit this case.
ASSERT((itemCount - actualDeleteCount) <= (Smi::kMaxValue - len)); ASSERT((item_count - actual_delete_count) <= (Smi::kMaxValue - len));
FixedArray* source_elms = elms; FixedArray* source_elms = elms;
...@@ -673,8 +676,8 @@ BUILTIN(ArraySplice) { ...@@ -673,8 +676,8 @@ BUILTIN(ArraySplice) {
FixedArray* new_elms = FixedArray::cast(obj); FixedArray* new_elms = FixedArray::cast(obj);
AssertNoAllocation no_gc; AssertNoAllocation no_gc;
// Copy the part before actualStart as is. // Copy the part before actual_start as is.
CopyElements(&no_gc, new_elms, 0, elms, 0, actualStart); CopyElements(&no_gc, new_elms, 0, elms, 0, actual_start);
FillWithHoles(new_elms, new_length, capacity); FillWithHoles(new_elms, new_length, capacity);
source_elms = elms; source_elms = elms;
...@@ -684,15 +687,15 @@ BUILTIN(ArraySplice) { ...@@ -684,15 +687,15 @@ BUILTIN(ArraySplice) {
AssertNoAllocation no_gc; AssertNoAllocation no_gc;
MoveElements(&no_gc, MoveElements(&no_gc,
elms, actualStart + itemCount, elms, actual_start + item_count,
source_elms, actualStart + actualDeleteCount, source_elms, actual_start + actual_delete_count,
(len - actualDeleteCount - actualStart)); (len - actual_delete_count - actual_start));
} }
AssertNoAllocation no_gc; AssertNoAllocation no_gc;
WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc); WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc);
for (int k = actualStart; k < actualStart + itemCount; k++) { for (int k = actual_start; k < actual_start + item_count; k++) {
elms->set(k, args[3 + k - actualStart], mode); elms->set(k, args[3 + k - actual_start], mode);
} }
// Set the length. // Set the length.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment