Changeset 102709 in webkit
- Timestamp:
- Dec 13, 2011 3:17:43 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r102699 r102709 1 2011-12-13 Oliver Hunt <oliver@apple.com> 2 3 Arguments object doesn't handle mutation of length property correctly 4 https://bugs.webkit.org/show_bug.cgi?id=74454 5 6 Reviewed by Gavin Barraclough. 7 8 Add tests of mutated arguments.length 9 10 * fast/js/arguments-expected.txt: 11 * fast/js/script-tests/arguments.js: 12 (argumentLengthIs5): 13 (duplicateArgumentAndReturnLast_call): 14 (duplicateArgumentAndReturnFirst_call): 15 (duplicateArgumentAndReturnLast_apply): 16 (duplicateArgumentAndReturnFirst_apply): 17 1 18 2011-12-13 Vsevolod Vlasov <vsevik@chromium.org> 2 19 -
trunk/LayoutTests/fast/js/arguments-expected.txt
r97768 r102709 19 19 PASS access_4(1, 2, 3, 4, 5) is 4 20 20 PASS access_5(1, 2, 3, 4, 5) is 5 21 PASS argumentLengthIs5() is 5 22 PASS argumentLengthIs5(1,2,3,4,5) is 5 23 PASS argumentLengthIs5(1,2,3,4,5,6,7,8,9,10) is 5 24 PASS duplicateArgumentAndReturnLast_call(1) is 1 25 PASS duplicateArgumentAndReturnFirst_call(1) is 1 26 PASS duplicateArgumentAndReturnLast_apply(1) is 1 27 PASS duplicateArgumentAndReturnFirst_apply(1) is 1 21 28 PASS tear_off_equal_access_1(1, 2, 3) is 1 22 29 PASS tear_off_equal_access_2(1, 2, 3) is 2 -
trunk/LayoutTests/fast/js/script-tests/arguments.js
r98407 r102709 26 26 { 27 27 return arguments[4]; 28 } 29 30 function argumentLengthIs5() { 31 arguments.length = 5; 32 return arguments.length; 33 } 34 35 function duplicateArgumentAndReturnLast_call(a) { 36 Array.prototype.push.call(arguments, a); 37 return arguments[1]; 38 } 39 40 function duplicateArgumentAndReturnFirst_call(a) { 41 Array.prototype.push.call(arguments, a); 42 return arguments[0]; 43 } 44 45 function duplicateArgumentAndReturnLast_apply(a) { 46 Array.prototype.push.apply(arguments, arguments); 47 return arguments[1]; 48 } 49 50 function duplicateArgumentAndReturnFirst_apply(a) { 51 Array.prototype.push.apply(arguments, arguments); 52 return arguments[0]; 28 53 } 29 54 … … 45 70 shouldBe("access_4(1, 2, 3, 4, 5)", "4"); 46 71 shouldBe("access_5(1, 2, 3, 4, 5)", "5"); 72 73 shouldBe("argumentLengthIs5()", "5"); 74 shouldBe("argumentLengthIs5(1,2,3,4,5)", "5"); 75 shouldBe("argumentLengthIs5(1,2,3,4,5,6,7,8,9,10)", "5"); 76 shouldBe("duplicateArgumentAndReturnLast_call(1)", "1"); 77 shouldBe("duplicateArgumentAndReturnFirst_call(1)", "1"); 78 shouldBe("duplicateArgumentAndReturnLast_apply(1)", "1"); 79 shouldBe("duplicateArgumentAndReturnFirst_apply(1)", "1"); 47 80 48 81 function f(a, b, c) -
trunk/Source/JavaScriptCore/ChangeLog
r102707 r102709 1 2011-12-13 Oliver Hunt <oliver@apple.com> 2 3 Arguments object doesn't handle mutation of length property correctly 4 https://bugs.webkit.org/show_bug.cgi?id=74454 5 6 Reviewed by Gavin Barraclough. 7 8 Correct handling of arguments objects with overridden length property 9 10 * interpreter/Interpreter.cpp: 11 (JSC::loadVarargs): 12 * runtime/Arguments.cpp: 13 (JSC::Arguments::copyToArguments): 14 (JSC::Arguments::fillArgList): 15 1 16 2011-12-13 Filip Pizlo <fpizlo@apple.com> 2 17 -
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r102545 r102709 496 496 Arguments* argsObject = asArguments(arguments); 497 497 unsigned argCount = argsObject->length(callFrame); 498 CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister + argCount + 1 + RegisterFile::CallFrameHeaderSize);498 CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister + CallFrame::offsetFor(argCount + 1)); 499 499 if (argCount > Arguments::MaxArguments || !registerFile->grow(newCallFrame->registers())) { 500 500 callFrame->globalData().exception = createStackOverflowError(callFrame); … … 510 510 JSArray* array = asArray(arguments); 511 511 unsigned argCount = array->length(); 512 CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister + argCount + 1 + RegisterFile::CallFrameHeaderSize);512 CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister + CallFrame::offsetFor(argCount + 1)); 513 513 if (argCount > Arguments::MaxArguments || !registerFile->grow(newCallFrame->registers())) { 514 514 callFrame->globalData().exception = createStackOverflowError(callFrame); … … 523 523 JSObject* argObject = asObject(arguments); 524 524 unsigned argCount = argObject->get(callFrame, callFrame->propertyNames().length).toUInt32(callFrame); 525 CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister + argCount + 1 + RegisterFile::CallFrameHeaderSize);525 CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister + CallFrame::offsetFor(argCount + 1)); 526 526 if (argCount > Arguments::MaxArguments || !registerFile->grow(newCallFrame->registers())) { 527 527 callFrame->globalData().exception = createStackOverflowError(callFrame); -
trunk/Source/JavaScriptCore/runtime/Arguments.cpp
r102545 r102709 55 55 void Arguments::copyToArguments(ExecState* exec, CallFrame* callFrame, uint32_t length) 56 56 { 57 if (UNLIKELY(d->overrodeLength)) { 58 length = min(get(exec, exec->propertyNames().length).toUInt32(exec), length); 59 for (unsigned i = 0; i < length; i++) 60 callFrame->setArgument(i, get(exec, i)); 61 return; 62 } 57 63 ASSERT(length == this->length(exec)); 58 64 for (size_t i = 0; i < length; ++i) { … … 66 72 void Arguments::fillArgList(ExecState* exec, MarkedArgumentBuffer& args) 67 73 { 74 if (UNLIKELY(d->overrodeLength)) { 75 unsigned length = get(exec, exec->propertyNames().length).toUInt32(exec); 76 for (unsigned i = 0; i < length; i++) 77 args.append(get(exec, i)); 78 return; 79 } 68 80 uint32_t length = this->length(exec); 69 81 for (size_t i = 0; i < length; ++i) {
Note: See TracChangeset
for help on using the changeset viewer.