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

Side by Side Diff: src/full-codegen/mips/full-codegen-mips.cc

Issue 1618613002: [for-in] Sanitize for-in optimizations and fix bailout points. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if V8_TARGET_ARCH_MIPS 5 #if V8_TARGET_ARCH_MIPS
6 6
7 // Note on Mips implementation: 7 // Note on Mips implementation:
8 // 8 //
9 // The result_register() for mips is the 'v0' register, which is defined 9 // The result_register() for mips is the 'v0' register, which is defined
10 // by the ABI to contain function return values. However, the first 10 // by the ABI to contain function return values. However, the first
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { 1030 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
1031 Comment cmnt(masm_, "[ ForInStatement"); 1031 Comment cmnt(masm_, "[ ForInStatement");
1032 SetStatementPosition(stmt, SKIP_BREAK); 1032 SetStatementPosition(stmt, SKIP_BREAK);
1033 1033
1034 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot(); 1034 FeedbackVectorSlot slot = stmt->ForInFeedbackSlot();
1035 1035
1036 Label loop, exit; 1036 Label loop, exit;
1037 ForIn loop_statement(this, stmt); 1037 ForIn loop_statement(this, stmt);
1038 increment_loop_depth(); 1038 increment_loop_depth();
1039 1039
1040 // Get the object to enumerate over. If the object is null or undefined, skip 1040 // Get the object to enumerate over.
1041 // over the loop. See ECMA-262 version 5, section 12.6.4.
1042 SetExpressionAsStatementPosition(stmt->enumerable()); 1041 SetExpressionAsStatementPosition(stmt->enumerable());
1043 VisitForAccumulatorValue(stmt->enumerable()); 1042 VisitForAccumulatorValue(stmt->enumerable());
1044 __ mov(a0, result_register()); // Result as param to InvokeBuiltin below. 1043 __ mov(a0, result_register());
1045 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); 1044
1046 __ Branch(&exit, eq, a0, Operand(at)); 1045 // If the object is null or undefined, skip over the loop, otherwise convert
1047 Register null_value = t1; 1046 // it to a JS receiver. See ECMA-262 version 5, section 12.6.4.
1048 __ LoadRoot(null_value, Heap::kNullValueRootIndex);
1049 __ Branch(&exit, eq, a0, Operand(null_value));
1050 PrepareForBailoutForId(stmt->PrepareId(), TOS_REG);
1051 __ mov(a0, v0);
1052 // Convert the object to a JS object.
1053 Label convert, done_convert; 1047 Label convert, done_convert;
1054 __ JumpIfSmi(a0, &convert); 1048 __ JumpIfSmi(a0, &convert);
1055 __ GetObjectType(a0, a1, a1); 1049 __ GetObjectType(a0, a1, a1);
1056 __ Branch(&done_convert, ge, a1, Operand(FIRST_JS_RECEIVER_TYPE)); 1050 __ Branch(USE_DELAY_SLOT, &done_convert, ge, a1,
1051 Operand(FIRST_JS_RECEIVER_TYPE));
1052 __ LoadRoot(at, Heap::kNullValueRootIndex); // In delay slot.
1053 __ Branch(USE_DELAY_SLOT, &exit, eq, a0, Operand(at));
1054 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); // In delay slot.
1055 __ Branch(&exit, eq, a0, Operand(at));
1057 __ bind(&convert); 1056 __ bind(&convert);
1058 ToObjectStub stub(isolate()); 1057 ToObjectStub stub(isolate());
1059 __ CallStub(&stub); 1058 __ CallStub(&stub);
1060 __ mov(a0, v0); 1059 __ mov(a0, v0);
1061 __ bind(&done_convert); 1060 __ bind(&done_convert);
1062 PrepareForBailoutForId(stmt->ToObjectId(), TOS_REG); 1061 PrepareForBailoutForId(stmt->ToObjectId(), TOS_REG);
1063 __ push(a0); 1062 __ push(a0);
1064 1063
1065 // Check for proxies.
1066 Label call_runtime;
1067 __ GetObjectType(a0, a1, a1);
1068 __ Branch(&call_runtime, eq, a1, Operand(JS_PROXY_TYPE));
1069
1070 // Check cache validity in generated code. This is a fast case for 1064 // Check cache validity in generated code. This is a fast case for
1071 // the JSObject::IsSimpleEnum cache validity checks. If we cannot 1065 // the JSObject::IsSimpleEnum cache validity checks. If we cannot
1072 // guarantee cache validity, call the runtime system to check cache 1066 // guarantee cache validity, call the runtime system to check cache
1073 // validity or get the property names in a fixed array. 1067 // validity or get the property names in a fixed array.
1074 __ CheckEnumCache(null_value, &call_runtime); 1068 // Note: Proxies never have an enum cache, so will always take the
1069 // slow path.
1070 Label call_runtime;
1071 __ CheckEnumCache(&call_runtime);
1075 1072
1076 // The enum cache is valid. Load the map of the object being 1073 // The enum cache is valid. Load the map of the object being
1077 // iterated over and use the cache for the iteration. 1074 // iterated over and use the cache for the iteration.
1078 Label use_cache; 1075 Label use_cache;
1079 __ lw(v0, FieldMemOperand(a0, HeapObject::kMapOffset)); 1076 __ lw(v0, FieldMemOperand(a0, HeapObject::kMapOffset));
1080 __ Branch(&use_cache); 1077 __ Branch(&use_cache);
1081 1078
1082 // Get the set of properties to enumerate. 1079 // Get the set of properties to enumerate.
1083 __ bind(&call_runtime); 1080 __ bind(&call_runtime);
1084 __ push(a0); // Duplicate the enumerable object on the stack. 1081 __ push(a0); // Duplicate the enumerable object on the stack.
(...skipping 3739 matching lines...) Expand 10 before | Expand all | Expand 10 after
4824 reinterpret_cast<uint32_t>( 4821 reinterpret_cast<uint32_t>(
4825 isolate->builtins()->OsrAfterStackCheck()->entry())); 4822 isolate->builtins()->OsrAfterStackCheck()->entry()));
4826 return OSR_AFTER_STACK_CHECK; 4823 return OSR_AFTER_STACK_CHECK;
4827 } 4824 }
4828 4825
4829 4826
4830 } // namespace internal 4827 } // namespace internal
4831 } // namespace v8 4828 } // namespace v8
4832 4829
4833 #endif // V8_TARGET_ARCH_MIPS 4830 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/full-codegen/ia32/full-codegen-ia32.cc ('k') | src/full-codegen/mips64/full-codegen-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698