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

Side by Side Diff: src/compiler.cc

Issue 803933008: new classes: change semantics of super(...) call and add new.target to construct stub. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Platform ports Created 5 years, 11 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 8
9 #include "src/ast-numbering.h" 9 #include "src/ast-numbering.h"
10 #include "src/ast-this-access-visitor.h" 10 #include "src/ast-this-access-visitor.h"
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 Handle<Object> exception; 778 Handle<Object> exception;
779 if (!obj.ToHandle(&exception)) return; 779 if (!obj.ToHandle(&exception)) return;
780 780
781 MessageLocation location(info->script(), stmt->position(), stmt->position()); 781 MessageLocation location(info->script(), stmt->position(), stmt->position());
782 USE(info->isolate()->Throw(*exception, &location)); 782 USE(info->isolate()->Throw(*exception, &location));
783 } 783 }
784 784
785 785
786 static bool CheckSuperConstructorCall(CompilationInfo* info) { 786 static bool CheckSuperConstructorCall(CompilationInfo* info) {
787 FunctionLiteral* function = info->function(); 787 FunctionLiteral* function = info->function();
788 if (FLAG_experimental_classes) return true;
788 if (!function->uses_super_constructor_call()) return true; 789 if (!function->uses_super_constructor_call()) return true;
789
790 if (function->is_default_constructor()) return true; 790 if (function->is_default_constructor()) return true;
791 791
792 ZoneList<Statement*>* body = function->body(); 792 ZoneList<Statement*>* body = function->body();
793 CHECK(body->length() > 0); 793 CHECK(body->length() > 0);
794 794
795 int super_call_index = 0; 795 int super_call_index = 0;
796 // Allow 'use strict' and similiar and empty statements. 796 // Allow 'use strict' and similiar and empty statements.
797 while (true) { 797 while (true) {
798 CHECK(super_call_index < body->length()); // We know there is a super call. 798 CHECK(super_call_index < body->length()); // We know there is a super call.
799 Statement* stmt = body->at(super_call_index); 799 Statement* stmt = body->at(super_call_index);
(...skipping 29 matching lines...) Expand all
829 ZoneList<Expression*>* arguments = callExpr->arguments(); 829 ZoneList<Expression*>* arguments = callExpr->arguments();
830 830
831 AstThisAccessVisitor this_access_visitor(info->zone()); 831 AstThisAccessVisitor this_access_visitor(info->zone());
832 this_access_visitor.VisitExpressions(arguments); 832 this_access_visitor.VisitExpressions(arguments);
833 833
834 if (this_access_visitor.HasStackOverflow()) return false; 834 if (this_access_visitor.HasStackOverflow()) return false;
835 if (this_access_visitor.UsesThis()) { 835 if (this_access_visitor.UsesThis()) {
836 ThrowSuperConstructorCheckError(info, stmt); 836 ThrowSuperConstructorCheckError(info, stmt);
837 return false; 837 return false;
838 } 838 }
839
840 return true; 839 return true;
841 } 840 }
842 841
843 842
844 bool Compiler::Analyze(CompilationInfo* info) { 843 bool Compiler::Analyze(CompilationInfo* info) {
845 DCHECK(info->function() != NULL); 844 DCHECK(info->function() != NULL);
846 if (!Rewriter::Rewrite(info)) return false; 845 if (!Rewriter::Rewrite(info)) return false;
847 if (!Scope::Analyze(info)) return false; 846 if (!Scope::Analyze(info)) return false;
848 if (!Renumber(info)) return false; 847 if (!Renumber(info)) return false;
849 DCHECK(info->scope() != NULL); 848 DCHECK(info->scope() != NULL);
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
1579 AllowHandleDereference allow_deref; 1578 AllowHandleDereference allow_deref;
1580 bool tracing_on = info()->IsStub() 1579 bool tracing_on = info()->IsStub()
1581 ? FLAG_trace_hydrogen_stubs 1580 ? FLAG_trace_hydrogen_stubs
1582 : (FLAG_trace_hydrogen && 1581 : (FLAG_trace_hydrogen &&
1583 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); 1582 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter));
1584 return (tracing_on && 1583 return (tracing_on &&
1585 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); 1584 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL);
1586 } 1585 }
1587 1586
1588 } } // namespace v8::internal 1587 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698