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

Side by Side Diff: src/hydrogen.cc

Issue 585433002: Turn keyed loads with string-based (non-convertible to array-index) key into named loads (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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 | « src/hydrogen.h ('k') | test/mjsunit/keyed-named-access.js » ('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 // 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 <algorithm> 7 #include <algorithm>
8 8
9 #include "src/v8.h" 9 #include "src/v8.h"
10 10
(...skipping 6418 matching lines...) Expand 10 before | Expand all | Expand 10 after
6429 Property* prop, 6429 Property* prop,
6430 BailoutId ast_id, 6430 BailoutId ast_id,
6431 BailoutId return_id, 6431 BailoutId return_id,
6432 bool is_uninitialized) { 6432 bool is_uninitialized) {
6433 if (!prop->key()->IsPropertyName()) { 6433 if (!prop->key()->IsPropertyName()) {
6434 // Keyed store. 6434 // Keyed store.
6435 HValue* value = environment()->ExpressionStackAt(0); 6435 HValue* value = environment()->ExpressionStackAt(0);
6436 HValue* key = environment()->ExpressionStackAt(1); 6436 HValue* key = environment()->ExpressionStackAt(1);
6437 HValue* object = environment()->ExpressionStackAt(2); 6437 HValue* object = environment()->ExpressionStackAt(2);
6438 bool has_side_effects = false; 6438 bool has_side_effects = false;
6439 HandleKeyedElementAccess(object, key, value, expr, 6439 HandleKeyedElementAccess(object, key, value, expr, return_id, STORE,
6440 STORE, &has_side_effects); 6440 &has_side_effects);
6441 Drop(3); 6441 Drop(3);
6442 Push(value); 6442 Push(value);
6443 Add<HSimulate>(return_id, REMOVABLE_SIMULATE); 6443 Add<HSimulate>(return_id, REMOVABLE_SIMULATE);
6444 return ast_context()->ReturnValue(Pop()); 6444 return ast_context()->ReturnValue(Pop());
6445 } 6445 }
6446 6446
6447 // Named store. 6447 // Named store.
6448 HValue* value = Pop(); 6448 HValue* value = Pop();
6449 HValue* object = Pop(); 6449 HValue* object = Pop();
6450 6450
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
7122 DCHECK(join->predecessors()->length() > 0); 7122 DCHECK(join->predecessors()->length() > 0);
7123 // Deopt if none of the cases matched. 7123 // Deopt if none of the cases matched.
7124 NoObservableSideEffectsScope scope(this); 7124 NoObservableSideEffectsScope scope(this);
7125 FinishExitWithHardDeoptimization("Unknown map in polymorphic element access"); 7125 FinishExitWithHardDeoptimization("Unknown map in polymorphic element access");
7126 set_current_block(join); 7126 set_current_block(join);
7127 return access_type == STORE ? NULL : Pop(); 7127 return access_type == STORE ? NULL : Pop();
7128 } 7128 }
7129 7129
7130 7130
7131 HValue* HOptimizedGraphBuilder::HandleKeyedElementAccess( 7131 HValue* HOptimizedGraphBuilder::HandleKeyedElementAccess(
7132 HValue* obj, 7132 HValue* obj, HValue* key, HValue* val, Expression* expr,
7133 HValue* key, 7133 BailoutId return_id, PropertyAccessType access_type,
7134 HValue* val,
7135 Expression* expr,
7136 PropertyAccessType access_type,
7137 bool* has_side_effects) { 7134 bool* has_side_effects) {
7135 if (key->ActualValue()->IsConstant()) {
7136 Handle<Object> constant =
7137 HConstant::cast(key->ActualValue())->handle(isolate());
7138 uint32_t array_index;
7139 if (constant->IsString() &&
7140 !Handle<String>::cast(constant)->AsArrayIndex(&array_index)) {
7141 HInstruction* instr =
7142 BuildNamedAccess(access_type, expr->id(), return_id, expr, obj,
7143 Handle<String>::cast(constant), val, false);
7144 if (instr == NULL || instr->IsLinked()) {
7145 *has_side_effects = false;
7146 } else {
7147 AddInstruction(instr);
7148 *has_side_effects = instr->HasObservableSideEffects();
7149 }
7150 return instr;
7151 }
7152 }
7153
7138 DCHECK(!expr->IsPropertyName()); 7154 DCHECK(!expr->IsPropertyName());
7139 HInstruction* instr = NULL; 7155 HInstruction* instr = NULL;
7140 7156
7141 SmallMapList* types; 7157 SmallMapList* types;
7142 bool monomorphic = ComputeReceiverTypes(expr, obj, &types, zone()); 7158 bool monomorphic = ComputeReceiverTypes(expr, obj, &types, zone());
7143 7159
7144 bool force_generic = false; 7160 bool force_generic = false;
7145 if (access_type == STORE && 7161 if (access_type == STORE &&
7146 (monomorphic || (types != NULL && !types->is_empty()))) { 7162 (monomorphic || (types != NULL && !types->is_empty()))) {
7147 // Stores can't be mono/polymorphic if their prototype chain has dictionary 7163 // Stores can't be mono/polymorphic if their prototype chain has dictionary
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
7338 object, name, NULL, expr->IsUninitialized()); 7354 object, name, NULL, expr->IsUninitialized());
7339 if (instr == NULL) return; 7355 if (instr == NULL) return;
7340 if (instr->IsLinked()) return ast_context()->ReturnValue(instr); 7356 if (instr->IsLinked()) return ast_context()->ReturnValue(instr);
7341 7357
7342 } else { 7358 } else {
7343 HValue* key = Pop(); 7359 HValue* key = Pop();
7344 HValue* obj = Pop(); 7360 HValue* obj = Pop();
7345 7361
7346 bool has_side_effects = false; 7362 bool has_side_effects = false;
7347 HValue* load = HandleKeyedElementAccess( 7363 HValue* load = HandleKeyedElementAccess(
7348 obj, key, NULL, expr, LOAD, &has_side_effects); 7364 obj, key, NULL, expr, expr->LoadId(), LOAD, &has_side_effects);
7349 if (has_side_effects) { 7365 if (has_side_effects) {
7350 if (ast_context()->IsEffect()) { 7366 if (ast_context()->IsEffect()) {
7351 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); 7367 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE);
7352 } else { 7368 } else {
7353 Push(load); 7369 Push(load);
7354 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); 7370 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE);
7355 Drop(1); 7371 Drop(1);
7356 } 7372 }
7357 } 7373 }
7374 if (load == NULL) return;
7358 return ast_context()->ReturnValue(load); 7375 return ast_context()->ReturnValue(load);
7359 } 7376 }
7360 return ast_context()->ReturnInstruction(instr, ast_id); 7377 return ast_context()->ReturnInstruction(instr, ast_id);
7361 } 7378 }
7362 7379
7363 7380
7364 void HOptimizedGraphBuilder::VisitProperty(Property* expr) { 7381 void HOptimizedGraphBuilder::VisitProperty(Property* expr) {
7365 DCHECK(!HasStackOverflow()); 7382 DCHECK(!HasStackOverflow());
7366 DCHECK(current_block() != NULL); 7383 DCHECK(current_block() != NULL);
7367 DCHECK(current_block()->HasPredecessor()); 7384 DCHECK(current_block()->HasPredecessor());
(...skipping 5130 matching lines...) Expand 10 before | Expand all | Expand 10 after
12498 if (ShouldProduceTraceOutput()) { 12515 if (ShouldProduceTraceOutput()) {
12499 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 12516 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
12500 } 12517 }
12501 12518
12502 #ifdef DEBUG 12519 #ifdef DEBUG
12503 graph_->Verify(false); // No full verify. 12520 graph_->Verify(false); // No full verify.
12504 #endif 12521 #endif
12505 } 12522 }
12506 12523
12507 } } // namespace v8::internal 12524 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | test/mjsunit/keyed-named-access.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698