| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1183 return isolate->heap()->ToBoolean(obj->map()->is_extensible()); | 1183 return isolate->heap()->ToBoolean(obj->map()->is_extensible()); |
| 1184 } | 1184 } |
| 1185 | 1185 |
| 1186 | 1186 |
| 1187 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpCompile) { | 1187 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpCompile) { |
| 1188 HandleScope scope(isolate); | 1188 HandleScope scope(isolate); |
| 1189 ASSERT(args.length() == 3); | 1189 ASSERT(args.length() == 3); |
| 1190 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, re, 0); | 1190 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, re, 0); |
| 1191 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1); | 1191 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1); |
| 1192 CONVERT_ARG_HANDLE_CHECKED(String, flags, 2); | 1192 CONVERT_ARG_HANDLE_CHECKED(String, flags, 2); |
| 1193 Handle<Object> result = RegExpImpl::Compile(re, pattern, flags); | 1193 Handle<Object> result = |
| 1194 RegExpImpl::Compile(re, pattern, flags, isolate->runtime_zone()); |
| 1194 if (result.is_null()) return Failure::Exception(); | 1195 if (result.is_null()) return Failure::Exception(); |
| 1195 return *result; | 1196 return *result; |
| 1196 } | 1197 } |
| 1197 | 1198 |
| 1198 | 1199 |
| 1199 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateApiFunction) { | 1200 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateApiFunction) { |
| 1200 HandleScope scope(isolate); | 1201 HandleScope scope(isolate); |
| 1201 ASSERT(args.length() == 1); | 1202 ASSERT(args.length() == 1); |
| 1202 CONVERT_ARG_HANDLE_CHECKED(FunctionTemplateInfo, data, 0); | 1203 CONVERT_ARG_HANDLE_CHECKED(FunctionTemplateInfo, data, 0); |
| 1203 return *isolate->factory()->CreateApiFunction(data); | 1204 return *isolate->factory()->CreateApiFunction(data); |
| (...skipping 1784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2988 MUST_USE_RESULT static MaybeObject* StringReplaceAtomRegExpWithString( | 2989 MUST_USE_RESULT static MaybeObject* StringReplaceAtomRegExpWithString( |
| 2989 Isolate* isolate, | 2990 Isolate* isolate, |
| 2990 Handle<String> subject, | 2991 Handle<String> subject, |
| 2991 Handle<JSRegExp> pattern_regexp, | 2992 Handle<JSRegExp> pattern_regexp, |
| 2992 Handle<String> replacement, | 2993 Handle<String> replacement, |
| 2993 Handle<JSArray> last_match_info, | 2994 Handle<JSArray> last_match_info, |
| 2994 Zone* zone) { | 2995 Zone* zone) { |
| 2995 ASSERT(subject->IsFlat()); | 2996 ASSERT(subject->IsFlat()); |
| 2996 ASSERT(replacement->IsFlat()); | 2997 ASSERT(replacement->IsFlat()); |
| 2997 | 2998 |
| 2998 ZoneScope zone_space(isolate, DELETE_ON_EXIT); | 2999 ZoneScope zone_space(isolate->runtime_zone(), DELETE_ON_EXIT); |
| 2999 ZoneList<int> indices(8, isolate->zone()); | 3000 ZoneList<int> indices(8, isolate->runtime_zone()); |
| 3000 ASSERT_EQ(JSRegExp::ATOM, pattern_regexp->TypeTag()); | 3001 ASSERT_EQ(JSRegExp::ATOM, pattern_regexp->TypeTag()); |
| 3001 String* pattern = | 3002 String* pattern = |
| 3002 String::cast(pattern_regexp->DataAt(JSRegExp::kAtomPatternIndex)); | 3003 String::cast(pattern_regexp->DataAt(JSRegExp::kAtomPatternIndex)); |
| 3003 int subject_len = subject->length(); | 3004 int subject_len = subject->length(); |
| 3004 int pattern_len = pattern->length(); | 3005 int pattern_len = pattern->length(); |
| 3005 int replacement_len = replacement->length(); | 3006 int replacement_len = replacement->length(); |
| 3006 | 3007 |
| 3007 FindStringIndicesDispatch(isolate, *subject, pattern, &indices, 0xffffffff, | 3008 FindStringIndicesDispatch(isolate, *subject, pattern, &indices, 0xffffffff, |
| 3008 zone); | 3009 zone); |
| 3009 | 3010 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3093 if (match.is_null()) { | 3094 if (match.is_null()) { |
| 3094 return Failure::Exception(); | 3095 return Failure::Exception(); |
| 3095 } | 3096 } |
| 3096 if (match->IsNull()) { | 3097 if (match->IsNull()) { |
| 3097 return *subject_handle; | 3098 return *subject_handle; |
| 3098 } | 3099 } |
| 3099 | 3100 |
| 3100 int capture_count = regexp_handle->CaptureCount(); | 3101 int capture_count = regexp_handle->CaptureCount(); |
| 3101 | 3102 |
| 3102 // CompiledReplacement uses zone allocation. | 3103 // CompiledReplacement uses zone allocation. |
| 3103 ZoneScope zonescope(isolate, DELETE_ON_EXIT); | 3104 ZoneScope zonescope(zone, DELETE_ON_EXIT); |
| 3104 CompiledReplacement compiled_replacement(isolate->zone()); | 3105 CompiledReplacement compiled_replacement(zone); |
| 3105 compiled_replacement.Compile(replacement_handle, | 3106 compiled_replacement.Compile(replacement_handle, |
| 3106 capture_count, | 3107 capture_count, |
| 3107 length); | 3108 length); |
| 3108 | 3109 |
| 3109 bool is_global = regexp_handle->GetFlags().is_global(); | 3110 bool is_global = regexp_handle->GetFlags().is_global(); |
| 3110 | 3111 |
| 3111 // Shortcut for simple non-regexp global replacements | 3112 // Shortcut for simple non-regexp global replacements |
| 3112 if (is_global && | 3113 if (is_global && |
| 3113 regexp_handle->TypeTag() == JSRegExp::ATOM && | 3114 regexp_handle->TypeTag() == JSRegExp::ATOM && |
| 3114 compiled_replacement.simple_hint()) { | 3115 compiled_replacement.simple_hint()) { |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3389 } | 3390 } |
| 3390 } | 3391 } |
| 3391 replacement = String::cast(flat_replacement); | 3392 replacement = String::cast(flat_replacement); |
| 3392 } | 3393 } |
| 3393 | 3394 |
| 3394 CONVERT_ARG_CHECKED(JSRegExp, regexp, 1); | 3395 CONVERT_ARG_CHECKED(JSRegExp, regexp, 1); |
| 3395 CONVERT_ARG_CHECKED(JSArray, last_match_info, 3); | 3396 CONVERT_ARG_CHECKED(JSArray, last_match_info, 3); |
| 3396 | 3397 |
| 3397 ASSERT(last_match_info->HasFastObjectElements()); | 3398 ASSERT(last_match_info->HasFastObjectElements()); |
| 3398 | 3399 |
| 3399 Zone* zone = isolate->zone(); | 3400 Zone* zone = isolate->runtime_zone(); |
| 3400 if (replacement->length() == 0) { | 3401 if (replacement->length() == 0) { |
| 3401 if (subject->HasOnlyAsciiChars()) { | 3402 if (subject->HasOnlyAsciiChars()) { |
| 3402 return StringReplaceRegExpWithEmptyString<SeqAsciiString>( | 3403 return StringReplaceRegExpWithEmptyString<SeqAsciiString>( |
| 3403 isolate, subject, regexp, last_match_info, zone); | 3404 isolate, subject, regexp, last_match_info, zone); |
| 3404 } else { | 3405 } else { |
| 3405 return StringReplaceRegExpWithEmptyString<SeqTwoByteString>( | 3406 return StringReplaceRegExpWithEmptyString<SeqTwoByteString>( |
| 3406 isolate, subject, regexp, last_match_info, zone); | 3407 isolate, subject, regexp, last_match_info, zone); |
| 3407 } | 3408 } |
| 3408 } | 3409 } |
| 3409 | 3410 |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3738 Handle<Object> match = RegExpImpl::Exec(regexp, subject, 0, regexp_info); | 3739 Handle<Object> match = RegExpImpl::Exec(regexp, subject, 0, regexp_info); |
| 3739 | 3740 |
| 3740 if (match.is_null()) { | 3741 if (match.is_null()) { |
| 3741 return Failure::Exception(); | 3742 return Failure::Exception(); |
| 3742 } | 3743 } |
| 3743 if (match->IsNull()) { | 3744 if (match->IsNull()) { |
| 3744 return isolate->heap()->null_value(); | 3745 return isolate->heap()->null_value(); |
| 3745 } | 3746 } |
| 3746 int length = subject->length(); | 3747 int length = subject->length(); |
| 3747 | 3748 |
| 3748 Zone* zone = isolate->zone(); | 3749 Zone* zone = isolate->runtime_zone(); |
| 3749 ZoneScope zone_space(isolate, DELETE_ON_EXIT); | 3750 ZoneScope zone_space(zone, DELETE_ON_EXIT); |
| 3750 ZoneList<int> offsets(8, zone); | 3751 ZoneList<int> offsets(8, zone); |
| 3751 int start; | 3752 int start; |
| 3752 int end; | 3753 int end; |
| 3753 do { | 3754 do { |
| 3754 { | 3755 { |
| 3755 AssertNoAllocation no_alloc; | 3756 AssertNoAllocation no_alloc; |
| 3756 FixedArray* elements = FixedArray::cast(regexp_info->elements()); | 3757 FixedArray* elements = FixedArray::cast(regexp_info->elements()); |
| 3757 start = Smi::cast(elements->get(RegExpImpl::kFirstCapture))->value(); | 3758 start = Smi::cast(elements->get(RegExpImpl::kFirstCapture))->value(); |
| 3758 end = Smi::cast(elements->get(RegExpImpl::kFirstCapture + 1))->value(); | 3759 end = Smi::cast(elements->get(RegExpImpl::kFirstCapture + 1))->value(); |
| 3759 } | 3760 } |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3933 } | 3934 } |
| 3934 | 3935 |
| 3935 | 3936 |
| 3936 // Only called from Runtime_RegExpExecMultiple so it doesn't need to maintain | 3937 // Only called from Runtime_RegExpExecMultiple so it doesn't need to maintain |
| 3937 // separate last match info. See comment on that function. | 3938 // separate last match info. See comment on that function. |
| 3938 static int SearchRegExpMultiple( | 3939 static int SearchRegExpMultiple( |
| 3939 Isolate* isolate, | 3940 Isolate* isolate, |
| 3940 Handle<String> subject, | 3941 Handle<String> subject, |
| 3941 Handle<JSRegExp> regexp, | 3942 Handle<JSRegExp> regexp, |
| 3942 Handle<JSArray> last_match_array, | 3943 Handle<JSArray> last_match_array, |
| 3943 FixedArrayBuilder* builder) { | 3944 FixedArrayBuilder* builder, |
| 3945 Zone* zone) { |
| 3944 | 3946 |
| 3945 ASSERT(subject->IsFlat()); | 3947 ASSERT(subject->IsFlat()); |
| 3946 int registers_per_match = RegExpImpl::IrregexpPrepare(regexp, subject); | 3948 int registers_per_match = RegExpImpl::IrregexpPrepare(regexp, subject); |
| 3947 if (registers_per_match < 0) return RegExpImpl::RE_EXCEPTION; | 3949 if (registers_per_match < 0) return RegExpImpl::RE_EXCEPTION; |
| 3948 | 3950 |
| 3949 int max_matches; | 3951 int max_matches; |
| 3950 int num_registers = RegExpImpl::GlobalOffsetsVectorSize(regexp, | 3952 int num_registers = RegExpImpl::GlobalOffsetsVectorSize(regexp, |
| 3951 registers_per_match, | 3953 registers_per_match, |
| 3952 &max_matches); | 3954 &max_matches); |
| 3953 OffsetsVector registers(num_registers, isolate); | 3955 OffsetsVector registers(num_registers, isolate); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4116 result = SearchRegExpNoCaptureMultiple(isolate, | 4118 result = SearchRegExpNoCaptureMultiple(isolate, |
| 4117 subject, | 4119 subject, |
| 4118 regexp, | 4120 regexp, |
| 4119 last_match_info, | 4121 last_match_info, |
| 4120 &builder); | 4122 &builder); |
| 4121 } else { | 4123 } else { |
| 4122 result = SearchRegExpMultiple(isolate, | 4124 result = SearchRegExpMultiple(isolate, |
| 4123 subject, | 4125 subject, |
| 4124 regexp, | 4126 regexp, |
| 4125 last_match_info, | 4127 last_match_info, |
| 4126 &builder); | 4128 &builder, |
| 4129 isolate->runtime_zone()); |
| 4127 } | 4130 } |
| 4128 if (result == RegExpImpl::RE_SUCCESS) return *builder.ToJSArray(result_array); | 4131 if (result == RegExpImpl::RE_SUCCESS) return *builder.ToJSArray(result_array); |
| 4129 if (result == RegExpImpl::RE_FAILURE) return isolate->heap()->null_value(); | 4132 if (result == RegExpImpl::RE_FAILURE) return isolate->heap()->null_value(); |
| 4130 ASSERT_EQ(result, RegExpImpl::RE_EXCEPTION); | 4133 ASSERT_EQ(result, RegExpImpl::RE_EXCEPTION); |
| 4131 return Failure::Exception(); | 4134 return Failure::Exception(); |
| 4132 } | 4135 } |
| 4133 | 4136 |
| 4134 | 4137 |
| 4135 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToRadixString) { | 4138 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToRadixString) { |
| 4136 NoHandleAllocation ha; | 4139 NoHandleAllocation ha; |
| (...skipping 2313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6450 } | 6453 } |
| 6451 | 6454 |
| 6452 // The limit can be very large (0xffffffffu), but since the pattern | 6455 // The limit can be very large (0xffffffffu), but since the pattern |
| 6453 // isn't empty, we can never create more parts than ~half the length | 6456 // isn't empty, we can never create more parts than ~half the length |
| 6454 // of the subject. | 6457 // of the subject. |
| 6455 | 6458 |
| 6456 if (!subject->IsFlat()) FlattenString(subject); | 6459 if (!subject->IsFlat()) FlattenString(subject); |
| 6457 | 6460 |
| 6458 static const int kMaxInitialListCapacity = 16; | 6461 static const int kMaxInitialListCapacity = 16; |
| 6459 | 6462 |
| 6460 Zone* zone = isolate->zone(); | 6463 Zone* zone = isolate->runtime_zone(); |
| 6461 ZoneScope scope(isolate, DELETE_ON_EXIT); | 6464 ZoneScope scope(zone, DELETE_ON_EXIT); |
| 6462 | 6465 |
| 6463 // Find (up to limit) indices of separator and end-of-string in subject | 6466 // Find (up to limit) indices of separator and end-of-string in subject |
| 6464 int initial_capacity = Min<uint32_t>(kMaxInitialListCapacity, limit); | 6467 int initial_capacity = Min<uint32_t>(kMaxInitialListCapacity, limit); |
| 6465 ZoneList<int> indices(initial_capacity, zone); | 6468 ZoneList<int> indices(initial_capacity, zone); |
| 6466 if (!pattern->IsFlat()) FlattenString(pattern); | 6469 if (!pattern->IsFlat()) FlattenString(pattern); |
| 6467 | 6470 |
| 6468 FindStringIndicesDispatch(isolate, *subject, *pattern, &indices, limit, zone); | 6471 FindStringIndicesDispatch(isolate, *subject, *pattern, &indices, limit, zone); |
| 6469 | 6472 |
| 6470 if (static_cast<uint32_t>(indices.length()) < limit) { | 6473 if (static_cast<uint32_t>(indices.length()) < limit) { |
| 6471 indices.Add(subject_length, zone); | 6474 indices.Add(subject_length, zone); |
| (...skipping 2827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9299 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); | 9302 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); |
| 9300 return JSGlobalObject::cast(global)->global_receiver(); | 9303 return JSGlobalObject::cast(global)->global_receiver(); |
| 9301 } | 9304 } |
| 9302 | 9305 |
| 9303 | 9306 |
| 9304 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) { | 9307 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) { |
| 9305 HandleScope scope(isolate); | 9308 HandleScope scope(isolate); |
| 9306 ASSERT_EQ(1, args.length()); | 9309 ASSERT_EQ(1, args.length()); |
| 9307 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); | 9310 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); |
| 9308 | 9311 |
| 9309 Zone* zone = isolate->zone(); | 9312 Zone* zone = isolate->runtime_zone(); |
| 9310 source = Handle<String>(source->TryFlattenGetString()); | 9313 source = Handle<String>(source->TryFlattenGetString()); |
| 9311 // Optimized fast case where we only have ASCII characters. | 9314 // Optimized fast case where we only have ASCII characters. |
| 9312 Handle<Object> result; | 9315 Handle<Object> result; |
| 9313 if (source->IsSeqAsciiString()) { | 9316 if (source->IsSeqAsciiString()) { |
| 9314 result = JsonParser<true>::Parse(source, zone); | 9317 result = JsonParser<true>::Parse(source, zone); |
| 9315 } else { | 9318 } else { |
| 9316 result = JsonParser<false>::Parse(source, zone); | 9319 result = JsonParser<false>::Parse(source, zone); |
| 9317 } | 9320 } |
| 9318 if (result.is_null()) { | 9321 if (result.is_null()) { |
| 9319 // Syntax error or stack overflow in scanner. | 9322 // Syntax error or stack overflow in scanner. |
| (...skipping 1846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11166 if (scope_info->HasContext()) { | 11169 if (scope_info->HasContext()) { |
| 11167 context_ = Handle<Context>(context_->declaration_context(), isolate_); | 11170 context_ = Handle<Context>(context_->declaration_context(), isolate_); |
| 11168 } else { | 11171 } else { |
| 11169 while (context_->closure() == *function_) { | 11172 while (context_->closure() == *function_) { |
| 11170 context_ = Handle<Context>(context_->previous(), isolate_); | 11173 context_ = Handle<Context>(context_->previous(), isolate_); |
| 11171 } | 11174 } |
| 11172 } | 11175 } |
| 11173 if (scope_info->Type() != EVAL_SCOPE) nested_scope_chain_.Add(scope_info); | 11176 if (scope_info->Type() != EVAL_SCOPE) nested_scope_chain_.Add(scope_info); |
| 11174 } else { | 11177 } else { |
| 11175 // Reparse the code and analyze the scopes. | 11178 // Reparse the code and analyze the scopes. |
| 11176 ZoneScope zone_scope(isolate, DELETE_ON_EXIT); | |
| 11177 Handle<Script> script(Script::cast(shared_info->script())); | 11179 Handle<Script> script(Script::cast(shared_info->script())); |
| 11178 Scope* scope = NULL; | 11180 Scope* scope = NULL; |
| 11179 | 11181 |
| 11180 // Check whether we are in global, eval or function code. | 11182 // Check whether we are in global, eval or function code. |
| 11181 Handle<ScopeInfo> scope_info(shared_info->scope_info()); | 11183 Handle<ScopeInfo> scope_info(shared_info->scope_info()); |
| 11182 if (scope_info->Type() != FUNCTION_SCOPE) { | 11184 if (scope_info->Type() != FUNCTION_SCOPE) { |
| 11183 // Global or eval code. | 11185 // Global or eval code. |
| 11184 CompilationInfo info(script); | 11186 CompilationInfoWithZone info(script); |
| 11185 if (scope_info->Type() == GLOBAL_SCOPE) { | 11187 if (scope_info->Type() == GLOBAL_SCOPE) { |
| 11186 info.MarkAsGlobal(); | 11188 info.MarkAsGlobal(); |
| 11187 } else { | 11189 } else { |
| 11188 ASSERT(scope_info->Type() == EVAL_SCOPE); | 11190 ASSERT(scope_info->Type() == EVAL_SCOPE); |
| 11189 info.MarkAsEval(); | 11191 info.MarkAsEval(); |
| 11190 info.SetCallingContext(Handle<Context>(function_->context())); | 11192 info.SetCallingContext(Handle<Context>(function_->context())); |
| 11191 } | 11193 } |
| 11192 if (ParserApi::Parse(&info, kNoParsingFlags) && Scope::Analyze(&info)) { | 11194 if (ParserApi::Parse(&info, kNoParsingFlags) && Scope::Analyze(&info)) { |
| 11193 scope = info.function()->scope(); | 11195 scope = info.function()->scope(); |
| 11194 } | 11196 } |
| 11197 RetrieveScopeChain(scope, shared_info); |
| 11195 } else { | 11198 } else { |
| 11196 // Function code | 11199 // Function code |
| 11197 CompilationInfo info(shared_info); | 11200 CompilationInfoWithZone info(shared_info); |
| 11198 if (ParserApi::Parse(&info, kNoParsingFlags) && Scope::Analyze(&info)) { | 11201 if (ParserApi::Parse(&info, kNoParsingFlags) && Scope::Analyze(&info)) { |
| 11199 scope = info.function()->scope(); | 11202 scope = info.function()->scope(); |
| 11200 } | 11203 } |
| 11201 } | 11204 RetrieveScopeChain(scope, shared_info); |
| 11202 | |
| 11203 // Retrieve the scope chain for the current position. | |
| 11204 if (scope != NULL) { | |
| 11205 int source_position = shared_info->code()->SourcePosition(frame_->pc()); | |
| 11206 scope->GetNestedScopeChain(&nested_scope_chain_, source_position); | |
| 11207 } else { | |
| 11208 // A failed reparse indicates that the preparser has diverged from the | |
| 11209 // parser or that the preparse data given to the initial parse has been | |
| 11210 // faulty. We fail in debug mode but in release mode we only provide the | |
| 11211 // information we get from the context chain but nothing about | |
| 11212 // completely stack allocated scopes or stack allocated locals. | |
| 11213 UNREACHABLE(); | |
| 11214 } | 11205 } |
| 11215 } | 11206 } |
| 11216 } | 11207 } |
| 11217 | 11208 |
| 11218 ScopeIterator(Isolate* isolate, | 11209 ScopeIterator(Isolate* isolate, |
| 11219 Handle<JSFunction> function) | 11210 Handle<JSFunction> function) |
| 11220 : isolate_(isolate), | 11211 : isolate_(isolate), |
| 11221 frame_(NULL), | 11212 frame_(NULL), |
| 11222 inlined_jsframe_index_(0), | 11213 inlined_jsframe_index_(0), |
| 11223 function_(function), | 11214 function_(function), |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11403 #endif | 11394 #endif |
| 11404 | 11395 |
| 11405 private: | 11396 private: |
| 11406 Isolate* isolate_; | 11397 Isolate* isolate_; |
| 11407 JavaScriptFrame* frame_; | 11398 JavaScriptFrame* frame_; |
| 11408 int inlined_jsframe_index_; | 11399 int inlined_jsframe_index_; |
| 11409 Handle<JSFunction> function_; | 11400 Handle<JSFunction> function_; |
| 11410 Handle<Context> context_; | 11401 Handle<Context> context_; |
| 11411 List<Handle<ScopeInfo> > nested_scope_chain_; | 11402 List<Handle<ScopeInfo> > nested_scope_chain_; |
| 11412 | 11403 |
| 11404 void RetrieveScopeChain(Scope* scope, |
| 11405 Handle<SharedFunctionInfo> shared_info) { |
| 11406 if (scope != NULL) { |
| 11407 int source_position = shared_info->code()->SourcePosition(frame_->pc()); |
| 11408 scope->GetNestedScopeChain(&nested_scope_chain_, source_position); |
| 11409 } else { |
| 11410 // A failed reparse indicates that the preparser has diverged from the |
| 11411 // parser or that the preparse data given to the initial parse has been |
| 11412 // faulty. We fail in debug mode but in release mode we only provide the |
| 11413 // information we get from the context chain but nothing about |
| 11414 // completely stack allocated scopes or stack allocated locals. |
| 11415 UNREACHABLE(); |
| 11416 } |
| 11417 } |
| 11418 |
| 11413 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator); | 11419 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator); |
| 11414 }; | 11420 }; |
| 11415 | 11421 |
| 11416 | 11422 |
| 11417 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeCount) { | 11423 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeCount) { |
| 11418 HandleScope scope(isolate); | 11424 HandleScope scope(isolate); |
| 11419 ASSERT(args.length() == 2); | 11425 ASSERT(args.length() == 2); |
| 11420 | 11426 |
| 11421 // Check arguments. | 11427 // Check arguments. |
| 11422 Object* check; | 11428 Object* check; |
| (...skipping 1358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12781 // checks that none of them have activations on stacks (of any thread). | 12787 // checks that none of them have activations on stacks (of any thread). |
| 12782 // Returns array of the same length with corresponding results of | 12788 // Returns array of the same length with corresponding results of |
| 12783 // LiveEdit::FunctionPatchabilityStatus type. | 12789 // LiveEdit::FunctionPatchabilityStatus type. |
| 12784 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCheckAndDropActivations) { | 12790 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCheckAndDropActivations) { |
| 12785 ASSERT(args.length() == 2); | 12791 ASSERT(args.length() == 2); |
| 12786 HandleScope scope(isolate); | 12792 HandleScope scope(isolate); |
| 12787 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0); | 12793 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0); |
| 12788 CONVERT_BOOLEAN_ARG_CHECKED(do_drop, 1); | 12794 CONVERT_BOOLEAN_ARG_CHECKED(do_drop, 1); |
| 12789 | 12795 |
| 12790 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop, | 12796 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop, |
| 12791 isolate->zone()); | 12797 isolate->runtime_zone()); |
| 12792 } | 12798 } |
| 12793 | 12799 |
| 12794 // Compares 2 strings line-by-line, then token-wise and returns diff in form | 12800 // Compares 2 strings line-by-line, then token-wise and returns diff in form |
| 12795 // of JSArray of triplets (pos1, pos1_end, pos2_end) describing list | 12801 // of JSArray of triplets (pos1, pos1_end, pos2_end) describing list |
| 12796 // of diff chunks. | 12802 // of diff chunks. |
| 12797 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCompareStrings) { | 12803 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCompareStrings) { |
| 12798 ASSERT(args.length() == 2); | 12804 ASSERT(args.length() == 2); |
| 12799 HandleScope scope(isolate); | 12805 HandleScope scope(isolate); |
| 12800 CONVERT_ARG_HANDLE_CHECKED(String, s1, 0); | 12806 CONVERT_ARG_HANDLE_CHECKED(String, s1, 0); |
| 12801 CONVERT_ARG_HANDLE_CHECKED(String, s2, 1); | 12807 CONVERT_ARG_HANDLE_CHECKED(String, s2, 1); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 12828 | 12834 |
| 12829 int count = 0; | 12835 int count = 0; |
| 12830 JavaScriptFrameIterator it(isolate, id); | 12836 JavaScriptFrameIterator it(isolate, id); |
| 12831 for (; !it.done(); it.Advance()) { | 12837 for (; !it.done(); it.Advance()) { |
| 12832 if (index < count + it.frame()->GetInlineCount()) break; | 12838 if (index < count + it.frame()->GetInlineCount()) break; |
| 12833 count += it.frame()->GetInlineCount(); | 12839 count += it.frame()->GetInlineCount(); |
| 12834 } | 12840 } |
| 12835 if (it.done()) return heap->undefined_value(); | 12841 if (it.done()) return heap->undefined_value(); |
| 12836 | 12842 |
| 12837 const char* error_message = | 12843 const char* error_message = |
| 12838 LiveEdit::RestartFrame(it.frame(), isolate->zone()); | 12844 LiveEdit::RestartFrame(it.frame(), isolate->runtime_zone()); |
| 12839 if (error_message) { | 12845 if (error_message) { |
| 12840 return *(isolate->factory()->LookupAsciiSymbol(error_message)); | 12846 return *(isolate->factory()->LookupAsciiSymbol(error_message)); |
| 12841 } | 12847 } |
| 12842 return heap->true_value(); | 12848 return heap->true_value(); |
| 12843 } | 12849 } |
| 12844 | 12850 |
| 12845 | 12851 |
| 12846 // A testing entry. Returns statement position which is the closest to | 12852 // A testing entry. Returns statement position which is the closest to |
| 12847 // source_position. | 12853 // source_position. |
| 12848 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionCodePositionFromSource) { | 12854 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionCodePositionFromSource) { |
| (...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13646 // Handle last resort GC and make sure to allow future allocations | 13652 // Handle last resort GC and make sure to allow future allocations |
| 13647 // to grow the heap without causing GCs (if possible). | 13653 // to grow the heap without causing GCs (if possible). |
| 13648 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13654 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13649 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13655 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 13650 "Runtime::PerformGC"); | 13656 "Runtime::PerformGC"); |
| 13651 } | 13657 } |
| 13652 } | 13658 } |
| 13653 | 13659 |
| 13654 | 13660 |
| 13655 } } // namespace v8::internal | 13661 } } // namespace v8::internal |
| OLD | NEW |