OLD | NEW |
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/js-inlining.h" | 5 #include "src/compiler/js-inlining.h" |
6 | 6 |
7 #include "src/ast/ast.h" | 7 #include "src/ast/ast.h" |
8 #include "src/compilation-info.h" | 8 #include "src/compilation-info.h" |
9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/compiler/all-nodes.h" | 10 #include "src/compiler/all-nodes.h" |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 case IrOpcode::kJSCreateArguments: | 298 case IrOpcode::kJSCreateArguments: |
299 case IrOpcode::kJSCreateArray: | 299 case IrOpcode::kJSCreateArray: |
300 case IrOpcode::kJSCreateClosure: | 300 case IrOpcode::kJSCreateClosure: |
301 case IrOpcode::kJSCreateIterResultObject: | 301 case IrOpcode::kJSCreateIterResultObject: |
302 case IrOpcode::kJSCreateKeyValueArray: | 302 case IrOpcode::kJSCreateKeyValueArray: |
303 case IrOpcode::kJSCreateLiteralArray: | 303 case IrOpcode::kJSCreateLiteralArray: |
304 case IrOpcode::kJSCreateLiteralObject: | 304 case IrOpcode::kJSCreateLiteralObject: |
305 case IrOpcode::kJSCreateLiteralRegExp: | 305 case IrOpcode::kJSCreateLiteralRegExp: |
306 case IrOpcode::kJSConvertReceiver: | 306 case IrOpcode::kJSConvertReceiver: |
307 case IrOpcode::kJSGetSuperConstructor: | 307 case IrOpcode::kJSGetSuperConstructor: |
308 case IrOpcode::kJSToObject: | 308 case IrOpcode::kJSToObject: { |
309 return false; | |
310 default: | |
311 break; | |
312 } | |
313 for (Node* dominator = effect;;) { | |
314 if (dominator->opcode() == IrOpcode::kCheckMaps && | |
315 NodeProperties::IsSame(dominator->InputAt(0), receiver)) { | |
316 // Check if all maps have the given {instance_type}. | |
317 ZoneHandleSet<Map> const& maps = | |
318 CheckMapsParametersOf(dominator->op()).maps(); | |
319 for (size_t i = 0; i < maps.size(); ++i) { | |
320 if (!maps[i]->IsJSReceiverMap()) return true; | |
321 } | |
322 return false; | 309 return false; |
323 } | 310 } |
324 switch (dominator->opcode()) { | 311 default: { |
325 case IrOpcode::kStoreField: { | 312 ZoneHandleSet<Map> maps; |
326 FieldAccess const& access = FieldAccessOf(dominator->op()); | 313 if (NodeProperties::InferReceiverMaps(receiver, effect, &maps)) { |
327 if (access.base_is_tagged == kTaggedBase && | 314 // Check if all {maps} are actually JSReceiver maps. |
328 access.offset == HeapObject::kMapOffset) { | 315 for (size_t i = 0; i < maps.size(); ++i) { |
329 return true; | 316 if (!maps[i]->IsJSReceiverMap()) return true; |
330 } | 317 } |
331 break; | 318 return false; |
332 } | 319 } |
333 case IrOpcode::kStoreElement: | 320 return true; |
334 case IrOpcode::kStoreTypedElement: | |
335 break; | |
336 default: { | |
337 DCHECK_EQ(1, dominator->op()->EffectOutputCount()); | |
338 if (dominator->op()->EffectInputCount() != 1 || | |
339 !dominator->op()->HasProperty(Operator::kNoWrite)) { | |
340 // Didn't find any appropriate CheckMaps node. | |
341 return true; | |
342 } | |
343 break; | |
344 } | |
345 } | 321 } |
346 dominator = NodeProperties::GetEffectInput(dominator); | |
347 } | 322 } |
348 } | 323 } |
349 | 324 |
350 // TODO(mstarzinger,verwaest): Move this predicate onto SharedFunctionInfo? | 325 // TODO(mstarzinger,verwaest): Move this predicate onto SharedFunctionInfo? |
351 bool NeedsImplicitReceiver(Handle<SharedFunctionInfo> shared_info) { | 326 bool NeedsImplicitReceiver(Handle<SharedFunctionInfo> shared_info) { |
352 DisallowHeapAllocation no_gc; | 327 DisallowHeapAllocation no_gc; |
353 Isolate* const isolate = shared_info->GetIsolate(); | 328 Isolate* const isolate = shared_info->GetIsolate(); |
354 Code* const construct_stub = shared_info->construct_stub(); | 329 Code* const construct_stub = shared_info->construct_stub(); |
355 return construct_stub != *isolate->builtins()->JSBuiltinsConstructStub() && | 330 return construct_stub != *isolate->builtins()->JSBuiltinsConstructStub() && |
356 construct_stub != | 331 construct_stub != |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 | 730 |
756 CommonOperatorBuilder* JSInliner::common() const { return jsgraph()->common(); } | 731 CommonOperatorBuilder* JSInliner::common() const { return jsgraph()->common(); } |
757 | 732 |
758 SimplifiedOperatorBuilder* JSInliner::simplified() const { | 733 SimplifiedOperatorBuilder* JSInliner::simplified() const { |
759 return jsgraph()->simplified(); | 734 return jsgraph()->simplified(); |
760 } | 735 } |
761 | 736 |
762 } // namespace compiler | 737 } // namespace compiler |
763 } // namespace internal | 738 } // namespace internal |
764 } // namespace v8 | 739 } // namespace v8 |
OLD | NEW |