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

Side by Side Diff: src/compiler/ast-graph-builder.cc

Issue 1092353002: [strong] Disallow implicit conversions for binary arithmetic operations (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: cl feedback 5 Created 5 years, 7 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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 #include "src/compiler/ast-graph-builder.h" 5 #include "src/compiler/ast-graph-builder.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/compiler/ast-loop-assignment-analyzer.h" 8 #include "src/compiler/ast-loop-assignment-analyzer.h"
9 #include "src/compiler/control-builders.h" 9 #include "src/compiler/control-builders.h"
10 #include "src/compiler/js-type-feedback.h" 10 #include "src/compiler/js-type-feedback.h"
(...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 1262
1263 // These stack values are renamed in the case of OSR, so reload them 1263 // These stack values are renamed in the case of OSR, so reload them
1264 // from the environment. 1264 // from the environment.
1265 Node* index = environment()->Peek(0); 1265 Node* index = environment()->Peek(0);
1266 Node* cache_length = environment()->Peek(1); 1266 Node* cache_length = environment()->Peek(1);
1267 Node* cache_array = environment()->Peek(2); 1267 Node* cache_array = environment()->Peek(2);
1268 Node* cache_type = environment()->Peek(3); 1268 Node* cache_type = environment()->Peek(3);
1269 Node* obj = environment()->Peek(4); 1269 Node* obj = environment()->Peek(4);
1270 1270
1271 // Check loop termination condition. 1271 // Check loop termination condition.
1272 Node* exit_cond = NewNode(javascript()->LessThan(), index, cache_length); 1272 Node* exit_cond = NewNode(javascript()->LessThan(LanguageMode::SLOPPY),
1273 index, cache_length);
1273 // TODO(jarin): provide real bailout id. 1274 // TODO(jarin): provide real bailout id.
1274 PrepareFrameState(exit_cond, BailoutId::None()); 1275 PrepareFrameState(exit_cond, BailoutId::None());
1275 for_loop.BreakUnless(exit_cond); 1276 for_loop.BreakUnless(exit_cond);
1276 Node* pair = NewNode(javascript()->CallRuntime(Runtime::kForInNext, 4), obj, 1277 Node* pair = NewNode(javascript()->CallRuntime(Runtime::kForInNext, 4), obj,
1277 cache_array, cache_type, index); 1278 cache_array, cache_type, index);
1278 Node* value = NewNode(common()->Projection(0), pair); 1279 Node* value = NewNode(common()->Projection(0), pair);
1279 Node* should_filter = NewNode(common()->Projection(1), pair); 1280 Node* should_filter = NewNode(common()->Projection(1), pair);
1280 environment()->Push(value); 1281 environment()->Push(value);
1281 { 1282 {
1282 // Test if FILTER_KEY needs to be called. 1283 // Test if FILTER_KEY needs to be called.
(...skipping 13 matching lines...) Expand all
1296 function, obj, value); 1297 function, obj, value);
1297 PrepareFrameState(res, stmt->FilterId(), OutputFrameStateCombine::Push()); 1298 PrepareFrameState(res, stmt->FilterId(), OutputFrameStateCombine::Push());
1298 Node* property_missing = 1299 Node* property_missing =
1299 NewNode(javascript()->StrictEqual(), res, jsgraph()->ZeroConstant()); 1300 NewNode(javascript()->StrictEqual(), res, jsgraph()->ZeroConstant());
1300 { 1301 {
1301 IfBuilder is_property_missing(this); 1302 IfBuilder is_property_missing(this);
1302 is_property_missing.If(property_missing); 1303 is_property_missing.If(property_missing);
1303 is_property_missing.Then(); 1304 is_property_missing.Then();
1304 // Inc counter and continue. 1305 // Inc counter and continue.
1305 Node* index_inc = 1306 Node* index_inc =
1306 NewNode(javascript()->Add(), index, jsgraph()->OneConstant()); 1307 NewNode(javascript()->Add(LanguageMode::SLOPPY), index,
1308 jsgraph()->OneConstant());
1307 // TODO(jarin): provide real bailout id. 1309 // TODO(jarin): provide real bailout id.
1308 PrepareFrameStateAfterAndBefore(index_inc, BailoutId::None(), 1310 PrepareFrameStateAfterAndBefore(index_inc, BailoutId::None(),
1309 OutputFrameStateCombine::Ignore(), 1311 OutputFrameStateCombine::Ignore(),
1310 jsgraph()->EmptyFrameState()); 1312 jsgraph()->EmptyFrameState());
1311 environment()->Poke(0, index_inc); 1313 environment()->Poke(0, index_inc);
1312 for_loop.Continue(); 1314 for_loop.Continue();
1313 is_property_missing.Else(); 1315 is_property_missing.Else();
1314 is_property_missing.End(); 1316 is_property_missing.End();
1315 } 1317 }
1316 // Replace 'value' in environment. 1318 // Replace 'value' in environment.
1317 environment()->Push(res); 1319 environment()->Push(res);
1318 test_should_filter.Else(); 1320 test_should_filter.Else();
1319 test_should_filter.End(); 1321 test_should_filter.End();
1320 } 1322 }
1321 value = environment()->Pop(); 1323 value = environment()->Pop();
1322 // Bind value and do loop body. 1324 // Bind value and do loop body.
1323 VisitForInAssignment(stmt->each(), value, stmt->AssignmentId()); 1325 VisitForInAssignment(stmt->each(), value, stmt->AssignmentId());
1324 VisitIterationBody(stmt, &for_loop); 1326 VisitIterationBody(stmt, &for_loop);
1325 index = environment()->Peek(0); 1327 index = environment()->Peek(0);
1326 for_loop.EndBody(); 1328 for_loop.EndBody();
1327 1329
1328 // Inc counter and continue. 1330 // Inc counter and continue.
1329 Node* index_inc = 1331 Node* index_inc =
1330 NewNode(javascript()->Add(), index, jsgraph()->OneConstant()); 1332 NewNode(javascript()->Add(LanguageMode::SLOPPY), index,
1333 jsgraph()->OneConstant());
1331 // TODO(jarin): provide real bailout id. 1334 // TODO(jarin): provide real bailout id.
1332 PrepareFrameStateAfterAndBefore(index_inc, BailoutId::None(), 1335 PrepareFrameStateAfterAndBefore(index_inc, BailoutId::None(),
1333 OutputFrameStateCombine::Ignore(), 1336 OutputFrameStateCombine::Ignore(),
1334 jsgraph()->EmptyFrameState()); 1337 jsgraph()->EmptyFrameState());
1335 environment()->Poke(0, index_inc); 1338 environment()->Poke(0, index_inc);
1336 for_loop.EndLoop(); 1339 for_loop.EndLoop();
1337 environment()->Drop(5); 1340 environment()->Drop(5);
1338 // PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); 1341 // PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS);
1339 } 1342 }
1340 1343
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after
2432 case Token::NE: 2435 case Token::NE:
2433 op = javascript()->NotEqual(); 2436 op = javascript()->NotEqual();
2434 break; 2437 break;
2435 case Token::EQ_STRICT: 2438 case Token::EQ_STRICT:
2436 op = javascript()->StrictEqual(); 2439 op = javascript()->StrictEqual();
2437 break; 2440 break;
2438 case Token::NE_STRICT: 2441 case Token::NE_STRICT:
2439 op = javascript()->StrictNotEqual(); 2442 op = javascript()->StrictNotEqual();
2440 break; 2443 break;
2441 case Token::LT: 2444 case Token::LT:
2442 op = javascript()->LessThan(); 2445 op = javascript()->LessThan(language_mode());
2443 break; 2446 break;
2444 case Token::GT: 2447 case Token::GT:
2445 op = javascript()->GreaterThan(); 2448 op = javascript()->GreaterThan(language_mode());
2446 break; 2449 break;
2447 case Token::LTE: 2450 case Token::LTE:
2448 op = javascript()->LessThanOrEqual(); 2451 op = javascript()->LessThanOrEqual(language_mode());
2449 break; 2452 break;
2450 case Token::GTE: 2453 case Token::GTE:
2451 op = javascript()->GreaterThanOrEqual(); 2454 op = javascript()->GreaterThanOrEqual(language_mode());
2452 break; 2455 break;
2453 case Token::INSTANCEOF: 2456 case Token::INSTANCEOF:
2454 op = javascript()->InstanceOf(); 2457 op = javascript()->InstanceOf();
2455 break; 2458 break;
2456 case Token::IN: 2459 case Token::IN:
2457 op = javascript()->HasProperty(); 2460 op = javascript()->HasProperty();
2458 break; 2461 break;
2459 default: 2462 default:
2460 op = NULL; 2463 op = NULL;
2461 UNREACHABLE(); 2464 UNREACHABLE();
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
3201 Node* control = NewNode(common()->Throw(), exception_value); 3204 Node* control = NewNode(common()->Throw(), exception_value);
3202 UpdateControlDependencyToLeaveFunction(control); 3205 UpdateControlDependencyToLeaveFunction(control);
3203 return control; 3206 return control;
3204 } 3207 }
3205 3208
3206 3209
3207 Node* AstGraphBuilder::BuildBinaryOp(Node* left, Node* right, Token::Value op) { 3210 Node* AstGraphBuilder::BuildBinaryOp(Node* left, Node* right, Token::Value op) {
3208 const Operator* js_op; 3211 const Operator* js_op;
3209 switch (op) { 3212 switch (op) {
3210 case Token::BIT_OR: 3213 case Token::BIT_OR:
3211 js_op = javascript()->BitwiseOr(); 3214 js_op = javascript()->BitwiseOr(language_mode());
3212 break; 3215 break;
3213 case Token::BIT_AND: 3216 case Token::BIT_AND:
3214 js_op = javascript()->BitwiseAnd(); 3217 js_op = javascript()->BitwiseAnd(language_mode());
3215 break; 3218 break;
3216 case Token::BIT_XOR: 3219 case Token::BIT_XOR:
3217 js_op = javascript()->BitwiseXor(); 3220 js_op = javascript()->BitwiseXor(language_mode());
3218 break; 3221 break;
3219 case Token::SHL: 3222 case Token::SHL:
3220 js_op = javascript()->ShiftLeft(); 3223 js_op = javascript()->ShiftLeft(language_mode());
3221 break; 3224 break;
3222 case Token::SAR: 3225 case Token::SAR:
3223 js_op = javascript()->ShiftRight(); 3226 js_op = javascript()->ShiftRight(language_mode());
3224 break; 3227 break;
3225 case Token::SHR: 3228 case Token::SHR:
3226 js_op = javascript()->ShiftRightLogical(); 3229 js_op = javascript()->ShiftRightLogical(language_mode());
3227 break; 3230 break;
3228 case Token::ADD: 3231 case Token::ADD:
3229 js_op = javascript()->Add(); 3232 js_op = javascript()->Add(language_mode());
3230 break; 3233 break;
3231 case Token::SUB: 3234 case Token::SUB:
3232 js_op = javascript()->Subtract(); 3235 js_op = javascript()->Subtract(language_mode());
3233 break; 3236 break;
3234 case Token::MUL: 3237 case Token::MUL:
3235 js_op = javascript()->Multiply(); 3238 js_op = javascript()->Multiply(language_mode());
3236 break; 3239 break;
3237 case Token::DIV: 3240 case Token::DIV:
3238 js_op = javascript()->Divide(); 3241 js_op = javascript()->Divide(language_mode());
3239 break; 3242 break;
3240 case Token::MOD: 3243 case Token::MOD:
3241 js_op = javascript()->Modulus(); 3244 js_op = javascript()->Modulus(language_mode());
3242 break; 3245 break;
3243 default: 3246 default:
3244 UNREACHABLE(); 3247 UNREACHABLE();
3245 js_op = NULL; 3248 js_op = NULL;
3246 } 3249 }
3247 return NewNode(js_op, left, right); 3250 return NewNode(js_op, left, right);
3248 } 3251 }
3249 3252
3250 3253
3251 bool AstGraphBuilder::CheckOsrEntry(IterationStatement* stmt) { 3254 bool AstGraphBuilder::CheckOsrEntry(IterationStatement* stmt) {
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
3579 // Phi does not exist yet, introduce one. 3582 // Phi does not exist yet, introduce one.
3580 value = NewPhi(inputs, value, control); 3583 value = NewPhi(inputs, value, control);
3581 value->ReplaceInput(inputs - 1, other); 3584 value->ReplaceInput(inputs - 1, other);
3582 } 3585 }
3583 return value; 3586 return value;
3584 } 3587 }
3585 3588
3586 } // namespace compiler 3589 } // namespace compiler
3587 } // namespace internal 3590 } // namespace internal
3588 } // namespace v8 3591 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stubs.cc ('k') | src/compiler/js-generic-lowering.cc » ('j') | src/ic/ic.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698