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

Side by Side Diff: src/hydrogen.cc

Issue 212643016: Fix deopts causing uninitialized fixed typed arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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 | « no previous file | src/runtime.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 8492 matching lines...) Expand 10 before | Expand all | Expand 10 after
8503 return Map::AsElementsKind(map, target_kind); 8503 return Map::AsElementsKind(map, target_kind);
8504 } 8504 }
8505 8505
8506 8506
8507 HValue* HOptimizedGraphBuilder::BuildAllocateExternalElements( 8507 HValue* HOptimizedGraphBuilder::BuildAllocateExternalElements(
8508 ExternalArrayType array_type, 8508 ExternalArrayType array_type,
8509 bool is_zero_byte_offset, 8509 bool is_zero_byte_offset,
8510 HValue* buffer, HValue* byte_offset, HValue* length) { 8510 HValue* buffer, HValue* byte_offset, HValue* length) {
8511 Handle<Map> external_array_map( 8511 Handle<Map> external_array_map(
8512 isolate()->heap()->MapForExternalArrayType(array_type)); 8512 isolate()->heap()->MapForExternalArrayType(array_type));
8513
8514 // The HForceRepresentation is to prevent possible deopt on int-smi
8515 // conversion after allocation but before the new object fields are set.
8516 length = AddUncasted<HForceRepresentation>(length, Representation::Smi());
8513 HValue* elements = 8517 HValue* elements =
8514 Add<HAllocate>( 8518 Add<HAllocate>(
8515 Add<HConstant>(ExternalArray::kAlignedSize), 8519 Add<HConstant>(ExternalArray::kAlignedSize),
8516 HType::Tagged(), 8520 HType::Tagged(),
8517 NOT_TENURED, 8521 NOT_TENURED,
8518 external_array_map->instance_type()); 8522 external_array_map->instance_type());
8519 8523
8520 AddStoreMapConstant(elements, external_array_map); 8524 AddStoreMapConstant(elements, external_array_map);
8525 Add<HStoreNamedField>(elements,
8526 HObjectAccess::ForFixedArrayLength(), length);
8521 8527
8522 HValue* backing_store = Add<HLoadNamedField>( 8528 HValue* backing_store = Add<HLoadNamedField>(
8523 buffer, static_cast<HValue*>(NULL), 8529 buffer, static_cast<HValue*>(NULL),
8524 HObjectAccess::ForJSArrayBufferBackingStore()); 8530 HObjectAccess::ForJSArrayBufferBackingStore());
8525 8531
8526 HValue* typed_array_start; 8532 HValue* typed_array_start;
8527 if (is_zero_byte_offset) { 8533 if (is_zero_byte_offset) {
8528 typed_array_start = backing_store; 8534 typed_array_start = backing_store;
8529 } else { 8535 } else {
8530 HInstruction* external_pointer = 8536 HInstruction* external_pointer =
8531 AddUncasted<HAdd>(backing_store, byte_offset); 8537 AddUncasted<HAdd>(backing_store, byte_offset);
8532 // Arguments are checked prior to call to TypedArrayInitialize, 8538 // Arguments are checked prior to call to TypedArrayInitialize,
8533 // including byte_offset. 8539 // including byte_offset.
8534 external_pointer->ClearFlag(HValue::kCanOverflow); 8540 external_pointer->ClearFlag(HValue::kCanOverflow);
8535 typed_array_start = external_pointer; 8541 typed_array_start = external_pointer;
8536 } 8542 }
8537 8543
8538
8539 Add<HStoreNamedField>(elements, 8544 Add<HStoreNamedField>(elements,
8540 HObjectAccess::ForExternalArrayExternalPointer(), 8545 HObjectAccess::ForExternalArrayExternalPointer(),
8541 typed_array_start); 8546 typed_array_start);
8542 8547
8543 Add<HStoreNamedField>(elements,
8544 HObjectAccess::ForFixedArrayLength(), length);
8545 return elements; 8548 return elements;
8546 } 8549 }
8547 8550
8548 8551
8549 HValue* HOptimizedGraphBuilder::BuildAllocateFixedTypedArray( 8552 HValue* HOptimizedGraphBuilder::BuildAllocateFixedTypedArray(
8550 ExternalArrayType array_type, size_t element_size, 8553 ExternalArrayType array_type, size_t element_size,
8551 ElementsKind fixed_elements_kind, 8554 ElementsKind fixed_elements_kind,
8552 HValue* byte_length, HValue* length) { 8555 HValue* byte_length, HValue* length) {
8553 STATIC_ASSERT( 8556 STATIC_ASSERT(
8554 (FixedTypedArrayBase::kHeaderSize & kObjectAlignmentMask) == 0); 8557 (FixedTypedArrayBase::kHeaderSize & kObjectAlignmentMask) == 0);
8555 HValue* total_size; 8558 HValue* total_size;
8556 8559
8557 // if fixed array's elements are not aligned to object's alignment, 8560 // if fixed array's elements are not aligned to object's alignment,
8558 // we need to align the whole array to object alignment. 8561 // we need to align the whole array to object alignment.
8559 if (element_size % kObjectAlignment != 0) { 8562 if (element_size % kObjectAlignment != 0) {
8560 total_size = BuildObjectSizeAlignment( 8563 total_size = BuildObjectSizeAlignment(
8561 byte_length, FixedTypedArrayBase::kHeaderSize); 8564 byte_length, FixedTypedArrayBase::kHeaderSize);
8562 } else { 8565 } else {
8563 total_size = AddUncasted<HAdd>(byte_length, 8566 total_size = AddUncasted<HAdd>(byte_length,
8564 Add<HConstant>(FixedTypedArrayBase::kHeaderSize)); 8567 Add<HConstant>(FixedTypedArrayBase::kHeaderSize));
8565 total_size->ClearFlag(HValue::kCanOverflow); 8568 total_size->ClearFlag(HValue::kCanOverflow);
8566 } 8569 }
8567 8570
8571 // The HForceRepresentation is to prevent possible deopt on int-smi
8572 // conversion after allocation but before the new object fields are set.
8573 length = AddUncasted<HForceRepresentation>(length, Representation::Smi());
8568 Handle<Map> fixed_typed_array_map( 8574 Handle<Map> fixed_typed_array_map(
8569 isolate()->heap()->MapForFixedTypedArray(array_type)); 8575 isolate()->heap()->MapForFixedTypedArray(array_type));
8570 HValue* elements = 8576 HValue* elements =
8571 Add<HAllocate>(total_size, HType::Tagged(), 8577 Add<HAllocate>(total_size, HType::Tagged(),
8572 NOT_TENURED, 8578 NOT_TENURED,
8573 fixed_typed_array_map->instance_type()); 8579 fixed_typed_array_map->instance_type());
8574 AddStoreMapConstant(elements, fixed_typed_array_map); 8580 AddStoreMapConstant(elements, fixed_typed_array_map);
8575 8581
8576 Add<HStoreNamedField>(elements, 8582 Add<HStoreNamedField>(elements,
8577 HObjectAccess::ForFixedArrayLength(), 8583 HObjectAccess::ForFixedArrayLength(),
8578 length); 8584 length);
8585
8579 HValue* filler = Add<HConstant>(static_cast<int32_t>(0)); 8586 HValue* filler = Add<HConstant>(static_cast<int32_t>(0));
8580 8587
8581 { 8588 {
8582 LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement); 8589 LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement);
8583 8590
8584 HValue* key = builder.BeginBody( 8591 HValue* key = builder.BeginBody(
8585 Add<HConstant>(static_cast<int32_t>(0)), 8592 Add<HConstant>(static_cast<int32_t>(0)),
8586 length, Token::LT); 8593 length, Token::LT);
8587 Add<HStoreKeyed>(elements, key, filler, fixed_elements_kind); 8594 Add<HStoreKeyed>(elements, key, filler, fixed_elements_kind);
8588 8595
8589 builder.EndBody(); 8596 builder.EndBody();
8590 } 8597 }
8591 Add<HStoreNamedField>(
8592 elements, HObjectAccess::ForFixedArrayLength(), length);
8593 return elements; 8598 return elements;
8594 } 8599 }
8595 8600
8596 8601
8597 void HOptimizedGraphBuilder::GenerateTypedArrayInitialize( 8602 void HOptimizedGraphBuilder::GenerateTypedArrayInitialize(
8598 CallRuntime* expr) { 8603 CallRuntime* expr) {
8599 ZoneList<Expression*>* arguments = expr->arguments(); 8604 ZoneList<Expression*>* arguments = expr->arguments();
8600 8605
8601 NoObservableSideEffectsScope scope(this); 8606 NoObservableSideEffectsScope scope(this);
8602 static const int kObjectArg = 0; 8607 static const int kObjectArg = 0;
(...skipping 2840 matching lines...) Expand 10 before | Expand all | Expand 10 after
11443 if (ShouldProduceTraceOutput()) { 11448 if (ShouldProduceTraceOutput()) {
11444 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 11449 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
11445 } 11450 }
11446 11451
11447 #ifdef DEBUG 11452 #ifdef DEBUG
11448 graph_->Verify(false); // No full verify. 11453 graph_->Verify(false); // No full verify.
11449 #endif 11454 #endif
11450 } 11455 }
11451 11456
11452 } } // namespace v8::internal 11457 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698