| 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 16 matching lines...) Expand all Loading... |
| 27 AccessorNameSetterCallback setter, | 27 AccessorNameSetterCallback setter, |
| 28 PropertyAttributes attributes) { | 28 PropertyAttributes attributes) { |
| 29 Factory* factory = isolate->factory(); | 29 Factory* factory = isolate->factory(); |
| 30 Handle<AccessorInfo> info = factory->NewAccessorInfo(); | 30 Handle<AccessorInfo> info = factory->NewAccessorInfo(); |
| 31 info->set_property_attributes(attributes); | 31 info->set_property_attributes(attributes); |
| 32 info->set_all_can_read(false); | 32 info->set_all_can_read(false); |
| 33 info->set_all_can_write(false); | 33 info->set_all_can_write(false); |
| 34 info->set_is_special_data_property(true); | 34 info->set_is_special_data_property(true); |
| 35 info->set_name(*name); | 35 info->set_name(*name); |
| 36 Handle<Object> get = v8::FromCData(isolate, getter); | 36 Handle<Object> get = v8::FromCData(isolate, getter); |
| 37 if (setter == nullptr) setter = &ReconfigureToDataProperty; |
| 37 Handle<Object> set = v8::FromCData(isolate, setter); | 38 Handle<Object> set = v8::FromCData(isolate, setter); |
| 38 info->set_getter(*get); | 39 info->set_getter(*get); |
| 39 info->set_setter(*set); | 40 info->set_setter(*set); |
| 40 return info; | 41 return info; |
| 41 } | 42 } |
| 42 | 43 |
| 43 | 44 |
| 44 static V8_INLINE bool CheckForName(Handle<Name> name, | 45 static V8_INLINE bool CheckForName(Handle<Name> name, |
| 45 Handle<String> property_name, | 46 Handle<String> property_name, |
| 46 int offset, | 47 int offset, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 case JS_DATA_VIEW_TYPE: | 119 case JS_DATA_VIEW_TYPE: |
| 119 return CheckForName(name, isolate->factory()->byte_length_string(), | 120 return CheckForName(name, isolate->factory()->byte_length_string(), |
| 120 JSDataView::kByteLengthOffset, object_offset) || | 121 JSDataView::kByteLengthOffset, object_offset) || |
| 121 CheckForName(name, isolate->factory()->byte_offset_string(), | 122 CheckForName(name, isolate->factory()->byte_offset_string(), |
| 122 JSDataView::kByteOffsetOffset, object_offset); | 123 JSDataView::kByteOffsetOffset, object_offset); |
| 123 default: | 124 default: |
| 124 return false; | 125 return false; |
| 125 } | 126 } |
| 126 } | 127 } |
| 127 | 128 |
| 129 MUST_USE_RESULT static MaybeHandle<Object> ReplaceAccessorWithDataProperty( |
| 130 Isolate* isolate, Handle<JSObject> receiver, Handle<JSObject> holder, |
| 131 Handle<Name> name, Handle<Object> value, bool observe) { |
| 132 LookupIterator it(receiver, name, holder, |
| 133 LookupIterator::OWN_SKIP_INTERCEPTOR); |
| 134 // Skip any access checks we might hit. This accessor should never hit in a |
| 135 // situation where the caller does not have access. |
| 136 if (it.state() == LookupIterator::ACCESS_CHECK) { |
| 137 CHECK(it.HasAccess()); |
| 138 it.Next(); |
| 139 } |
| 140 CHECK_EQ(LookupIterator::ACCESSOR, it.state()); |
| 141 |
| 142 Handle<Object> old_value; |
| 143 bool is_observed = observe && receiver->map()->is_observed(); |
| 144 if (is_observed) { |
| 145 MaybeHandle<Object> maybe_old = |
| 146 Object::GetPropertyWithAccessor(&it, SLOPPY); |
| 147 if (!maybe_old.ToHandle(&old_value)) return maybe_old; |
| 148 } |
| 149 |
| 150 it.ReconfigureDataProperty(value, it.property_attributes()); |
| 151 |
| 152 if (is_observed && !old_value->SameValue(*value)) { |
| 153 return JSObject::EnqueueChangeRecord(receiver, "update", name, old_value); |
| 154 } |
| 155 |
| 156 return value; |
| 157 } |
| 158 |
| 159 void Accessors::ReconfigureToDataProperty( |
| 160 v8::Local<v8::Name> key, v8::Local<v8::Value> val, |
| 161 const v8::PropertyCallbackInfo<void>& info) { |
| 162 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 163 HandleScope scope(isolate); |
| 164 Handle<JSObject> receiver = |
| 165 Handle<JSObject>::cast(Utils::OpenHandle(*info.This())); |
| 166 Handle<JSObject> holder = |
| 167 Handle<JSObject>::cast(Utils::OpenHandle(*info.Holder())); |
| 168 Handle<Name> name = Utils::OpenHandle(*key); |
| 169 Handle<Object> value = Utils::OpenHandle(*val); |
| 170 MaybeHandle<Object> result = ReplaceAccessorWithDataProperty( |
| 171 isolate, receiver, holder, name, value, false); |
| 172 if (result.is_null()) isolate->OptionalRescheduleException(false); |
| 173 } |
| 128 | 174 |
| 129 // | 175 // |
| 130 // Accessors::ArgumentsIterator | 176 // Accessors::ArgumentsIterator |
| 131 // | 177 // |
| 132 | 178 |
| 133 | 179 |
| 134 void Accessors::ArgumentsIteratorGetter( | 180 void Accessors::ArgumentsIteratorGetter( |
| 135 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { | 181 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 136 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 182 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 137 DisallowHeapAllocation no_allocation; | 183 DisallowHeapAllocation no_allocation; |
| 138 HandleScope scope(isolate); | 184 HandleScope scope(isolate); |
| 139 Object* result = isolate->native_context()->array_values_iterator(); | 185 Object* result = isolate->native_context()->array_values_iterator(); |
| 140 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate))); | 186 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate))); |
| 141 } | 187 } |
| 142 | 188 |
| 143 | 189 |
| 144 void Accessors::ArgumentsIteratorSetter( | |
| 145 v8::Local<v8::Name> name, v8::Local<v8::Value> val, | |
| 146 const v8::PropertyCallbackInfo<void>& info) { | |
| 147 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | |
| 148 HandleScope scope(isolate); | |
| 149 Handle<JSObject> object_handle = | |
| 150 Handle<JSObject>::cast(Utils::OpenHandle(*info.This())); | |
| 151 Handle<Object> value_handle = Utils::OpenHandle(*val); | |
| 152 Handle<Name> name_handle = Utils::OpenHandle(*name); | |
| 153 | |
| 154 if (JSObject::DefinePropertyOrElementIgnoreAttributes( | |
| 155 object_handle, name_handle, value_handle, NONE) | |
| 156 .is_null()) { | |
| 157 isolate->OptionalRescheduleException(false); | |
| 158 } | |
| 159 } | |
| 160 | |
| 161 | |
| 162 Handle<AccessorInfo> Accessors::ArgumentsIteratorInfo( | 190 Handle<AccessorInfo> Accessors::ArgumentsIteratorInfo( |
| 163 Isolate* isolate, PropertyAttributes attributes) { | 191 Isolate* isolate, PropertyAttributes attributes) { |
| 164 Handle<Name> name = isolate->factory()->iterator_symbol(); | 192 Handle<Name> name = isolate->factory()->iterator_symbol(); |
| 165 return MakeAccessor(isolate, name, &ArgumentsIteratorGetter, | 193 return MakeAccessor(isolate, name, &ArgumentsIteratorGetter, nullptr, |
| 166 &ArgumentsIteratorSetter, attributes); | 194 attributes); |
| 167 } | 195 } |
| 168 | 196 |
| 169 | 197 |
| 170 // | 198 // |
| 171 // Accessors::ArrayLength | 199 // Accessors::ArrayLength |
| 172 // | 200 // |
| 173 | 201 |
| 174 | 202 |
| 175 void Accessors::ArrayLengthGetter( | 203 void Accessors::ArrayLengthGetter( |
| 176 v8::Local<v8::Name> name, | 204 v8::Local<v8::Name> name, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 if (!value->IsString()) { | 278 if (!value->IsString()) { |
| 251 // Not a string value. That means that we either got a String wrapper or | 279 // Not a string value. That means that we either got a String wrapper or |
| 252 // a Value with a String wrapper in its prototype chain. | 280 // a Value with a String wrapper in its prototype chain. |
| 253 value = JSValue::cast(*Utils::OpenHandle(*info.Holder()))->value(); | 281 value = JSValue::cast(*Utils::OpenHandle(*info.Holder()))->value(); |
| 254 } | 282 } |
| 255 Object* result = Smi::FromInt(String::cast(value)->length()); | 283 Object* result = Smi::FromInt(String::cast(value)->length()); |
| 256 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate))); | 284 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate))); |
| 257 } | 285 } |
| 258 | 286 |
| 259 | 287 |
| 260 void Accessors::StringLengthSetter( | |
| 261 v8::Local<v8::Name> name, | |
| 262 v8::Local<v8::Value> value, | |
| 263 const v8::PropertyCallbackInfo<void>& info) { | |
| 264 UNREACHABLE(); | |
| 265 } | |
| 266 | |
| 267 | |
| 268 Handle<AccessorInfo> Accessors::StringLengthInfo( | 288 Handle<AccessorInfo> Accessors::StringLengthInfo( |
| 269 Isolate* isolate, PropertyAttributes attributes) { | 289 Isolate* isolate, PropertyAttributes attributes) { |
| 270 return MakeAccessor(isolate, | 290 return MakeAccessor(isolate, isolate->factory()->length_string(), |
| 271 isolate->factory()->length_string(), | 291 &StringLengthGetter, nullptr, attributes); |
| 272 &StringLengthGetter, | |
| 273 &StringLengthSetter, | |
| 274 attributes); | |
| 275 } | 292 } |
| 276 | 293 |
| 277 | 294 |
| 278 // | 295 // |
| 279 // Accessors::ScriptColumnOffset | 296 // Accessors::ScriptColumnOffset |
| 280 // | 297 // |
| 281 | 298 |
| 282 | 299 |
| 283 void Accessors::ScriptColumnOffsetGetter( | 300 void Accessors::ScriptColumnOffsetGetter( |
| 284 v8::Local<v8::Name> name, | 301 v8::Local<v8::Name> name, |
| 285 const v8::PropertyCallbackInfo<v8::Value>& info) { | 302 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 286 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 303 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 287 DisallowHeapAllocation no_allocation; | 304 DisallowHeapAllocation no_allocation; |
| 288 HandleScope scope(isolate); | 305 HandleScope scope(isolate); |
| 289 Object* object = *Utils::OpenHandle(*info.This()); | 306 Object* object = *Utils::OpenHandle(*info.This()); |
| 290 Object* res = Smi::FromInt( | 307 Object* res = Smi::FromInt( |
| 291 Script::cast(JSValue::cast(object)->value())->column_offset()); | 308 Script::cast(JSValue::cast(object)->value())->column_offset()); |
| 292 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); | 309 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); |
| 293 } | 310 } |
| 294 | 311 |
| 295 | 312 |
| 296 void Accessors::ScriptColumnOffsetSetter( | |
| 297 v8::Local<v8::Name> name, | |
| 298 v8::Local<v8::Value> value, | |
| 299 const v8::PropertyCallbackInfo<void>& info) { | |
| 300 UNREACHABLE(); | |
| 301 } | |
| 302 | |
| 303 | |
| 304 Handle<AccessorInfo> Accessors::ScriptColumnOffsetInfo( | 313 Handle<AccessorInfo> Accessors::ScriptColumnOffsetInfo( |
| 305 Isolate* isolate, PropertyAttributes attributes) { | 314 Isolate* isolate, PropertyAttributes attributes) { |
| 306 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 315 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
| 307 STATIC_CHAR_VECTOR("column_offset"))); | 316 STATIC_CHAR_VECTOR("column_offset"))); |
| 308 return MakeAccessor(isolate, | 317 return MakeAccessor(isolate, name, &ScriptColumnOffsetGetter, nullptr, |
| 309 name, | |
| 310 &ScriptColumnOffsetGetter, | |
| 311 &ScriptColumnOffsetSetter, | |
| 312 attributes); | 318 attributes); |
| 313 } | 319 } |
| 314 | 320 |
| 315 | 321 |
| 316 // | 322 // |
| 317 // Accessors::ScriptId | 323 // Accessors::ScriptId |
| 318 // | 324 // |
| 319 | 325 |
| 320 | 326 |
| 321 void Accessors::ScriptIdGetter( | 327 void Accessors::ScriptIdGetter( |
| 322 v8::Local<v8::Name> name, | 328 v8::Local<v8::Name> name, |
| 323 const v8::PropertyCallbackInfo<v8::Value>& info) { | 329 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 324 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 330 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 325 DisallowHeapAllocation no_allocation; | 331 DisallowHeapAllocation no_allocation; |
| 326 HandleScope scope(isolate); | 332 HandleScope scope(isolate); |
| 327 Object* object = *Utils::OpenHandle(*info.This()); | 333 Object* object = *Utils::OpenHandle(*info.This()); |
| 328 Object* id = Smi::FromInt(Script::cast(JSValue::cast(object)->value())->id()); | 334 Object* id = Smi::FromInt(Script::cast(JSValue::cast(object)->value())->id()); |
| 329 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(id, isolate))); | 335 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(id, isolate))); |
| 330 } | 336 } |
| 331 | 337 |
| 332 | 338 |
| 333 void Accessors::ScriptIdSetter( | |
| 334 v8::Local<v8::Name> name, | |
| 335 v8::Local<v8::Value> value, | |
| 336 const v8::PropertyCallbackInfo<void>& info) { | |
| 337 UNREACHABLE(); | |
| 338 } | |
| 339 | |
| 340 | |
| 341 Handle<AccessorInfo> Accessors::ScriptIdInfo( | 339 Handle<AccessorInfo> Accessors::ScriptIdInfo( |
| 342 Isolate* isolate, PropertyAttributes attributes) { | 340 Isolate* isolate, PropertyAttributes attributes) { |
| 343 Handle<String> name( | 341 Handle<String> name( |
| 344 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("id"))); | 342 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("id"))); |
| 345 return MakeAccessor(isolate, | 343 return MakeAccessor(isolate, name, &ScriptIdGetter, nullptr, attributes); |
| 346 name, | |
| 347 &ScriptIdGetter, | |
| 348 &ScriptIdSetter, | |
| 349 attributes); | |
| 350 } | 344 } |
| 351 | 345 |
| 352 | 346 |
| 353 // | 347 // |
| 354 // Accessors::ScriptName | 348 // Accessors::ScriptName |
| 355 // | 349 // |
| 356 | 350 |
| 357 | 351 |
| 358 void Accessors::ScriptNameGetter( | 352 void Accessors::ScriptNameGetter( |
| 359 v8::Local<v8::Name> name, | 353 v8::Local<v8::Name> name, |
| 360 const v8::PropertyCallbackInfo<v8::Value>& info) { | 354 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 361 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 355 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 362 DisallowHeapAllocation no_allocation; | 356 DisallowHeapAllocation no_allocation; |
| 363 HandleScope scope(isolate); | 357 HandleScope scope(isolate); |
| 364 Object* object = *Utils::OpenHandle(*info.This()); | 358 Object* object = *Utils::OpenHandle(*info.This()); |
| 365 Object* source = Script::cast(JSValue::cast(object)->value())->name(); | 359 Object* source = Script::cast(JSValue::cast(object)->value())->name(); |
| 366 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(source, isolate))); | 360 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(source, isolate))); |
| 367 } | 361 } |
| 368 | 362 |
| 369 | 363 |
| 370 void Accessors::ScriptNameSetter( | |
| 371 v8::Local<v8::Name> name, | |
| 372 v8::Local<v8::Value> value, | |
| 373 const v8::PropertyCallbackInfo<void>& info) { | |
| 374 UNREACHABLE(); | |
| 375 } | |
| 376 | |
| 377 | |
| 378 Handle<AccessorInfo> Accessors::ScriptNameInfo( | 364 Handle<AccessorInfo> Accessors::ScriptNameInfo( |
| 379 Isolate* isolate, PropertyAttributes attributes) { | 365 Isolate* isolate, PropertyAttributes attributes) { |
| 380 return MakeAccessor(isolate, | 366 return MakeAccessor(isolate, isolate->factory()->name_string(), |
| 381 isolate->factory()->name_string(), | 367 &ScriptNameGetter, nullptr, attributes); |
| 382 &ScriptNameGetter, | |
| 383 &ScriptNameSetter, | |
| 384 attributes); | |
| 385 } | 368 } |
| 386 | 369 |
| 387 | 370 |
| 388 // | 371 // |
| 389 // Accessors::ScriptSource | 372 // Accessors::ScriptSource |
| 390 // | 373 // |
| 391 | 374 |
| 392 | 375 |
| 393 void Accessors::ScriptSourceGetter( | 376 void Accessors::ScriptSourceGetter( |
| 394 v8::Local<v8::Name> name, | 377 v8::Local<v8::Name> name, |
| 395 const v8::PropertyCallbackInfo<v8::Value>& info) { | 378 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 396 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 379 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 397 DisallowHeapAllocation no_allocation; | 380 DisallowHeapAllocation no_allocation; |
| 398 HandleScope scope(isolate); | 381 HandleScope scope(isolate); |
| 399 Object* object = *Utils::OpenHandle(*info.This()); | 382 Object* object = *Utils::OpenHandle(*info.This()); |
| 400 Object* source = Script::cast(JSValue::cast(object)->value())->source(); | 383 Object* source = Script::cast(JSValue::cast(object)->value())->source(); |
| 401 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(source, isolate))); | 384 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(source, isolate))); |
| 402 } | 385 } |
| 403 | 386 |
| 404 | 387 |
| 405 void Accessors::ScriptSourceSetter( | |
| 406 v8::Local<v8::Name> name, | |
| 407 v8::Local<v8::Value> value, | |
| 408 const v8::PropertyCallbackInfo<void>& info) { | |
| 409 UNREACHABLE(); | |
| 410 } | |
| 411 | |
| 412 | |
| 413 Handle<AccessorInfo> Accessors::ScriptSourceInfo( | 388 Handle<AccessorInfo> Accessors::ScriptSourceInfo( |
| 414 Isolate* isolate, PropertyAttributes attributes) { | 389 Isolate* isolate, PropertyAttributes attributes) { |
| 415 return MakeAccessor(isolate, | 390 return MakeAccessor(isolate, isolate->factory()->source_string(), |
| 416 isolate->factory()->source_string(), | 391 &ScriptSourceGetter, nullptr, attributes); |
| 417 &ScriptSourceGetter, | |
| 418 &ScriptSourceSetter, | |
| 419 attributes); | |
| 420 } | 392 } |
| 421 | 393 |
| 422 | 394 |
| 423 // | 395 // |
| 424 // Accessors::ScriptLineOffset | 396 // Accessors::ScriptLineOffset |
| 425 // | 397 // |
| 426 | 398 |
| 427 | 399 |
| 428 void Accessors::ScriptLineOffsetGetter( | 400 void Accessors::ScriptLineOffsetGetter( |
| 429 v8::Local<v8::Name> name, | 401 v8::Local<v8::Name> name, |
| 430 const v8::PropertyCallbackInfo<v8::Value>& info) { | 402 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 431 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 403 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 432 DisallowHeapAllocation no_allocation; | 404 DisallowHeapAllocation no_allocation; |
| 433 HandleScope scope(isolate); | 405 HandleScope scope(isolate); |
| 434 Object* object = *Utils::OpenHandle(*info.This()); | 406 Object* object = *Utils::OpenHandle(*info.This()); |
| 435 Object* res = | 407 Object* res = |
| 436 Smi::FromInt(Script::cast(JSValue::cast(object)->value())->line_offset()); | 408 Smi::FromInt(Script::cast(JSValue::cast(object)->value())->line_offset()); |
| 437 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); | 409 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); |
| 438 } | 410 } |
| 439 | 411 |
| 440 | 412 |
| 441 void Accessors::ScriptLineOffsetSetter( | |
| 442 v8::Local<v8::Name> name, | |
| 443 v8::Local<v8::Value> value, | |
| 444 const v8::PropertyCallbackInfo<void>& info) { | |
| 445 UNREACHABLE(); | |
| 446 } | |
| 447 | |
| 448 | |
| 449 Handle<AccessorInfo> Accessors::ScriptLineOffsetInfo( | 413 Handle<AccessorInfo> Accessors::ScriptLineOffsetInfo( |
| 450 Isolate* isolate, PropertyAttributes attributes) { | 414 Isolate* isolate, PropertyAttributes attributes) { |
| 451 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 415 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
| 452 STATIC_CHAR_VECTOR("line_offset"))); | 416 STATIC_CHAR_VECTOR("line_offset"))); |
| 453 return MakeAccessor(isolate, | 417 return MakeAccessor(isolate, name, &ScriptLineOffsetGetter, nullptr, |
| 454 name, | |
| 455 &ScriptLineOffsetGetter, | |
| 456 &ScriptLineOffsetSetter, | |
| 457 attributes); | 418 attributes); |
| 458 } | 419 } |
| 459 | 420 |
| 460 | 421 |
| 461 // | 422 // |
| 462 // Accessors::ScriptType | 423 // Accessors::ScriptType |
| 463 // | 424 // |
| 464 | 425 |
| 465 | 426 |
| 466 void Accessors::ScriptTypeGetter( | 427 void Accessors::ScriptTypeGetter( |
| 467 v8::Local<v8::Name> name, | 428 v8::Local<v8::Name> name, |
| 468 const v8::PropertyCallbackInfo<v8::Value>& info) { | 429 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 469 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 430 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 470 DisallowHeapAllocation no_allocation; | 431 DisallowHeapAllocation no_allocation; |
| 471 HandleScope scope(isolate); | 432 HandleScope scope(isolate); |
| 472 Object* object = *Utils::OpenHandle(*info.This()); | 433 Object* object = *Utils::OpenHandle(*info.This()); |
| 473 Object* res = | 434 Object* res = |
| 474 Smi::FromInt(Script::cast(JSValue::cast(object)->value())->type()); | 435 Smi::FromInt(Script::cast(JSValue::cast(object)->value())->type()); |
| 475 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); | 436 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); |
| 476 } | 437 } |
| 477 | 438 |
| 478 | 439 |
| 479 void Accessors::ScriptTypeSetter( | |
| 480 v8::Local<v8::Name> name, | |
| 481 v8::Local<v8::Value> value, | |
| 482 const v8::PropertyCallbackInfo<void>& info) { | |
| 483 UNREACHABLE(); | |
| 484 } | |
| 485 | |
| 486 | |
| 487 Handle<AccessorInfo> Accessors::ScriptTypeInfo( | 440 Handle<AccessorInfo> Accessors::ScriptTypeInfo( |
| 488 Isolate* isolate, PropertyAttributes attributes) { | 441 Isolate* isolate, PropertyAttributes attributes) { |
| 489 Handle<String> name( | 442 Handle<String> name( |
| 490 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("type"))); | 443 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("type"))); |
| 491 return MakeAccessor(isolate, | 444 return MakeAccessor(isolate, name, &ScriptTypeGetter, nullptr, attributes); |
| 492 name, | |
| 493 &ScriptTypeGetter, | |
| 494 &ScriptTypeSetter, | |
| 495 attributes); | |
| 496 } | 445 } |
| 497 | 446 |
| 498 | 447 |
| 499 // | 448 // |
| 500 // Accessors::ScriptCompilationType | 449 // Accessors::ScriptCompilationType |
| 501 // | 450 // |
| 502 | 451 |
| 503 | 452 |
| 504 void Accessors::ScriptCompilationTypeGetter( | 453 void Accessors::ScriptCompilationTypeGetter( |
| 505 v8::Local<v8::Name> name, | 454 v8::Local<v8::Name> name, |
| 506 const v8::PropertyCallbackInfo<v8::Value>& info) { | 455 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 507 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 456 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 508 DisallowHeapAllocation no_allocation; | 457 DisallowHeapAllocation no_allocation; |
| 509 HandleScope scope(isolate); | 458 HandleScope scope(isolate); |
| 510 Object* object = *Utils::OpenHandle(*info.This()); | 459 Object* object = *Utils::OpenHandle(*info.This()); |
| 511 Object* res = Smi::FromInt( | 460 Object* res = Smi::FromInt( |
| 512 Script::cast(JSValue::cast(object)->value())->compilation_type()); | 461 Script::cast(JSValue::cast(object)->value())->compilation_type()); |
| 513 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); | 462 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); |
| 514 } | 463 } |
| 515 | 464 |
| 516 | 465 |
| 517 void Accessors::ScriptCompilationTypeSetter( | |
| 518 v8::Local<v8::Name> name, | |
| 519 v8::Local<v8::Value> value, | |
| 520 const v8::PropertyCallbackInfo<void>& info) { | |
| 521 UNREACHABLE(); | |
| 522 } | |
| 523 | |
| 524 | |
| 525 Handle<AccessorInfo> Accessors::ScriptCompilationTypeInfo( | 466 Handle<AccessorInfo> Accessors::ScriptCompilationTypeInfo( |
| 526 Isolate* isolate, PropertyAttributes attributes) { | 467 Isolate* isolate, PropertyAttributes attributes) { |
| 527 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 468 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
| 528 STATIC_CHAR_VECTOR("compilation_type"))); | 469 STATIC_CHAR_VECTOR("compilation_type"))); |
| 529 return MakeAccessor(isolate, | 470 return MakeAccessor(isolate, name, &ScriptCompilationTypeGetter, nullptr, |
| 530 name, | |
| 531 &ScriptCompilationTypeGetter, | |
| 532 &ScriptCompilationTypeSetter, | |
| 533 attributes); | 471 attributes); |
| 534 } | 472 } |
| 535 | 473 |
| 536 | 474 |
| 537 // | 475 // |
| 538 // Accessors::ScriptGetLineEnds | 476 // Accessors::ScriptGetLineEnds |
| 539 // | 477 // |
| 540 | 478 |
| 541 | 479 |
| 542 void Accessors::ScriptLineEndsGetter( | 480 void Accessors::ScriptLineEndsGetter( |
| 543 v8::Local<v8::Name> name, | 481 v8::Local<v8::Name> name, |
| 544 const v8::PropertyCallbackInfo<v8::Value>& info) { | 482 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 545 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 483 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 546 HandleScope scope(isolate); | 484 HandleScope scope(isolate); |
| 547 Handle<Object> object = Utils::OpenHandle(*info.This()); | 485 Handle<Object> object = Utils::OpenHandle(*info.This()); |
| 548 Handle<Script> script( | 486 Handle<Script> script( |
| 549 Script::cast(Handle<JSValue>::cast(object)->value()), isolate); | 487 Script::cast(Handle<JSValue>::cast(object)->value()), isolate); |
| 550 Script::InitLineEnds(script); | 488 Script::InitLineEnds(script); |
| 551 DCHECK(script->line_ends()->IsFixedArray()); | 489 DCHECK(script->line_ends()->IsFixedArray()); |
| 552 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); | 490 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); |
| 553 // We do not want anyone to modify this array from JS. | 491 // We do not want anyone to modify this array from JS. |
| 554 DCHECK(*line_ends == isolate->heap()->empty_fixed_array() || | 492 DCHECK(*line_ends == isolate->heap()->empty_fixed_array() || |
| 555 line_ends->map() == isolate->heap()->fixed_cow_array_map()); | 493 line_ends->map() == isolate->heap()->fixed_cow_array_map()); |
| 556 Handle<JSArray> js_array = | 494 Handle<JSArray> js_array = |
| 557 isolate->factory()->NewJSArrayWithElements(line_ends); | 495 isolate->factory()->NewJSArrayWithElements(line_ends); |
| 558 info.GetReturnValue().Set(Utils::ToLocal(js_array)); | 496 info.GetReturnValue().Set(Utils::ToLocal(js_array)); |
| 559 } | 497 } |
| 560 | 498 |
| 561 | 499 |
| 562 void Accessors::ScriptLineEndsSetter( | |
| 563 v8::Local<v8::Name> name, | |
| 564 v8::Local<v8::Value> value, | |
| 565 const v8::PropertyCallbackInfo<void>& info) { | |
| 566 UNREACHABLE(); | |
| 567 } | |
| 568 | |
| 569 | |
| 570 Handle<AccessorInfo> Accessors::ScriptLineEndsInfo( | 500 Handle<AccessorInfo> Accessors::ScriptLineEndsInfo( |
| 571 Isolate* isolate, PropertyAttributes attributes) { | 501 Isolate* isolate, PropertyAttributes attributes) { |
| 572 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 502 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
| 573 STATIC_CHAR_VECTOR("line_ends"))); | 503 STATIC_CHAR_VECTOR("line_ends"))); |
| 574 return MakeAccessor(isolate, | 504 return MakeAccessor(isolate, name, &ScriptLineEndsGetter, nullptr, |
| 575 name, | |
| 576 &ScriptLineEndsGetter, | |
| 577 &ScriptLineEndsSetter, | |
| 578 attributes); | 505 attributes); |
| 579 } | 506 } |
| 580 | 507 |
| 581 | 508 |
| 582 // | 509 // |
| 583 // Accessors::ScriptSourceUrl | 510 // Accessors::ScriptSourceUrl |
| 584 // | 511 // |
| 585 | 512 |
| 586 | 513 |
| 587 void Accessors::ScriptSourceUrlGetter( | 514 void Accessors::ScriptSourceUrlGetter( |
| 588 v8::Local<v8::Name> name, | 515 v8::Local<v8::Name> name, |
| 589 const v8::PropertyCallbackInfo<v8::Value>& info) { | 516 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 590 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 517 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 591 DisallowHeapAllocation no_allocation; | 518 DisallowHeapAllocation no_allocation; |
| 592 HandleScope scope(isolate); | 519 HandleScope scope(isolate); |
| 593 Object* object = *Utils::OpenHandle(*info.This()); | 520 Object* object = *Utils::OpenHandle(*info.This()); |
| 594 Object* url = Script::cast(JSValue::cast(object)->value())->source_url(); | 521 Object* url = Script::cast(JSValue::cast(object)->value())->source_url(); |
| 595 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(url, isolate))); | 522 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(url, isolate))); |
| 596 } | 523 } |
| 597 | 524 |
| 598 | 525 |
| 599 void Accessors::ScriptSourceUrlSetter( | |
| 600 v8::Local<v8::Name> name, | |
| 601 v8::Local<v8::Value> value, | |
| 602 const v8::PropertyCallbackInfo<void>& info) { | |
| 603 UNREACHABLE(); | |
| 604 } | |
| 605 | |
| 606 | |
| 607 Handle<AccessorInfo> Accessors::ScriptSourceUrlInfo( | 526 Handle<AccessorInfo> Accessors::ScriptSourceUrlInfo( |
| 608 Isolate* isolate, PropertyAttributes attributes) { | 527 Isolate* isolate, PropertyAttributes attributes) { |
| 609 return MakeAccessor(isolate, | 528 return MakeAccessor(isolate, isolate->factory()->source_url_string(), |
| 610 isolate->factory()->source_url_string(), | 529 &ScriptSourceUrlGetter, nullptr, attributes); |
| 611 &ScriptSourceUrlGetter, | |
| 612 &ScriptSourceUrlSetter, | |
| 613 attributes); | |
| 614 } | 530 } |
| 615 | 531 |
| 616 | 532 |
| 617 // | 533 // |
| 618 // Accessors::ScriptSourceMappingUrl | 534 // Accessors::ScriptSourceMappingUrl |
| 619 // | 535 // |
| 620 | 536 |
| 621 | 537 |
| 622 void Accessors::ScriptSourceMappingUrlGetter( | 538 void Accessors::ScriptSourceMappingUrlGetter( |
| 623 v8::Local<v8::Name> name, | 539 v8::Local<v8::Name> name, |
| 624 const v8::PropertyCallbackInfo<v8::Value>& info) { | 540 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 625 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 541 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 626 DisallowHeapAllocation no_allocation; | 542 DisallowHeapAllocation no_allocation; |
| 627 HandleScope scope(isolate); | 543 HandleScope scope(isolate); |
| 628 Object* object = *Utils::OpenHandle(*info.This()); | 544 Object* object = *Utils::OpenHandle(*info.This()); |
| 629 Object* url = | 545 Object* url = |
| 630 Script::cast(JSValue::cast(object)->value())->source_mapping_url(); | 546 Script::cast(JSValue::cast(object)->value())->source_mapping_url(); |
| 631 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(url, isolate))); | 547 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(url, isolate))); |
| 632 } | 548 } |
| 633 | 549 |
| 634 | 550 |
| 635 void Accessors::ScriptSourceMappingUrlSetter( | |
| 636 v8::Local<v8::Name> name, | |
| 637 v8::Local<v8::Value> value, | |
| 638 const v8::PropertyCallbackInfo<void>& info) { | |
| 639 UNREACHABLE(); | |
| 640 } | |
| 641 | |
| 642 | |
| 643 Handle<AccessorInfo> Accessors::ScriptSourceMappingUrlInfo( | 551 Handle<AccessorInfo> Accessors::ScriptSourceMappingUrlInfo( |
| 644 Isolate* isolate, PropertyAttributes attributes) { | 552 Isolate* isolate, PropertyAttributes attributes) { |
| 645 return MakeAccessor(isolate, | 553 return MakeAccessor(isolate, isolate->factory()->source_mapping_url_string(), |
| 646 isolate->factory()->source_mapping_url_string(), | 554 &ScriptSourceMappingUrlGetter, nullptr, attributes); |
| 647 &ScriptSourceMappingUrlGetter, | |
| 648 &ScriptSourceMappingUrlSetter, | |
| 649 attributes); | |
| 650 } | 555 } |
| 651 | 556 |
| 652 | 557 |
| 653 // | 558 // |
| 654 // Accessors::ScriptIsEmbedderDebugScript | 559 // Accessors::ScriptIsEmbedderDebugScript |
| 655 // | 560 // |
| 656 | 561 |
| 657 | 562 |
| 658 void Accessors::ScriptIsEmbedderDebugScriptGetter( | 563 void Accessors::ScriptIsEmbedderDebugScriptGetter( |
| 659 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { | 564 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 660 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 565 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 661 DisallowHeapAllocation no_allocation; | 566 DisallowHeapAllocation no_allocation; |
| 662 HandleScope scope(isolate); | 567 HandleScope scope(isolate); |
| 663 Object* object = *Utils::OpenHandle(*info.This()); | 568 Object* object = *Utils::OpenHandle(*info.This()); |
| 664 bool is_embedder_debug_script = Script::cast(JSValue::cast(object)->value()) | 569 bool is_embedder_debug_script = Script::cast(JSValue::cast(object)->value()) |
| 665 ->origin_options() | 570 ->origin_options() |
| 666 .IsEmbedderDebugScript(); | 571 .IsEmbedderDebugScript(); |
| 667 Object* res = *isolate->factory()->ToBoolean(is_embedder_debug_script); | 572 Object* res = *isolate->factory()->ToBoolean(is_embedder_debug_script); |
| 668 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); | 573 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); |
| 669 } | 574 } |
| 670 | 575 |
| 671 | 576 |
| 672 void Accessors::ScriptIsEmbedderDebugScriptSetter( | |
| 673 v8::Local<v8::Name> name, v8::Local<v8::Value> value, | |
| 674 const v8::PropertyCallbackInfo<void>& info) { | |
| 675 UNREACHABLE(); | |
| 676 } | |
| 677 | |
| 678 | |
| 679 Handle<AccessorInfo> Accessors::ScriptIsEmbedderDebugScriptInfo( | 577 Handle<AccessorInfo> Accessors::ScriptIsEmbedderDebugScriptInfo( |
| 680 Isolate* isolate, PropertyAttributes attributes) { | 578 Isolate* isolate, PropertyAttributes attributes) { |
| 681 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 579 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
| 682 STATIC_CHAR_VECTOR("is_debugger_script"))); | 580 STATIC_CHAR_VECTOR("is_debugger_script"))); |
| 683 return MakeAccessor(isolate, name, &ScriptIsEmbedderDebugScriptGetter, | 581 return MakeAccessor(isolate, name, &ScriptIsEmbedderDebugScriptGetter, |
| 684 &ScriptIsEmbedderDebugScriptSetter, attributes); | 582 nullptr, attributes); |
| 685 } | 583 } |
| 686 | 584 |
| 687 | 585 |
| 688 // | 586 // |
| 689 // Accessors::ScriptGetContextData | 587 // Accessors::ScriptGetContextData |
| 690 // | 588 // |
| 691 | 589 |
| 692 | 590 |
| 693 void Accessors::ScriptContextDataGetter( | 591 void Accessors::ScriptContextDataGetter( |
| 694 v8::Local<v8::Name> name, | 592 v8::Local<v8::Name> name, |
| 695 const v8::PropertyCallbackInfo<v8::Value>& info) { | 593 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 696 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 594 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 697 DisallowHeapAllocation no_allocation; | 595 DisallowHeapAllocation no_allocation; |
| 698 HandleScope scope(isolate); | 596 HandleScope scope(isolate); |
| 699 Object* object = *Utils::OpenHandle(*info.This()); | 597 Object* object = *Utils::OpenHandle(*info.This()); |
| 700 Object* res = Script::cast(JSValue::cast(object)->value())->context_data(); | 598 Object* res = Script::cast(JSValue::cast(object)->value())->context_data(); |
| 701 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); | 599 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); |
| 702 } | 600 } |
| 703 | 601 |
| 704 | 602 |
| 705 void Accessors::ScriptContextDataSetter( | |
| 706 v8::Local<v8::Name> name, | |
| 707 v8::Local<v8::Value> value, | |
| 708 const v8::PropertyCallbackInfo<void>& info) { | |
| 709 UNREACHABLE(); | |
| 710 } | |
| 711 | |
| 712 | |
| 713 Handle<AccessorInfo> Accessors::ScriptContextDataInfo( | 603 Handle<AccessorInfo> Accessors::ScriptContextDataInfo( |
| 714 Isolate* isolate, PropertyAttributes attributes) { | 604 Isolate* isolate, PropertyAttributes attributes) { |
| 715 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 605 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
| 716 STATIC_CHAR_VECTOR("context_data"))); | 606 STATIC_CHAR_VECTOR("context_data"))); |
| 717 return MakeAccessor(isolate, | 607 return MakeAccessor(isolate, name, &ScriptContextDataGetter, nullptr, |
| 718 name, | |
| 719 &ScriptContextDataGetter, | |
| 720 &ScriptContextDataSetter, | |
| 721 attributes); | 608 attributes); |
| 722 } | 609 } |
| 723 | 610 |
| 724 | 611 |
| 725 // | 612 // |
| 726 // Accessors::ScriptGetEvalFromScript | 613 // Accessors::ScriptGetEvalFromScript |
| 727 // | 614 // |
| 728 | 615 |
| 729 | 616 |
| 730 void Accessors::ScriptEvalFromScriptGetter( | 617 void Accessors::ScriptEvalFromScriptGetter( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 742 if (eval_from_shared->script()->IsScript()) { | 629 if (eval_from_shared->script()->IsScript()) { |
| 743 Handle<Script> eval_from_script(Script::cast(eval_from_shared->script())); | 630 Handle<Script> eval_from_script(Script::cast(eval_from_shared->script())); |
| 744 result = Script::GetWrapper(eval_from_script); | 631 result = Script::GetWrapper(eval_from_script); |
| 745 } | 632 } |
| 746 } | 633 } |
| 747 | 634 |
| 748 info.GetReturnValue().Set(Utils::ToLocal(result)); | 635 info.GetReturnValue().Set(Utils::ToLocal(result)); |
| 749 } | 636 } |
| 750 | 637 |
| 751 | 638 |
| 752 void Accessors::ScriptEvalFromScriptSetter( | |
| 753 v8::Local<v8::Name> name, | |
| 754 v8::Local<v8::Value> value, | |
| 755 const v8::PropertyCallbackInfo<void>& info) { | |
| 756 UNREACHABLE(); | |
| 757 } | |
| 758 | |
| 759 | |
| 760 Handle<AccessorInfo> Accessors::ScriptEvalFromScriptInfo( | 639 Handle<AccessorInfo> Accessors::ScriptEvalFromScriptInfo( |
| 761 Isolate* isolate, PropertyAttributes attributes) { | 640 Isolate* isolate, PropertyAttributes attributes) { |
| 762 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 641 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
| 763 STATIC_CHAR_VECTOR("eval_from_script"))); | 642 STATIC_CHAR_VECTOR("eval_from_script"))); |
| 764 return MakeAccessor(isolate, | 643 return MakeAccessor(isolate, name, &ScriptEvalFromScriptGetter, nullptr, |
| 765 name, | |
| 766 &ScriptEvalFromScriptGetter, | |
| 767 &ScriptEvalFromScriptSetter, | |
| 768 attributes); | 644 attributes); |
| 769 } | 645 } |
| 770 | 646 |
| 771 | 647 |
| 772 // | 648 // |
| 773 // Accessors::ScriptGetEvalFromScriptPosition | 649 // Accessors::ScriptGetEvalFromScriptPosition |
| 774 // | 650 // |
| 775 | 651 |
| 776 | 652 |
| 777 void Accessors::ScriptEvalFromScriptPositionGetter( | 653 void Accessors::ScriptEvalFromScriptPositionGetter( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 788 script->eval_from_shared())->code()); | 664 script->eval_from_shared())->code()); |
| 789 result = Handle<Object>(Smi::FromInt(code->SourcePosition( | 665 result = Handle<Object>(Smi::FromInt(code->SourcePosition( |
| 790 code->instruction_start() + | 666 code->instruction_start() + |
| 791 script->eval_from_instructions_offset())), | 667 script->eval_from_instructions_offset())), |
| 792 isolate); | 668 isolate); |
| 793 } | 669 } |
| 794 info.GetReturnValue().Set(Utils::ToLocal(result)); | 670 info.GetReturnValue().Set(Utils::ToLocal(result)); |
| 795 } | 671 } |
| 796 | 672 |
| 797 | 673 |
| 798 void Accessors::ScriptEvalFromScriptPositionSetter( | |
| 799 v8::Local<v8::Name> name, | |
| 800 v8::Local<v8::Value> value, | |
| 801 const v8::PropertyCallbackInfo<void>& info) { | |
| 802 UNREACHABLE(); | |
| 803 } | |
| 804 | |
| 805 | |
| 806 Handle<AccessorInfo> Accessors::ScriptEvalFromScriptPositionInfo( | 674 Handle<AccessorInfo> Accessors::ScriptEvalFromScriptPositionInfo( |
| 807 Isolate* isolate, PropertyAttributes attributes) { | 675 Isolate* isolate, PropertyAttributes attributes) { |
| 808 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 676 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
| 809 STATIC_CHAR_VECTOR("eval_from_script_position"))); | 677 STATIC_CHAR_VECTOR("eval_from_script_position"))); |
| 810 return MakeAccessor(isolate, | 678 return MakeAccessor(isolate, name, &ScriptEvalFromScriptPositionGetter, |
| 811 name, | 679 nullptr, attributes); |
| 812 &ScriptEvalFromScriptPositionGetter, | |
| 813 &ScriptEvalFromScriptPositionSetter, | |
| 814 attributes); | |
| 815 } | 680 } |
| 816 | 681 |
| 817 | 682 |
| 818 // | 683 // |
| 819 // Accessors::ScriptGetEvalFromFunctionName | 684 // Accessors::ScriptGetEvalFromFunctionName |
| 820 // | 685 // |
| 821 | 686 |
| 822 | 687 |
| 823 void Accessors::ScriptEvalFromFunctionNameGetter( | 688 void Accessors::ScriptEvalFromFunctionNameGetter( |
| 824 v8::Local<v8::Name> name, | 689 v8::Local<v8::Name> name, |
| 825 const v8::PropertyCallbackInfo<v8::Value>& info) { | 690 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 826 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 691 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 827 HandleScope scope(isolate); | 692 HandleScope scope(isolate); |
| 828 Handle<Object> object = Utils::OpenHandle(*info.This()); | 693 Handle<Object> object = Utils::OpenHandle(*info.This()); |
| 829 Handle<Script> script( | 694 Handle<Script> script( |
| 830 Script::cast(Handle<JSValue>::cast(object)->value()), isolate); | 695 Script::cast(Handle<JSValue>::cast(object)->value()), isolate); |
| 831 Handle<Object> result; | 696 Handle<Object> result; |
| 832 Handle<SharedFunctionInfo> shared( | 697 Handle<SharedFunctionInfo> shared( |
| 833 SharedFunctionInfo::cast(script->eval_from_shared())); | 698 SharedFunctionInfo::cast(script->eval_from_shared())); |
| 834 // Find the name of the function calling eval. | 699 // Find the name of the function calling eval. |
| 835 if (!shared->name()->IsUndefined()) { | 700 if (!shared->name()->IsUndefined()) { |
| 836 result = Handle<Object>(shared->name(), isolate); | 701 result = Handle<Object>(shared->name(), isolate); |
| 837 } else { | 702 } else { |
| 838 result = Handle<Object>(shared->inferred_name(), isolate); | 703 result = Handle<Object>(shared->inferred_name(), isolate); |
| 839 } | 704 } |
| 840 info.GetReturnValue().Set(Utils::ToLocal(result)); | 705 info.GetReturnValue().Set(Utils::ToLocal(result)); |
| 841 } | 706 } |
| 842 | 707 |
| 843 | 708 |
| 844 void Accessors::ScriptEvalFromFunctionNameSetter( | |
| 845 v8::Local<v8::Name> name, | |
| 846 v8::Local<v8::Value> value, | |
| 847 const v8::PropertyCallbackInfo<void>& info) { | |
| 848 UNREACHABLE(); | |
| 849 } | |
| 850 | |
| 851 | |
| 852 Handle<AccessorInfo> Accessors::ScriptEvalFromFunctionNameInfo( | 709 Handle<AccessorInfo> Accessors::ScriptEvalFromFunctionNameInfo( |
| 853 Isolate* isolate, PropertyAttributes attributes) { | 710 Isolate* isolate, PropertyAttributes attributes) { |
| 854 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 711 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
| 855 STATIC_CHAR_VECTOR("eval_from_function_name"))); | 712 STATIC_CHAR_VECTOR("eval_from_function_name"))); |
| 856 return MakeAccessor(isolate, | 713 return MakeAccessor(isolate, name, &ScriptEvalFromFunctionNameGetter, nullptr, |
| 857 name, | |
| 858 &ScriptEvalFromFunctionNameGetter, | |
| 859 &ScriptEvalFromFunctionNameSetter, | |
| 860 attributes); | 714 attributes); |
| 861 } | 715 } |
| 862 | 716 |
| 863 | 717 |
| 864 // | 718 // |
| 865 // Accessors::FunctionPrototype | 719 // Accessors::FunctionPrototype |
| 866 // | 720 // |
| 867 | 721 |
| 868 static Handle<Object> GetFunctionPrototype(Isolate* isolate, | 722 static Handle<Object> GetFunctionPrototype(Isolate* isolate, |
| 869 Handle<JSFunction> function) { | 723 Handle<JSFunction> function) { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 length = function->shared()->length(); | 821 length = function->shared()->length(); |
| 968 } | 822 } |
| 969 if (isolate->has_pending_exception()) { | 823 if (isolate->has_pending_exception()) { |
| 970 isolate->OptionalRescheduleException(false); | 824 isolate->OptionalRescheduleException(false); |
| 971 } | 825 } |
| 972 } | 826 } |
| 973 Handle<Object> result(Smi::FromInt(length), isolate); | 827 Handle<Object> result(Smi::FromInt(length), isolate); |
| 974 info.GetReturnValue().Set(Utils::ToLocal(result)); | 828 info.GetReturnValue().Set(Utils::ToLocal(result)); |
| 975 } | 829 } |
| 976 | 830 |
| 977 | 831 void Accessors::ObservedReconfigureToDataProperty( |
| 978 MUST_USE_RESULT static MaybeHandle<Object> ReplaceAccessorWithDataProperty( | 832 v8::Local<v8::Name> key, v8::Local<v8::Value> val, |
| 979 Isolate* isolate, Handle<JSObject> object, Handle<Name> name, | |
| 980 Handle<Object> value, bool is_observed, Handle<Object> old_value) { | |
| 981 LookupIterator it(object, name); | |
| 982 CHECK_EQ(LookupIterator::ACCESSOR, it.state()); | |
| 983 DCHECK(it.HolderIsReceiverOrHiddenPrototype()); | |
| 984 it.ReconfigureDataProperty(value, it.property_details().attributes()); | |
| 985 | |
| 986 if (is_observed && !old_value->SameValue(*value)) { | |
| 987 return JSObject::EnqueueChangeRecord(object, "update", name, old_value); | |
| 988 } | |
| 989 | |
| 990 return value; | |
| 991 } | |
| 992 | |
| 993 | |
| 994 MUST_USE_RESULT static MaybeHandle<Object> SetFunctionLength( | |
| 995 Isolate* isolate, Handle<JSFunction> function, Handle<Object> value) { | |
| 996 Handle<Object> old_value; | |
| 997 bool is_observed = function->map()->is_observed(); | |
| 998 if (is_observed) { | |
| 999 old_value = handle(Smi::FromInt(function->shared()->length()), isolate); | |
| 1000 } | |
| 1001 | |
| 1002 return ReplaceAccessorWithDataProperty(isolate, function, | |
| 1003 isolate->factory()->length_string(), | |
| 1004 value, is_observed, old_value); | |
| 1005 } | |
| 1006 | |
| 1007 | |
| 1008 void Accessors::FunctionLengthSetter( | |
| 1009 v8::Local<v8::Name> name, | |
| 1010 v8::Local<v8::Value> val, | |
| 1011 const v8::PropertyCallbackInfo<void>& info) { | 833 const v8::PropertyCallbackInfo<void>& info) { |
| 1012 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 834 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 1013 HandleScope scope(isolate); | 835 HandleScope scope(isolate); |
| 836 Handle<JSObject> receiver = |
| 837 Handle<JSObject>::cast(Utils::OpenHandle(*info.This())); |
| 838 Handle<JSObject> holder = |
| 839 Handle<JSObject>::cast(Utils::OpenHandle(*info.Holder())); |
| 840 Handle<Name> name = Utils::OpenHandle(*key); |
| 1014 Handle<Object> value = Utils::OpenHandle(*val); | 841 Handle<Object> value = Utils::OpenHandle(*val); |
| 1015 | 842 MaybeHandle<Object> result = ReplaceAccessorWithDataProperty( |
| 1016 Handle<JSFunction> object = | 843 isolate, receiver, holder, name, value, true); |
| 1017 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); | 844 if (result.is_null()) isolate->OptionalRescheduleException(false); |
| 1018 if (SetFunctionLength(isolate, object, value).is_null()) { | |
| 1019 isolate->OptionalRescheduleException(false); | |
| 1020 } | |
| 1021 } | 845 } |
| 1022 | 846 |
| 1023 | 847 |
| 1024 Handle<AccessorInfo> Accessors::FunctionLengthInfo( | 848 Handle<AccessorInfo> Accessors::FunctionLengthInfo( |
| 1025 Isolate* isolate, PropertyAttributes attributes) { | 849 Isolate* isolate, PropertyAttributes attributes) { |
| 1026 return MakeAccessor(isolate, | 850 return MakeAccessor(isolate, isolate->factory()->length_string(), |
| 1027 isolate->factory()->length_string(), | 851 &FunctionLengthGetter, &ObservedReconfigureToDataProperty, |
| 1028 &FunctionLengthGetter, | |
| 1029 &FunctionLengthSetter, | |
| 1030 attributes); | 852 attributes); |
| 1031 } | 853 } |
| 1032 | 854 |
| 1033 | 855 |
| 1034 // | 856 // |
| 1035 // Accessors::FunctionName | 857 // Accessors::FunctionName |
| 1036 // | 858 // |
| 1037 | 859 |
| 1038 | 860 |
| 1039 void Accessors::FunctionNameGetter( | 861 void Accessors::FunctionNameGetter( |
| 1040 v8::Local<v8::Name> name, | 862 v8::Local<v8::Name> name, |
| 1041 const v8::PropertyCallbackInfo<v8::Value>& info) { | 863 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1042 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 864 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 1043 HandleScope scope(isolate); | 865 HandleScope scope(isolate); |
| 1044 Handle<JSFunction> function = | 866 Handle<JSFunction> function = |
| 1045 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); | 867 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); |
| 1046 Handle<Object> result; | 868 Handle<Object> result; |
| 1047 if (function->shared()->name_should_print_as_anonymous()) { | 869 if (function->shared()->name_should_print_as_anonymous()) { |
| 1048 result = isolate->factory()->anonymous_string(); | 870 result = isolate->factory()->anonymous_string(); |
| 1049 } else { | 871 } else { |
| 1050 result = handle(function->shared()->name(), isolate); | 872 result = handle(function->shared()->name(), isolate); |
| 1051 } | 873 } |
| 1052 info.GetReturnValue().Set(Utils::ToLocal(result)); | 874 info.GetReturnValue().Set(Utils::ToLocal(result)); |
| 1053 } | 875 } |
| 1054 | 876 |
| 1055 | |
| 1056 MUST_USE_RESULT static MaybeHandle<Object> SetFunctionName( | |
| 1057 Isolate* isolate, Handle<JSFunction> function, Handle<Object> value) { | |
| 1058 Handle<Object> old_value; | |
| 1059 bool is_observed = function->map()->is_observed(); | |
| 1060 if (is_observed) { | |
| 1061 old_value = handle(function->shared()->name(), isolate); | |
| 1062 } | |
| 1063 | |
| 1064 return ReplaceAccessorWithDataProperty(isolate, function, | |
| 1065 isolate->factory()->name_string(), | |
| 1066 value, is_observed, old_value); | |
| 1067 } | |
| 1068 | |
| 1069 | |
| 1070 void Accessors::FunctionNameSetter( | |
| 1071 v8::Local<v8::Name> name, | |
| 1072 v8::Local<v8::Value> val, | |
| 1073 const v8::PropertyCallbackInfo<void>& info) { | |
| 1074 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | |
| 1075 HandleScope scope(isolate); | |
| 1076 Handle<Object> value = Utils::OpenHandle(*val); | |
| 1077 | |
| 1078 Handle<JSFunction> object = | |
| 1079 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); | |
| 1080 if (SetFunctionName(isolate, object, value).is_null()) { | |
| 1081 isolate->OptionalRescheduleException(false); | |
| 1082 } | |
| 1083 } | |
| 1084 | |
| 1085 | |
| 1086 Handle<AccessorInfo> Accessors::FunctionNameInfo( | 877 Handle<AccessorInfo> Accessors::FunctionNameInfo( |
| 1087 Isolate* isolate, PropertyAttributes attributes) { | 878 Isolate* isolate, PropertyAttributes attributes) { |
| 1088 return MakeAccessor(isolate, | 879 return MakeAccessor(isolate, isolate->factory()->name_string(), |
| 1089 isolate->factory()->name_string(), | 880 &FunctionNameGetter, &ObservedReconfigureToDataProperty, |
| 1090 &FunctionNameGetter, | |
| 1091 &FunctionNameSetter, | |
| 1092 attributes); | 881 attributes); |
| 1093 } | 882 } |
| 1094 | 883 |
| 1095 | 884 |
| 1096 // | 885 // |
| 1097 // Accessors::FunctionArguments | 886 // Accessors::FunctionArguments |
| 1098 // | 887 // |
| 1099 | 888 |
| 1100 | 889 |
| 1101 static Handle<Object> ArgumentsForInlinedFunction( | 890 static Handle<Object> ArgumentsForInlinedFunction( |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1209 const v8::PropertyCallbackInfo<v8::Value>& info) { | 998 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1210 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 999 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 1211 HandleScope scope(isolate); | 1000 HandleScope scope(isolate); |
| 1212 Handle<JSFunction> function = | 1001 Handle<JSFunction> function = |
| 1213 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); | 1002 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); |
| 1214 Handle<Object> result = GetFunctionArguments(isolate, function); | 1003 Handle<Object> result = GetFunctionArguments(isolate, function); |
| 1215 info.GetReturnValue().Set(Utils::ToLocal(result)); | 1004 info.GetReturnValue().Set(Utils::ToLocal(result)); |
| 1216 } | 1005 } |
| 1217 | 1006 |
| 1218 | 1007 |
| 1219 void Accessors::FunctionArgumentsSetter( | |
| 1220 v8::Local<v8::Name> name, | |
| 1221 v8::Local<v8::Value> val, | |
| 1222 const v8::PropertyCallbackInfo<void>& info) { | |
| 1223 // Function arguments is non writable, non configurable. | |
| 1224 UNREACHABLE(); | |
| 1225 } | |
| 1226 | |
| 1227 | |
| 1228 Handle<AccessorInfo> Accessors::FunctionArgumentsInfo( | 1008 Handle<AccessorInfo> Accessors::FunctionArgumentsInfo( |
| 1229 Isolate* isolate, PropertyAttributes attributes) { | 1009 Isolate* isolate, PropertyAttributes attributes) { |
| 1230 return MakeAccessor(isolate, | 1010 return MakeAccessor(isolate, isolate->factory()->arguments_string(), |
| 1231 isolate->factory()->arguments_string(), | 1011 &FunctionArgumentsGetter, nullptr, attributes); |
| 1232 &FunctionArgumentsGetter, | |
| 1233 &FunctionArgumentsSetter, | |
| 1234 attributes); | |
| 1235 } | 1012 } |
| 1236 | 1013 |
| 1237 | 1014 |
| 1238 // | 1015 // |
| 1239 // Accessors::FunctionCaller | 1016 // Accessors::FunctionCaller |
| 1240 // | 1017 // |
| 1241 | 1018 |
| 1242 | 1019 |
| 1243 static inline bool AllowAccessToFunction(Context* current_context, | 1020 static inline bool AllowAccessToFunction(Context* current_context, |
| 1244 JSFunction* function) { | 1021 JSFunction* function) { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1354 Handle<JSFunction> caller; | 1131 Handle<JSFunction> caller; |
| 1355 if (maybe_caller.ToHandle(&caller)) { | 1132 if (maybe_caller.ToHandle(&caller)) { |
| 1356 result = caller; | 1133 result = caller; |
| 1357 } else { | 1134 } else { |
| 1358 result = isolate->factory()->null_value(); | 1135 result = isolate->factory()->null_value(); |
| 1359 } | 1136 } |
| 1360 info.GetReturnValue().Set(Utils::ToLocal(result)); | 1137 info.GetReturnValue().Set(Utils::ToLocal(result)); |
| 1361 } | 1138 } |
| 1362 | 1139 |
| 1363 | 1140 |
| 1364 void Accessors::FunctionCallerSetter( | |
| 1365 v8::Local<v8::Name> name, | |
| 1366 v8::Local<v8::Value> val, | |
| 1367 const v8::PropertyCallbackInfo<void>& info) { | |
| 1368 // Function caller is non writable, non configurable. | |
| 1369 UNREACHABLE(); | |
| 1370 } | |
| 1371 | |
| 1372 | |
| 1373 Handle<AccessorInfo> Accessors::FunctionCallerInfo( | 1141 Handle<AccessorInfo> Accessors::FunctionCallerInfo( |
| 1374 Isolate* isolate, PropertyAttributes attributes) { | 1142 Isolate* isolate, PropertyAttributes attributes) { |
| 1375 return MakeAccessor(isolate, | 1143 return MakeAccessor(isolate, isolate->factory()->caller_string(), |
| 1376 isolate->factory()->caller_string(), | 1144 &FunctionCallerGetter, nullptr, attributes); |
| 1377 &FunctionCallerGetter, | |
| 1378 &FunctionCallerSetter, | |
| 1379 attributes); | |
| 1380 } | 1145 } |
| 1381 | 1146 |
| 1382 | 1147 |
| 1383 // | 1148 // |
| 1384 // Accessors::MakeModuleExport | 1149 // Accessors::MakeModuleExport |
| 1385 // | 1150 // |
| 1386 | 1151 |
| 1387 static void ModuleGetExport(v8::Local<v8::Name> property, | 1152 static void ModuleGetExport(v8::Local<v8::Name> property, |
| 1388 const v8::PropertyCallbackInfo<v8::Value>& info) { | 1153 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1389 JSModule* instance = JSModule::cast(*v8::Utils::OpenHandle(*info.Holder())); | 1154 JSModule* instance = JSModule::cast(*v8::Utils::OpenHandle(*info.Holder())); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1433 Isolate* isolate = name->GetIsolate(); | 1198 Isolate* isolate = name->GetIsolate(); |
| 1434 Handle<AccessorInfo> info = MakeAccessor(isolate, name, &ModuleGetExport, | 1199 Handle<AccessorInfo> info = MakeAccessor(isolate, name, &ModuleGetExport, |
| 1435 &ModuleSetExport, attributes); | 1200 &ModuleSetExport, attributes); |
| 1436 info->set_data(Smi::FromInt(index)); | 1201 info->set_data(Smi::FromInt(index)); |
| 1437 return info; | 1202 return info; |
| 1438 } | 1203 } |
| 1439 | 1204 |
| 1440 | 1205 |
| 1441 } // namespace internal | 1206 } // namespace internal |
| 1442 } // namespace v8 | 1207 } // namespace v8 |
| OLD | NEW |