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

Side by Side Diff: src/runtime/runtime-regexp.cc

Issue 1432453005: Revert of Use in-object fields instead of private symbols for regexp slots. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « src/runtime/runtime.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/conversions-inl.h" 8 #include "src/conversions-inl.h"
9 #include "src/isolate-inl.h" 9 #include "src/isolate-inl.h"
10 #include "src/messages.h" 10 #include "src/messages.h"
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 RUNTIME_ASSERT(index <= subject->length()); 781 RUNTIME_ASSERT(index <= subject->length());
782 isolate->counters()->regexp_entry_runtime()->Increment(); 782 isolate->counters()->regexp_entry_runtime()->Increment();
783 Handle<Object> result; 783 Handle<Object> result;
784 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 784 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
785 isolate, result, 785 isolate, result,
786 RegExpImpl::Exec(regexp, subject, index, last_match_info)); 786 RegExpImpl::Exec(regexp, subject, index, last_match_info));
787 return *result; 787 return *result;
788 } 788 }
789 789
790 790
791 RUNTIME_FUNCTION(Runtime_RegExpFlags) {
792 SealHandleScope shs(isolate);
793 DCHECK(args.length() == 1);
794 CONVERT_ARG_CHECKED(JSRegExp, regexp, 0);
795 return regexp->flags();
796 }
797
798
799 RUNTIME_FUNCTION(Runtime_RegExpSource) {
800 SealHandleScope shs(isolate);
801 DCHECK(args.length() == 1);
802 CONVERT_ARG_CHECKED(JSRegExp, regexp, 0);
803 return regexp->source();
804 }
805
806
807 RUNTIME_FUNCTION(Runtime_RegExpConstructResult) { 791 RUNTIME_FUNCTION(Runtime_RegExpConstructResult) {
808 HandleScope handle_scope(isolate); 792 HandleScope handle_scope(isolate);
809 DCHECK(args.length() == 3); 793 DCHECK(args.length() == 3);
810 CONVERT_SMI_ARG_CHECKED(size, 0); 794 CONVERT_SMI_ARG_CHECKED(size, 0);
811 RUNTIME_ASSERT(size >= 0 && size <= FixedArray::kMaxLength); 795 RUNTIME_ASSERT(size >= 0 && size <= FixedArray::kMaxLength);
812 CONVERT_ARG_HANDLE_CHECKED(Object, index, 1); 796 CONVERT_ARG_HANDLE_CHECKED(Object, index, 1);
813 CONVERT_ARG_HANDLE_CHECKED(Object, input, 2); 797 CONVERT_ARG_HANDLE_CHECKED(Object, input, 2);
814 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(size); 798 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(size);
815 Handle<Map> regexp_map(isolate->native_context()->regexp_result_map()); 799 Handle<Map> regexp_map(isolate->native_context()->regexp_result_map());
816 Handle<JSObject> object = 800 Handle<JSObject> object =
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 if (!success) { 917 if (!success) {
934 THROW_NEW_ERROR_RETURN_FAILURE( 918 THROW_NEW_ERROR_RETURN_FAILURE(
935 isolate, 919 isolate,
936 NewSyntaxError(MessageTemplate::kInvalidRegExpFlags, flags_string)); 920 NewSyntaxError(MessageTemplate::kInvalidRegExpFlags, flags_string));
937 } 921 }
938 922
939 Handle<String> escaped_source; 923 Handle<String> escaped_source;
940 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, escaped_source, 924 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, escaped_source,
941 EscapeRegExpSource(isolate, source)); 925 EscapeRegExpSource(isolate, source));
942 926
943 regexp->set_source(*escaped_source);
944 regexp->set_flags(Smi::FromInt(flags.value()));
945
946 Map* map = regexp->map(); 927 Map* map = regexp->map();
947 Object* constructor = map->GetConstructor(); 928 Object* constructor = map->GetConstructor();
948 if (constructor->IsJSFunction() && 929 if (constructor->IsJSFunction() &&
949 JSFunction::cast(constructor)->initial_map() == map) { 930 JSFunction::cast(constructor)->initial_map() == map) {
950 // If we still have the original map, set in-object properties directly. 931 // If we still have the original map, set in-object properties directly.
932 regexp->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, *escaped_source);
933 regexp->InObjectPropertyAtPut(JSRegExp::kFlagsFieldIndex,
934 Smi::FromInt(flags.value()),
935 SKIP_WRITE_BARRIER);
951 regexp->InObjectPropertyAtPut(JSRegExp::kLastIndexFieldIndex, 936 regexp->InObjectPropertyAtPut(JSRegExp::kLastIndexFieldIndex,
952 Smi::FromInt(0), SKIP_WRITE_BARRIER); 937 Smi::FromInt(0), SKIP_WRITE_BARRIER);
953 } else { 938 } else {
954 // Map has changed, so use generic, but slower, method. 939 // Map has changed, so use generic, but slower, method. We also end here if
940 // the --harmony-regexp flag is set, because the initial map does not have
941 // space for the 'sticky' flag, since it is from the snapshot, but must work
942 // both with and without --harmony-regexp. When sticky comes out from under
943 // the flag, we will be able to use the fast initial map.
944 PropertyAttributes final =
945 static_cast<PropertyAttributes>(READ_ONLY | DONT_ENUM | DONT_DELETE);
955 PropertyAttributes writable = 946 PropertyAttributes writable =
956 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); 947 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE);
948 Handle<Object> zero(Smi::FromInt(0), isolate);
957 JSObject::SetOwnPropertyIgnoreAttributes( 949 JSObject::SetOwnPropertyIgnoreAttributes(
958 regexp, factory->last_index_string(), 950 regexp, factory->regexp_source_symbol(), escaped_source, final)
959 Handle<Smi>(Smi::FromInt(0), isolate), writable)
960 .Check(); 951 .Check();
952 JSObject::SetOwnPropertyIgnoreAttributes(
953 regexp, factory->regexp_flags_symbol(),
954 Handle<Smi>(Smi::FromInt(flags.value()), isolate), final)
955 .Check();
956 JSObject::SetOwnPropertyIgnoreAttributes(
957 regexp, factory->last_index_string(), zero, writable).Check();
961 } 958 }
962 959
963 Handle<Object> result; 960 Handle<Object> result;
964 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 961 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
965 isolate, result, RegExpImpl::Compile(regexp, source, flags)); 962 isolate, result, RegExpImpl::Compile(regexp, source, flags));
966 return *result; 963 return *result;
967 } 964 }
968 965
969 966
970 RUNTIME_FUNCTION(Runtime_MaterializeRegExpLiteral) { 967 RUNTIME_FUNCTION(Runtime_MaterializeRegExpLiteral) {
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 1166
1170 1167
1171 RUNTIME_FUNCTION(Runtime_IsRegExp) { 1168 RUNTIME_FUNCTION(Runtime_IsRegExp) {
1172 SealHandleScope shs(isolate); 1169 SealHandleScope shs(isolate);
1173 DCHECK(args.length() == 1); 1170 DCHECK(args.length() == 1);
1174 CONVERT_ARG_CHECKED(Object, obj, 0); 1171 CONVERT_ARG_CHECKED(Object, obj, 0);
1175 return isolate->heap()->ToBoolean(obj->IsJSRegExp()); 1172 return isolate->heap()->ToBoolean(obj->IsJSRegExp());
1176 } 1173 }
1177 } // namespace internal 1174 } // namespace internal
1178 } // namespace v8 1175 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698