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

Side by Side Diff: src/hydrogen.cc

Issue 1108313003: Add HArrayBufferNotNeutered instruction (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates 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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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/hydrogen.h" 5 #include "src/hydrogen.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "src/v8.h" 9 #include "src/v8.h"
10 10
(...skipping 2407 matching lines...) Expand 10 before | Expand all | Expand 10 after
2418 length = Add<HLoadNamedField>( 2418 length = Add<HLoadNamedField>(
2419 checked_object->ActualValue(), checked_object, 2419 checked_object->ActualValue(), checked_object,
2420 HObjectAccess::ForArrayLength(elements_kind)); 2420 HObjectAccess::ForArrayLength(elements_kind));
2421 } else { 2421 } else {
2422 length = AddLoadFixedArrayLength(elements); 2422 length = AddLoadFixedArrayLength(elements);
2423 } 2423 }
2424 length->set_type(HType::Smi()); 2424 length->set_type(HType::Smi());
2425 HValue* checked_key = NULL; 2425 HValue* checked_key = NULL;
2426 if (IsExternalArrayElementsKind(elements_kind) || 2426 if (IsExternalArrayElementsKind(elements_kind) ||
2427 IsFixedTypedArrayElementsKind(elements_kind)) { 2427 IsFixedTypedArrayElementsKind(elements_kind)) {
2428 checked_object = Add<HCheckArrayBufferNotNeutered>(checked_object);
2429
2428 HValue* backing_store; 2430 HValue* backing_store;
2429 if (IsExternalArrayElementsKind(elements_kind)) { 2431 if (IsExternalArrayElementsKind(elements_kind)) {
2430 backing_store = Add<HLoadNamedField>( 2432 backing_store = Add<HLoadNamedField>(
2431 elements, nullptr, HObjectAccess::ForExternalArrayExternalPointer()); 2433 elements, nullptr, HObjectAccess::ForExternalArrayExternalPointer());
2432 } else { 2434 } else {
2433 backing_store = elements; 2435 backing_store = elements;
2434 } 2436 }
2435 if (store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS) { 2437 if (store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS) {
2436 NoObservableSideEffectsScope no_effects(this); 2438 NoObservableSideEffectsScope no_effects(this);
2437 if (IsExternalArrayElementsKind(elements_kind)) {
2438 HInstruction* buffer =
2439 Add<HLoadNamedField>(checked_object, nullptr,
2440 HObjectAccess::ForJSArrayBufferViewBuffer());
2441 HInstruction* flags = Add<HLoadNamedField>(
2442 buffer, nullptr, HObjectAccess::ForJSArrayBufferBitField());
2443 HValue* was_neutered_mask =
2444 Add<HConstant>(1 << JSArrayBuffer::WasNeutered::kShift);
2445 HValue* was_neutered_test =
2446 AddUncasted<HBitwise>(Token::BIT_AND, flags, was_neutered_mask);
2447
2448 IfBuilder if_was_neutered(this);
2449 if_was_neutered.If<HCompareNumericAndBranch>(
2450 was_neutered_test, graph()->GetConstant0(), Token::NE);
2451 if_was_neutered.ThenDeopt(Deoptimizer::kOutOfBounds);
2452 if_was_neutered.End();
2453 }
2454 IfBuilder length_checker(this); 2439 IfBuilder length_checker(this);
2455 length_checker.If<HCompareNumericAndBranch>(key, length, Token::LT); 2440 length_checker.If<HCompareNumericAndBranch>(key, length, Token::LT);
2456 length_checker.Then(); 2441 length_checker.Then();
2457 IfBuilder negative_checker(this); 2442 IfBuilder negative_checker(this);
2458 HValue* bounds_check = negative_checker.If<HCompareNumericAndBranch>( 2443 HValue* bounds_check = negative_checker.If<HCompareNumericAndBranch>(
2459 key, graph()->GetConstant0(), Token::GTE); 2444 key, graph()->GetConstant0(), Token::GTE);
2460 negative_checker.Then(); 2445 negative_checker.Then();
2461 HInstruction* result = AddElementAccess( 2446 HInstruction* result = AddElementAccess(
2462 backing_store, key, val, bounds_check, elements_kind, access_type); 2447 backing_store, key, val, bounds_check, elements_kind, access_type);
2463 negative_checker.ElseDeopt(Deoptimizer::kNegativeKeyEncountered); 2448 negative_checker.ElseDeopt(Deoptimizer::kNegativeKeyEncountered);
2464 negative_checker.End(); 2449 negative_checker.End();
2465 length_checker.End(); 2450 length_checker.End();
2466 return result; 2451 return result;
2467 } else { 2452 } else {
2468 if (IsExternalArrayElementsKind(elements_kind)) {
2469 HInstruction* buffer =
2470 Add<HLoadNamedField>(checked_object, nullptr,
2471 HObjectAccess::ForJSArrayBufferViewBuffer());
2472 HInstruction* buffer_length = Add<HLoadNamedField>(
2473 buffer, nullptr, HObjectAccess::ForJSArrayBufferByteLength());
2474 Add<HBoundsCheck>(graph()->GetConstant0(), buffer_length);
2475 }
2476 DCHECK(store_mode == STANDARD_STORE); 2453 DCHECK(store_mode == STANDARD_STORE);
2477 checked_key = Add<HBoundsCheck>(key, length); 2454 checked_key = Add<HBoundsCheck>(key, length);
2478 return AddElementAccess( 2455 return AddElementAccess(
2479 backing_store, checked_key, val, 2456 backing_store, checked_key, val,
2480 checked_object, elements_kind, access_type); 2457 checked_object, elements_kind, access_type);
2481 } 2458 }
2482 } 2459 }
2483 DCHECK(fast_smi_only_elements || 2460 DCHECK(fast_smi_only_elements ||
2484 fast_elements || 2461 fast_elements ||
2485 IsFastDoubleElementsKind(elements_kind)); 2462 IsFastDoubleElementsKind(elements_kind));
(...skipping 3847 matching lines...) Expand 10 before | Expand all | Expand 10 after
6333 HValue* value, BailoutId ast_id, BailoutId return_id, 6310 HValue* value, BailoutId ast_id, BailoutId return_id,
6334 bool can_inline_accessor) { 6311 bool can_inline_accessor) {
6335 HObjectAccess access = HObjectAccess::ForMap(); // bogus default 6312 HObjectAccess access = HObjectAccess::ForMap(); // bogus default
6336 if (info->GetJSObjectFieldAccess(&access)) { 6313 if (info->GetJSObjectFieldAccess(&access)) {
6337 DCHECK(info->IsLoad()); 6314 DCHECK(info->IsLoad());
6338 return New<HLoadNamedField>(object, checked_object, access); 6315 return New<HLoadNamedField>(object, checked_object, access);
6339 } 6316 }
6340 6317
6341 if (info->GetJSArrayBufferViewFieldAccess(&access)) { 6318 if (info->GetJSArrayBufferViewFieldAccess(&access)) {
6342 DCHECK(info->IsLoad()); 6319 DCHECK(info->IsLoad());
6343 return BuildArrayBufferViewFieldAccessor( 6320 checked_object = Add<HCheckArrayBufferNotNeutered>(checked_object);
6344 object, checked_object, FieldIndex::ForInObjectOffset(access.offset())); 6321 return New<HLoadNamedField>(object, checked_object, access);
6345 } 6322 }
6346 6323
6347 if (info->name().is_identical_to(isolate()->factory()->prototype_string()) && 6324 if (info->name().is_identical_to(isolate()->factory()->prototype_string()) &&
6348 info->map()->function_with_prototype()) { 6325 info->map()->function_with_prototype()) {
6349 DCHECK(!info->map()->has_non_instance_prototype()); 6326 DCHECK(!info->map()->has_non_instance_prototype());
6350 return New<HLoadFunctionPrototype>(checked_object); 6327 return New<HLoadFunctionPrototype>(checked_object);
6351 } 6328 }
6352 6329
6353 HValue* checked_holder = checked_object; 6330 HValue* checked_holder = checked_object;
6354 if (info->has_holder()) { 6331 if (info->has_holder()) {
(...skipping 6774 matching lines...) Expand 10 before | Expand all | Expand 10 after
13129 if (ShouldProduceTraceOutput()) { 13106 if (ShouldProduceTraceOutput()) {
13130 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 13107 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
13131 } 13108 }
13132 13109
13133 #ifdef DEBUG 13110 #ifdef DEBUG
13134 graph_->Verify(false); // No full verify. 13111 graph_->Verify(false); // No full verify.
13135 #endif 13112 #endif
13136 } 13113 }
13137 13114
13138 } } // namespace v8::internal 13115 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698