| OLD | NEW |
| 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/accessors.h" | 5 #include "src/accessors.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/contexts.h" | 8 #include "src/contexts.h" |
| 9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
| 10 #include "src/execution.h" | 10 #include "src/execution.h" |
| (...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1195 | 1195 |
| 1196 MaybeHandle<Object> result = ClearInternalStackTrace(isolate, holder); | 1196 MaybeHandle<Object> result = ClearInternalStackTrace(isolate, holder); |
| 1197 if (result.is_null()) { | 1197 if (result.is_null()) { |
| 1198 isolate->OptionalRescheduleException(false); | 1198 isolate->OptionalRescheduleException(false); |
| 1199 return; | 1199 return; |
| 1200 } | 1200 } |
| 1201 | 1201 |
| 1202 // If stack is still an accessor (this could have changed in the meantime | 1202 // If stack is still an accessor (this could have changed in the meantime |
| 1203 // since FormatStackTrace can execute arbitrary JS), replace it with a data | 1203 // since FormatStackTrace can execute arbitrary JS), replace it with a data |
| 1204 // property. | 1204 // property. |
| 1205 Handle<Object> receiver = Utils::OpenHandle(*info.This()); | 1205 Handle<Object> receiver = |
| 1206 Utils::OpenHandle(*v8::Local<v8::Value>(info.This())); |
| 1206 Handle<Name> name = Utils::OpenHandle(*key); | 1207 Handle<Name> name = Utils::OpenHandle(*key); |
| 1207 if (IsAccessor(receiver, name, holder)) { | 1208 if (IsAccessor(receiver, name, holder)) { |
| 1208 result = ReplaceAccessorWithDataProperty(isolate, receiver, holder, name, | 1209 result = ReplaceAccessorWithDataProperty(isolate, receiver, holder, name, |
| 1209 formatted_stack_trace); | 1210 formatted_stack_trace); |
| 1210 if (result.is_null()) { | 1211 if (result.is_null()) { |
| 1211 isolate->OptionalRescheduleException(false); | 1212 isolate->OptionalRescheduleException(false); |
| 1212 return; | 1213 return; |
| 1213 } | 1214 } |
| 1214 } else { | 1215 } else { |
| 1215 // The stack property has been modified in the meantime. | 1216 // The stack property has been modified in the meantime. |
| 1216 if (!JSObject::GetProperty(holder, name).ToHandle(&formatted_stack_trace)) { | 1217 if (!JSObject::GetProperty(holder, name).ToHandle(&formatted_stack_trace)) { |
| 1217 isolate->OptionalRescheduleException(false); | 1218 isolate->OptionalRescheduleException(false); |
| 1218 return; | 1219 return; |
| 1219 } | 1220 } |
| 1220 } | 1221 } |
| 1221 | 1222 |
| 1222 v8::Local<v8::Value> value = Utils::ToLocal(formatted_stack_trace); | 1223 v8::Local<v8::Value> value = Utils::ToLocal(formatted_stack_trace); |
| 1223 info.GetReturnValue().Set(value); | 1224 info.GetReturnValue().Set(value); |
| 1224 } | 1225 } |
| 1225 | 1226 |
| 1226 void Accessors::ErrorStackSetter( | 1227 void Accessors::ErrorStackSetter( |
| 1227 v8::Local<v8::Name> name, v8::Local<v8::Value> val, | 1228 v8::Local<v8::Name> name, v8::Local<v8::Value> val, |
| 1228 const v8::PropertyCallbackInfo<v8::Boolean>& info) { | 1229 const v8::PropertyCallbackInfo<v8::Boolean>& info) { |
| 1229 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 1230 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 1230 HandleScope scope(isolate); | 1231 HandleScope scope(isolate); |
| 1231 Handle<JSObject> obj = | 1232 Handle<JSObject> obj = Handle<JSObject>::cast( |
| 1232 Handle<JSObject>::cast(Utils::OpenHandle(*info.This())); | 1233 Utils::OpenHandle(*v8::Local<v8::Value>(info.This()))); |
| 1233 | 1234 |
| 1234 // Clear internal properties to avoid memory leaks. | 1235 // Clear internal properties to avoid memory leaks. |
| 1235 Handle<Symbol> stack_trace_symbol = isolate->factory()->stack_trace_symbol(); | 1236 Handle<Symbol> stack_trace_symbol = isolate->factory()->stack_trace_symbol(); |
| 1236 if (JSReceiver::HasOwnProperty(obj, stack_trace_symbol).FromMaybe(false)) { | 1237 if (JSReceiver::HasOwnProperty(obj, stack_trace_symbol).FromMaybe(false)) { |
| 1237 ClearInternalStackTrace(isolate, obj); | 1238 ClearInternalStackTrace(isolate, obj); |
| 1238 } | 1239 } |
| 1239 | 1240 |
| 1240 Accessors::ReconfigureToDataProperty(name, val, info); | 1241 Accessors::ReconfigureToDataProperty(name, val, info); |
| 1241 } | 1242 } |
| 1242 | 1243 |
| 1243 Handle<AccessorInfo> Accessors::ErrorStackInfo(Isolate* isolate, | 1244 Handle<AccessorInfo> Accessors::ErrorStackInfo(Isolate* isolate, |
| 1244 PropertyAttributes attributes) { | 1245 PropertyAttributes attributes) { |
| 1245 Handle<AccessorInfo> info = | 1246 Handle<AccessorInfo> info = |
| 1246 MakeAccessor(isolate, isolate->factory()->stack_string(), | 1247 MakeAccessor(isolate, isolate->factory()->stack_string(), |
| 1247 &ErrorStackGetter, &ErrorStackSetter, attributes); | 1248 &ErrorStackGetter, &ErrorStackSetter, attributes); |
| 1248 return info; | 1249 return info; |
| 1249 } | 1250 } |
| 1250 | 1251 |
| 1251 } // namespace internal | 1252 } // namespace internal |
| 1252 } // namespace v8 | 1253 } // namespace v8 |
| OLD | NEW |