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

Side by Side Diff: src/hydrogen.cc

Issue 71783003: Reland and fix "Add support for keyed-call on arrays of fast elements" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Test + fix Created 7 years, 1 month 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') | src/hydrogen-instructions.h » ('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 2408 matching lines...) Expand 10 before | Expand all | Expand 10 after
2419 2419
2420 2420
2421 HValue* HGraphBuilder::JSArrayBuilder::EmitMapCode() { 2421 HValue* HGraphBuilder::JSArrayBuilder::EmitMapCode() {
2422 if (!builder()->top_info()->IsStub()) { 2422 if (!builder()->top_info()->IsStub()) {
2423 // A constant map is fine. 2423 // A constant map is fine.
2424 Handle<Map> map(builder()->isolate()->get_initial_js_array_map(kind_), 2424 Handle<Map> map(builder()->isolate()->get_initial_js_array_map(kind_),
2425 builder()->isolate()); 2425 builder()->isolate());
2426 return builder()->Add<HConstant>(map); 2426 return builder()->Add<HConstant>(map);
2427 } 2427 }
2428 2428
2429 if (kind_ == GetInitialFastElementsKind()) { 2429 if (constructor_function_ != NULL && kind_ == GetInitialFastElementsKind()) {
2430 // No need for a context lookup if the kind_ matches the initial 2430 // No need for a context lookup if the kind_ matches the initial
2431 // map, because we can just load the map in that case. 2431 // map, because we can just load the map in that case.
2432 HObjectAccess access = HObjectAccess::ForPrototypeOrInitialMap(); 2432 HObjectAccess access = HObjectAccess::ForPrototypeOrInitialMap();
2433 return builder()->AddLoadNamedField(constructor_function_, access); 2433 return builder()->AddLoadNamedField(constructor_function_, access);
2434 } 2434 }
2435 2435
2436 HInstruction* native_context = builder()->BuildGetNativeContext(); 2436 HInstruction* native_context = builder()->BuildGetNativeContext();
2437 HInstruction* index = builder()->Add<HConstant>( 2437 HInstruction* index = builder()->Add<HConstant>(
2438 static_cast<int32_t>(Context::JS_ARRAY_MAPS_INDEX)); 2438 static_cast<int32_t>(Context::JS_ARRAY_MAPS_INDEX));
2439 2439
(...skipping 4957 matching lines...) Expand 10 before | Expand all | Expand 10 after
7397 ASSERT(current_block() != NULL); 7397 ASSERT(current_block() != NULL);
7398 ASSERT(current_block()->HasPredecessor()); 7398 ASSERT(current_block()->HasPredecessor());
7399 Expression* callee = expr->expression(); 7399 Expression* callee = expr->expression();
7400 int argument_count = expr->arguments()->length() + 1; // Plus receiver. 7400 int argument_count = expr->arguments()->length() + 1; // Plus receiver.
7401 HInstruction* call = NULL; 7401 HInstruction* call = NULL;
7402 7402
7403 Property* prop = callee->AsProperty(); 7403 Property* prop = callee->AsProperty();
7404 if (prop != NULL) { 7404 if (prop != NULL) {
7405 if (!prop->key()->IsPropertyName()) { 7405 if (!prop->key()->IsPropertyName()) {
7406 // Keyed function call. 7406 // Keyed function call.
7407 CHECK_ALIVE(VisitArgument(prop->obj())); 7407 CHECK_ALIVE(VisitForValue(prop->obj()));
7408 CHECK_ALIVE(VisitForValue(prop->key()));
7408 7409
7409 CHECK_ALIVE(VisitForValue(prop->key()));
7410 // Push receiver and key like the non-optimized code generator expects it. 7410 // Push receiver and key like the non-optimized code generator expects it.
7411 HValue* key = Pop(); 7411 HValue* key = Pop();
7412 HValue* receiver = Pop(); 7412 HValue* receiver = Pop();
7413 Push(key); 7413 Push(key);
7414 Push(receiver); 7414 Push(Add<HPushArgument>(receiver));
7415
7416 CHECK_ALIVE(VisitArgumentList(expr->arguments())); 7415 CHECK_ALIVE(VisitArgumentList(expr->arguments()));
7417 7416
7418 call = New<HCallKeyed>(key, argument_count); 7417 if (expr->IsMonomorphic()) {
7418 BuildCheckHeapObject(receiver);
7419 ElementsKind kind = expr->KeyedArrayCallIsHoley()
7420 ? FAST_HOLEY_ELEMENTS : FAST_ELEMENTS;
7421
7422 Handle<Map> map(isolate()->get_initial_js_array_map(kind));
7423
7424 HValue* function = BuildMonomorphicElementAccess(
7425 receiver, key, NULL, NULL, map, false, STANDARD_STORE);
7426
7427 call = New<HCallFunction>(function, argument_count);
7428 } else {
7429 call = New<HCallKeyed>(key, argument_count);
7430 }
7419 Drop(argument_count + 1); // 1 is the key. 7431 Drop(argument_count + 1); // 1 is the key.
7420 return ast_context()->ReturnInstruction(call, expr->id()); 7432 return ast_context()->ReturnInstruction(call, expr->id());
7421 } 7433 }
7422 7434
7423 // Named function call. 7435 // Named function call.
7424 if (TryCallApply(expr)) return; 7436 if (TryCallApply(expr)) return;
7425 7437
7426 CHECK_ALIVE(VisitForValue(prop->obj())); 7438 CHECK_ALIVE(VisitForValue(prop->obj()));
7427 CHECK_ALIVE(VisitExpressions(expr->arguments())); 7439 CHECK_ALIVE(VisitExpressions(expr->arguments()));
7428 7440
(...skipping 2903 matching lines...) Expand 10 before | Expand all | Expand 10 after
10332 if (ShouldProduceTraceOutput()) { 10344 if (ShouldProduceTraceOutput()) {
10333 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 10345 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
10334 } 10346 }
10335 10347
10336 #ifdef DEBUG 10348 #ifdef DEBUG
10337 graph_->Verify(false); // No full verify. 10349 graph_->Verify(false); // No full verify.
10338 #endif 10350 #endif
10339 } 10351 }
10340 10352
10341 } } // namespace v8::internal 10353 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698