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

Side by Side Diff: src/ia32/code-stubs-ia32.cc

Issue 19492006: Cleanup StringAddFlags. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add extra ASSERTs. Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/code-stubs-ia32.h ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 // Test if left operand is a string. 1346 // Test if left operand is a string.
1347 __ JumpIfSmi(left, &call_runtime, Label::kNear); 1347 __ JumpIfSmi(left, &call_runtime, Label::kNear);
1348 __ CmpObjectType(left, FIRST_NONSTRING_TYPE, ecx); 1348 __ CmpObjectType(left, FIRST_NONSTRING_TYPE, ecx);
1349 __ j(above_equal, &call_runtime, Label::kNear); 1349 __ j(above_equal, &call_runtime, Label::kNear);
1350 1350
1351 // Test if right operand is a string. 1351 // Test if right operand is a string.
1352 __ JumpIfSmi(right, &call_runtime, Label::kNear); 1352 __ JumpIfSmi(right, &call_runtime, Label::kNear);
1353 __ CmpObjectType(right, FIRST_NONSTRING_TYPE, ecx); 1353 __ CmpObjectType(right, FIRST_NONSTRING_TYPE, ecx);
1354 __ j(above_equal, &call_runtime, Label::kNear); 1354 __ j(above_equal, &call_runtime, Label::kNear);
1355 1355
1356 StringAddStub string_add_stub((StringAddFlags) 1356 StringAddStub string_add_stub(
1357 (ERECT_FRAME | NO_STRING_CHECK_IN_STUB)); 1357 (StringAddFlags)(STRING_ADD_CHECK_NONE | STRING_ADD_ERECT_FRAME));
1358 GenerateRegisterArgsPush(masm); 1358 GenerateRegisterArgsPush(masm);
1359 __ TailCallStub(&string_add_stub); 1359 __ TailCallStub(&string_add_stub);
1360 1360
1361 __ bind(&call_runtime); 1361 __ bind(&call_runtime);
1362 GenerateTypeTransition(masm); 1362 GenerateTypeTransition(masm);
1363 } 1363 }
1364 1364
1365 1365
1366 static void BinaryOpStub_GenerateHeapResultAllocation(MacroAssembler* masm, 1366 static void BinaryOpStub_GenerateHeapResultAllocation(MacroAssembler* masm,
1367 Label* alloc_failure, 1367 Label* alloc_failure,
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
1992 1992
1993 // Registers containing left and right operands respectively. 1993 // Registers containing left and right operands respectively.
1994 Register left = edx; 1994 Register left = edx;
1995 Register right = eax; 1995 Register right = eax;
1996 1996
1997 // Test if left operand is a string. 1997 // Test if left operand is a string.
1998 __ JumpIfSmi(left, &left_not_string, Label::kNear); 1998 __ JumpIfSmi(left, &left_not_string, Label::kNear);
1999 __ CmpObjectType(left, FIRST_NONSTRING_TYPE, ecx); 1999 __ CmpObjectType(left, FIRST_NONSTRING_TYPE, ecx);
2000 __ j(above_equal, &left_not_string, Label::kNear); 2000 __ j(above_equal, &left_not_string, Label::kNear);
2001 2001
2002 StringAddStub string_add_left_stub((StringAddFlags) 2002 StringAddStub string_add_left_stub(
2003 (ERECT_FRAME | NO_STRING_CHECK_LEFT_IN_STUB)); 2003 (StringAddFlags)(STRING_ADD_CHECK_RIGHT | STRING_ADD_ERECT_FRAME));
2004 GenerateRegisterArgsPush(masm); 2004 GenerateRegisterArgsPush(masm);
2005 __ TailCallStub(&string_add_left_stub); 2005 __ TailCallStub(&string_add_left_stub);
2006 2006
2007 // Left operand is not a string, test right. 2007 // Left operand is not a string, test right.
2008 __ bind(&left_not_string); 2008 __ bind(&left_not_string);
2009 __ JumpIfSmi(right, &call_runtime, Label::kNear); 2009 __ JumpIfSmi(right, &call_runtime, Label::kNear);
2010 __ CmpObjectType(right, FIRST_NONSTRING_TYPE, ecx); 2010 __ CmpObjectType(right, FIRST_NONSTRING_TYPE, ecx);
2011 __ j(above_equal, &call_runtime, Label::kNear); 2011 __ j(above_equal, &call_runtime, Label::kNear);
2012 2012
2013 StringAddStub string_add_right_stub((StringAddFlags) 2013 StringAddStub string_add_right_stub(
2014 (ERECT_FRAME | NO_STRING_CHECK_RIGHT_IN_STUB)); 2014 (StringAddFlags)(STRING_ADD_CHECK_LEFT | STRING_ADD_ERECT_FRAME));
2015 GenerateRegisterArgsPush(masm); 2015 GenerateRegisterArgsPush(masm);
2016 __ TailCallStub(&string_add_right_stub); 2016 __ TailCallStub(&string_add_right_stub);
2017 2017
2018 // Neither argument is a string. 2018 // Neither argument is a string.
2019 __ bind(&call_runtime); 2019 __ bind(&call_runtime);
2020 } 2020 }
2021 2021
2022 2022
2023 static void BinaryOpStub_GenerateHeapResultAllocation(MacroAssembler* masm, 2023 static void BinaryOpStub_GenerateHeapResultAllocation(MacroAssembler* masm,
2024 Label* alloc_failure, 2024 Label* alloc_failure,
(...skipping 3344 matching lines...) Expand 10 before | Expand all | Expand 10 after
5369 5369
5370 void StringAddStub::Generate(MacroAssembler* masm) { 5370 void StringAddStub::Generate(MacroAssembler* masm) {
5371 Label call_runtime, call_builtin; 5371 Label call_runtime, call_builtin;
5372 Builtins::JavaScript builtin_id = Builtins::ADD; 5372 Builtins::JavaScript builtin_id = Builtins::ADD;
5373 5373
5374 // Load the two arguments. 5374 // Load the two arguments.
5375 __ mov(eax, Operand(esp, 2 * kPointerSize)); // First argument. 5375 __ mov(eax, Operand(esp, 2 * kPointerSize)); // First argument.
5376 __ mov(edx, Operand(esp, 1 * kPointerSize)); // Second argument. 5376 __ mov(edx, Operand(esp, 1 * kPointerSize)); // Second argument.
5377 5377
5378 // Make sure that both arguments are strings if not known in advance. 5378 // Make sure that both arguments are strings if not known in advance.
5379 if ((flags_ & NO_STRING_ADD_FLAGS) != 0) { 5379 // Otherwise, at least one of the arguments is definitely a string,
5380 // and we convert the one that is not known to be a string.
5381 if ((flags_ & STRING_ADD_CHECK_BOTH) == STRING_ADD_CHECK_BOTH) {
5382 ASSERT((flags_ & STRING_ADD_CHECK_LEFT) == STRING_ADD_CHECK_LEFT);
5383 ASSERT((flags_ & STRING_ADD_CHECK_RIGHT) == STRING_ADD_CHECK_RIGHT);
5380 __ JumpIfSmi(eax, &call_runtime); 5384 __ JumpIfSmi(eax, &call_runtime);
5381 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, ebx); 5385 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, ebx);
5382 __ j(above_equal, &call_runtime); 5386 __ j(above_equal, &call_runtime);
5383 5387
5384 // First argument is a a string, test second. 5388 // First argument is a a string, test second.
5385 __ JumpIfSmi(edx, &call_runtime); 5389 __ JumpIfSmi(edx, &call_runtime);
5386 __ CmpObjectType(edx, FIRST_NONSTRING_TYPE, ebx); 5390 __ CmpObjectType(edx, FIRST_NONSTRING_TYPE, ebx);
5387 __ j(above_equal, &call_runtime); 5391 __ j(above_equal, &call_runtime);
5388 } else { 5392 } else if ((flags_ & STRING_ADD_CHECK_LEFT) == STRING_ADD_CHECK_LEFT) {
5389 // Here at least one of the arguments is definitely a string. 5393 ASSERT((flags_ & STRING_ADD_CHECK_RIGHT) == 0);
5390 // We convert the one that is not known to be a string. 5394 GenerateConvertArgument(masm, 2 * kPointerSize, eax, ebx, ecx, edi,
5391 if ((flags_ & NO_STRING_CHECK_LEFT_IN_STUB) == 0) { 5395 &call_builtin);
5392 ASSERT((flags_ & NO_STRING_CHECK_RIGHT_IN_STUB) != 0); 5396 builtin_id = Builtins::STRING_ADD_RIGHT;
5393 GenerateConvertArgument(masm, 2 * kPointerSize, eax, ebx, ecx, edi, 5397 } else if ((flags_ & STRING_ADD_CHECK_RIGHT) == STRING_ADD_CHECK_RIGHT) {
5394 &call_builtin); 5398 ASSERT((flags_ & STRING_ADD_CHECK_LEFT) == 0);
5395 builtin_id = Builtins::STRING_ADD_RIGHT; 5399 GenerateConvertArgument(masm, 1 * kPointerSize, edx, ebx, ecx, edi,
5396 } else if ((flags_ & NO_STRING_CHECK_RIGHT_IN_STUB) == 0) { 5400 &call_builtin);
5397 ASSERT((flags_ & NO_STRING_CHECK_LEFT_IN_STUB) != 0); 5401 builtin_id = Builtins::STRING_ADD_LEFT;
5398 GenerateConvertArgument(masm, 1 * kPointerSize, edx, ebx, ecx, edi,
5399 &call_builtin);
5400 builtin_id = Builtins::STRING_ADD_LEFT;
5401 }
5402 } 5402 }
5403 5403
5404 // Both arguments are strings. 5404 // Both arguments are strings.
5405 // eax: first string 5405 // eax: first string
5406 // edx: second string 5406 // edx: second string
5407 // Check if either of the strings are empty. In that case return the other. 5407 // Check if either of the strings are empty. In that case return the other.
5408 Label second_not_zero_length, both_not_zero_length; 5408 Label second_not_zero_length, both_not_zero_length;
5409 __ mov(ecx, FieldOperand(edx, String::kLengthOffset)); 5409 __ mov(ecx, FieldOperand(edx, String::kLengthOffset));
5410 STATIC_ASSERT(kSmiTag == 0); 5410 STATIC_ASSERT(kSmiTag == 0);
5411 __ test(ecx, ecx); 5411 __ test(ecx, ecx);
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
5677 // edi: length of second argument 5677 // edi: length of second argument
5678 StringHelper::GenerateCopyCharacters(masm, ecx, edx, edi, ebx, false); 5678 StringHelper::GenerateCopyCharacters(masm, ecx, edx, edi, ebx, false);
5679 __ IncrementCounter(counters->string_add_native(), 1); 5679 __ IncrementCounter(counters->string_add_native(), 1);
5680 __ ret(2 * kPointerSize); 5680 __ ret(2 * kPointerSize);
5681 5681
5682 // Recover stack pointer before jumping to runtime. 5682 // Recover stack pointer before jumping to runtime.
5683 __ bind(&call_runtime_drop_two); 5683 __ bind(&call_runtime_drop_two);
5684 __ Drop(2); 5684 __ Drop(2);
5685 // Just jump to runtime to add the two strings. 5685 // Just jump to runtime to add the two strings.
5686 __ bind(&call_runtime); 5686 __ bind(&call_runtime);
5687 if ((flags_ & ERECT_FRAME) != 0) { 5687 if ((flags_ & STRING_ADD_ERECT_FRAME) != 0) {
5688 GenerateRegisterArgsPop(masm, ecx); 5688 GenerateRegisterArgsPop(masm, ecx);
5689 // Build a frame 5689 // Build a frame
5690 { 5690 {
5691 FrameScope scope(masm, StackFrame::INTERNAL); 5691 FrameScope scope(masm, StackFrame::INTERNAL);
5692 GenerateRegisterArgsPush(masm); 5692 GenerateRegisterArgsPush(masm);
5693 __ CallRuntime(Runtime::kStringAdd, 2); 5693 __ CallRuntime(Runtime::kStringAdd, 2);
5694 } 5694 }
5695 __ ret(0); 5695 __ ret(0);
5696 } else { 5696 } else {
5697 __ TailCallRuntime(Runtime::kStringAdd, 2, 1); 5697 __ TailCallRuntime(Runtime::kStringAdd, 2, 1);
5698 } 5698 }
5699 5699
5700 if (call_builtin.is_linked()) { 5700 if (call_builtin.is_linked()) {
5701 __ bind(&call_builtin); 5701 __ bind(&call_builtin);
5702 if ((flags_ & ERECT_FRAME) != 0) { 5702 if ((flags_ & STRING_ADD_ERECT_FRAME) != 0) {
5703 GenerateRegisterArgsPop(masm, ecx); 5703 GenerateRegisterArgsPop(masm, ecx);
5704 // Build a frame 5704 // Build a frame
5705 { 5705 {
5706 FrameScope scope(masm, StackFrame::INTERNAL); 5706 FrameScope scope(masm, StackFrame::INTERNAL);
5707 GenerateRegisterArgsPush(masm); 5707 GenerateRegisterArgsPush(masm);
5708 __ InvokeBuiltin(builtin_id, CALL_FUNCTION); 5708 __ InvokeBuiltin(builtin_id, CALL_FUNCTION);
5709 } 5709 }
5710 __ ret(0); 5710 __ ret(0);
5711 } else { 5711 } else {
5712 __ InvokeBuiltin(builtin_id, JUMP_FUNCTION); 5712 __ InvokeBuiltin(builtin_id, JUMP_FUNCTION);
(...skipping 2055 matching lines...) Expand 10 before | Expand all | Expand 10 after
7768 __ bind(&fast_elements_case); 7768 __ bind(&fast_elements_case);
7769 GenerateCase(masm, FAST_ELEMENTS); 7769 GenerateCase(masm, FAST_ELEMENTS);
7770 } 7770 }
7771 7771
7772 7772
7773 #undef __ 7773 #undef __
7774 7774
7775 } } // namespace v8::internal 7775 } } // namespace v8::internal
7776 7776
7777 #endif // V8_TARGET_ARCH_IA32 7777 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/code-stubs-ia32.h ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698