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

Side by Side Diff: src/hydrogen.cc

Issue 23537067: Add support for keyed-call on arrays of fast elements (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 7 years, 2 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
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 2019 matching lines...) Expand 10 before | Expand all | Expand 10 after
2030 HValue* constructor_function) : 2030 HValue* constructor_function) :
2031 builder_(builder), 2031 builder_(builder),
2032 kind_(kind), 2032 kind_(kind),
2033 mode_(DONT_TRACK_ALLOCATION_SITE), 2033 mode_(DONT_TRACK_ALLOCATION_SITE),
2034 allocation_site_payload_(NULL), 2034 allocation_site_payload_(NULL),
2035 constructor_function_(constructor_function) { 2035 constructor_function_(constructor_function) {
2036 } 2036 }
2037 2037
2038 2038
2039 HValue* HGraphBuilder::JSArrayBuilder::EmitMapCode() { 2039 HValue* HGraphBuilder::JSArrayBuilder::EmitMapCode() {
2040 if (kind_ == GetInitialFastElementsKind()) { 2040 if (constructor_function_ != NULL && kind_ == GetInitialFastElementsKind()) {
2041 // No need for a context lookup if the kind_ matches the initial 2041 // No need for a context lookup if the kind_ matches the initial
2042 // map, because we can just load the map in that case. 2042 // map, because we can just load the map in that case.
2043 HObjectAccess access = HObjectAccess::ForPrototypeOrInitialMap(); 2043 HObjectAccess access = HObjectAccess::ForPrototypeOrInitialMap();
2044 return builder()->AddInstruction( 2044 return builder()->AddInstruction(
2045 builder()->BuildLoadNamedField(constructor_function_, access)); 2045 builder()->BuildLoadNamedField(constructor_function_, access));
2046 } 2046 }
2047 2047
2048 HInstruction* native_context = builder()->BuildGetNativeContext(); 2048 HInstruction* native_context = builder()->BuildGetNativeContext();
2049 HInstruction* index = builder()->Add<HConstant>( 2049 HInstruction* index = builder()->Add<HConstant>(
2050 static_cast<int32_t>(Context::JS_ARRAY_MAPS_INDEX)); 2050 static_cast<int32_t>(Context::JS_ARRAY_MAPS_INDEX));
(...skipping 4983 matching lines...) Expand 10 before | Expand all | Expand 10 after
7034 ASSERT(current_block() != NULL); 7034 ASSERT(current_block() != NULL);
7035 ASSERT(current_block()->HasPredecessor()); 7035 ASSERT(current_block()->HasPredecessor());
7036 Expression* callee = expr->expression(); 7036 Expression* callee = expr->expression();
7037 int argument_count = expr->arguments()->length() + 1; // Plus receiver. 7037 int argument_count = expr->arguments()->length() + 1; // Plus receiver.
7038 HInstruction* call = NULL; 7038 HInstruction* call = NULL;
7039 7039
7040 Property* prop = callee->AsProperty(); 7040 Property* prop = callee->AsProperty();
7041 if (prop != NULL) { 7041 if (prop != NULL) {
7042 if (!prop->key()->IsPropertyName()) { 7042 if (!prop->key()->IsPropertyName()) {
7043 // Keyed function call. 7043 // Keyed function call.
7044 CHECK_ALIVE(VisitArgument(prop->obj())); 7044 CHECK_ALIVE(VisitForValue(prop->obj()));
7045 CHECK_ALIVE(VisitForValue(prop->key()));
7045 7046
7046 CHECK_ALIVE(VisitForValue(prop->key()));
7047 // Push receiver and key like the non-optimized code generator expects it. 7047 // Push receiver and key like the non-optimized code generator expects it.
7048 HValue* key = Pop(); 7048 HValue* key = Pop();
7049 HValue* receiver = Pop(); 7049 HValue* receiver = Pop();
7050 Push(key); 7050 Push(key);
7051 Push(receiver); 7051 PushAndAdd(New<HPushArgument>(receiver));
7052
7053 CHECK_ALIVE(VisitArgumentList(expr->arguments())); 7052 CHECK_ALIVE(VisitArgumentList(expr->arguments()));
7054 7053
7055 HValue* context = environment()->context(); 7054 if (expr->IsMonomorphic()) {
7056 call = new(zone()) HCallKeyed(context, key, argument_count); 7055 BuildCheckHeapObject(receiver);
7056 ElementsKind kind = expr->KeyedArrayCallIsHoley()
7057 ? FAST_HOLEY_ELEMENTS : FAST_ELEMENTS;
7058
7059 Handle<Map> map(isolate()->get_initial_js_array_map(kind));
7060
7061 HValue* function = BuildMonomorphicElementAccess(
7062 receiver, key, NULL, NULL, map, false, STANDARD_STORE);
7063
7064 call = New<HCallFunction>(function, argument_count);
7065 } else {
7066 HValue* context = environment()->context();
7067 call = new(zone()) HCallKeyed(context, key, argument_count);
7068 }
7057 call->set_position(expr->position()); 7069 call->set_position(expr->position());
7058 Drop(argument_count + 1); // 1 is the key. 7070 Drop(argument_count + 1); // 1 is the key.
7059 return ast_context()->ReturnInstruction(call, expr->id()); 7071 return ast_context()->ReturnInstruction(call, expr->id());
7060 } 7072 }
7061 7073
7062 // Named function call. 7074 // Named function call.
7063 if (TryCallApply(expr)) return; 7075 if (TryCallApply(expr)) return;
7064 7076
7065 CHECK_ALIVE(VisitForValue(prop->obj())); 7077 CHECK_ALIVE(VisitForValue(prop->obj()));
7066 CHECK_ALIVE(VisitExpressions(expr->arguments())); 7078 CHECK_ALIVE(VisitExpressions(expr->arguments()));
(...skipping 2840 matching lines...) Expand 10 before | Expand all | Expand 10 after
9907 if (ShouldProduceTraceOutput()) { 9919 if (ShouldProduceTraceOutput()) {
9908 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 9920 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
9909 } 9921 }
9910 9922
9911 #ifdef DEBUG 9923 #ifdef DEBUG
9912 graph_->Verify(false); // No full verify. 9924 graph_->Verify(false); // No full verify.
9913 #endif 9925 #endif
9914 } 9926 }
9915 9927
9916 } } // namespace v8::internal 9928 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | src/ia32/lithium-ia32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698