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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/contexts.h" | 10 #include "src/contexts.h" |
11 #include "src/deoptimizer.h" | 11 #include "src/deoptimizer.h" |
12 #include "src/execution.h" | 12 #include "src/execution.h" |
13 #include "src/factory.h" | 13 #include "src/factory.h" |
14 #include "src/frames-inl.h" | 14 #include "src/frames-inl.h" |
15 #include "src/isolate.h" | 15 #include "src/isolate.h" |
16 #include "src/list-inl.h" | 16 #include "src/list-inl.h" |
17 #include "src/property-details.h" | 17 #include "src/property-details.h" |
18 #include "src/prototype.h" | 18 #include "src/prototype.h" |
19 | 19 |
20 namespace v8 { | 20 namespace v8 { |
21 namespace internal { | 21 namespace internal { |
22 | 22 |
23 | 23 |
24 Handle<AccessorInfo> Accessors::MakeAccessor( | 24 Handle<AccessorInfo> Accessors::MakeAccessor( |
25 Isolate* isolate, | 25 Isolate* isolate, |
26 Handle<String> name, | 26 Handle<Name> name, |
27 AccessorGetterCallback getter, | 27 AccessorNameGetterCallback getter, |
28 AccessorSetterCallback setter, | 28 AccessorNameSetterCallback setter, |
29 PropertyAttributes attributes) { | 29 PropertyAttributes attributes) { |
30 Factory* factory = isolate->factory(); | 30 Factory* factory = isolate->factory(); |
31 Handle<ExecutableAccessorInfo> info = factory->NewExecutableAccessorInfo(); | 31 Handle<ExecutableAccessorInfo> info = factory->NewExecutableAccessorInfo(); |
32 info->set_property_attributes(attributes); | 32 info->set_property_attributes(attributes); |
33 info->set_all_can_read(false); | 33 info->set_all_can_read(false); |
34 info->set_all_can_write(false); | 34 info->set_all_can_write(false); |
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 Handle<Object> set = v8::FromCData(isolate, setter); | 37 Handle<Object> set = v8::FromCData(isolate, setter); |
38 info->set_getter(*get); | 38 info->set_getter(*get); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 131 |
132 | 132 |
133 template | 133 template |
134 bool Accessors::IsJSObjectFieldAccessor<HeapType>(Handle<HeapType> type, | 134 bool Accessors::IsJSObjectFieldAccessor<HeapType>(Handle<HeapType> type, |
135 Handle<Name> name, | 135 Handle<Name> name, |
136 int* object_offset); | 136 int* object_offset); |
137 | 137 |
138 | 138 |
139 bool SetPropertyOnInstanceIfInherited( | 139 bool SetPropertyOnInstanceIfInherited( |
140 Isolate* isolate, const v8::PropertyCallbackInfo<void>& info, | 140 Isolate* isolate, const v8::PropertyCallbackInfo<void>& info, |
141 v8::Local<v8::String> name, Handle<Object> value) { | 141 v8::Local<v8::Name> name, Handle<Object> value) { |
142 Handle<Object> holder = Utils::OpenHandle(*info.Holder()); | 142 Handle<Object> holder = Utils::OpenHandle(*info.Holder()); |
143 Handle<Object> receiver = Utils::OpenHandle(*info.This()); | 143 Handle<Object> receiver = Utils::OpenHandle(*info.This()); |
144 if (*holder == *receiver) return false; | 144 if (*holder == *receiver) return false; |
145 if (receiver->IsJSObject()) { | 145 if (receiver->IsJSObject()) { |
146 Handle<JSObject> object = Handle<JSObject>::cast(receiver); | 146 Handle<JSObject> object = Handle<JSObject>::cast(receiver); |
147 // This behaves sloppy since we lost the actual strict-mode. | 147 // This behaves sloppy since we lost the actual strict-mode. |
148 // TODO(verwaest): Fix by making ExecutableAccessorInfo behave like data | 148 // TODO(verwaest): Fix by making ExecutableAccessorInfo behave like data |
149 // properties. | 149 // properties. |
150 if (!object->map()->is_extensible()) return true; | 150 if (!object->map()->is_extensible()) return true; |
151 JSObject::SetOwnPropertyIgnoreAttributes(object, Utils::OpenHandle(*name), | 151 JSObject::SetOwnPropertyIgnoreAttributes(object, Utils::OpenHandle(*name), |
(...skipping 17 matching lines...) Expand all Loading... |
169 has_initial_map()); | 169 has_initial_map()); |
170 if (wrapper->map() == isolate->number_function()->initial_map()) { | 170 if (wrapper->map() == isolate->number_function()->initial_map()) { |
171 return handle(wrapper->value(), isolate); | 171 return handle(wrapper->value(), isolate); |
172 } | 172 } |
173 | 173 |
174 return value; | 174 return value; |
175 } | 175 } |
176 | 176 |
177 | 177 |
178 void Accessors::ArrayLengthGetter( | 178 void Accessors::ArrayLengthGetter( |
179 v8::Local<v8::String> name, | 179 v8::Local<v8::Name> name, |
180 const v8::PropertyCallbackInfo<v8::Value>& info) { | 180 const v8::PropertyCallbackInfo<v8::Value>& info) { |
181 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 181 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
182 DisallowHeapAllocation no_allocation; | 182 DisallowHeapAllocation no_allocation; |
183 HandleScope scope(isolate); | 183 HandleScope scope(isolate); |
184 JSArray* holder = JSArray::cast(*Utils::OpenHandle(*info.Holder())); | 184 JSArray* holder = JSArray::cast(*Utils::OpenHandle(*info.Holder())); |
185 Object* result = holder->length(); | 185 Object* result = holder->length(); |
186 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate))); | 186 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate))); |
187 } | 187 } |
188 | 188 |
189 | 189 |
190 void Accessors::ArrayLengthSetter( | 190 void Accessors::ArrayLengthSetter( |
191 v8::Local<v8::String> name, | 191 v8::Local<v8::Name> name, |
192 v8::Local<v8::Value> val, | 192 v8::Local<v8::Value> val, |
193 const v8::PropertyCallbackInfo<void>& info) { | 193 const v8::PropertyCallbackInfo<void>& info) { |
194 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 194 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
195 HandleScope scope(isolate); | 195 HandleScope scope(isolate); |
196 Handle<JSObject> object = Utils::OpenHandle(*info.This()); | 196 Handle<JSObject> object = Utils::OpenHandle(*info.This()); |
197 Handle<Object> value = Utils::OpenHandle(*val); | 197 Handle<Object> value = Utils::OpenHandle(*val); |
198 if (SetPropertyOnInstanceIfInherited(isolate, info, name, value)) { | 198 if (SetPropertyOnInstanceIfInherited(isolate, info, name, value)) { |
199 return; | 199 return; |
200 } | 200 } |
201 | 201 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 attributes); | 237 attributes); |
238 } | 238 } |
239 | 239 |
240 | 240 |
241 | 241 |
242 // | 242 // |
243 // Accessors::StringLength | 243 // Accessors::StringLength |
244 // | 244 // |
245 | 245 |
246 void Accessors::StringLengthGetter( | 246 void Accessors::StringLengthGetter( |
247 v8::Local<v8::String> name, | 247 v8::Local<v8::Name> name, |
248 const v8::PropertyCallbackInfo<v8::Value>& info) { | 248 const v8::PropertyCallbackInfo<v8::Value>& info) { |
249 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 249 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
250 DisallowHeapAllocation no_allocation; | 250 DisallowHeapAllocation no_allocation; |
251 HandleScope scope(isolate); | 251 HandleScope scope(isolate); |
252 | 252 |
253 // We have a slight impedance mismatch between the external API and the way we | 253 // We have a slight impedance mismatch between the external API and the way we |
254 // use callbacks internally: Externally, callbacks can only be used with | 254 // use callbacks internally: Externally, callbacks can only be used with |
255 // v8::Object, but internally we have callbacks on entities which are higher | 255 // v8::Object, but internally we have callbacks on entities which are higher |
256 // in the hierarchy, in this case for String values. | 256 // in the hierarchy, in this case for String values. |
257 | 257 |
258 Object* value = *Utils::OpenHandle(*v8::Local<v8::Value>(info.This())); | 258 Object* value = *Utils::OpenHandle(*v8::Local<v8::Value>(info.This())); |
259 if (!value->IsString()) { | 259 if (!value->IsString()) { |
260 // Not a string value. That means that we either got a String wrapper or | 260 // Not a string value. That means that we either got a String wrapper or |
261 // a Value with a String wrapper in its prototype chain. | 261 // a Value with a String wrapper in its prototype chain. |
262 value = JSValue::cast(*Utils::OpenHandle(*info.Holder()))->value(); | 262 value = JSValue::cast(*Utils::OpenHandle(*info.Holder()))->value(); |
263 } | 263 } |
264 Object* result = Smi::FromInt(String::cast(value)->length()); | 264 Object* result = Smi::FromInt(String::cast(value)->length()); |
265 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate))); | 265 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate))); |
266 } | 266 } |
267 | 267 |
268 | 268 |
269 void Accessors::StringLengthSetter( | 269 void Accessors::StringLengthSetter( |
270 v8::Local<v8::String> name, | 270 v8::Local<v8::Name> name, |
271 v8::Local<v8::Value> value, | 271 v8::Local<v8::Value> value, |
272 const v8::PropertyCallbackInfo<void>& info) { | 272 const v8::PropertyCallbackInfo<void>& info) { |
273 UNREACHABLE(); | 273 UNREACHABLE(); |
274 } | 274 } |
275 | 275 |
276 | 276 |
277 Handle<AccessorInfo> Accessors::StringLengthInfo( | 277 Handle<AccessorInfo> Accessors::StringLengthInfo( |
278 Isolate* isolate, PropertyAttributes attributes) { | 278 Isolate* isolate, PropertyAttributes attributes) { |
279 return MakeAccessor(isolate, | 279 return MakeAccessor(isolate, |
280 isolate->factory()->length_string(), | 280 isolate->factory()->length_string(), |
281 &StringLengthGetter, | 281 &StringLengthGetter, |
282 &StringLengthSetter, | 282 &StringLengthSetter, |
283 attributes); | 283 attributes); |
284 } | 284 } |
285 | 285 |
286 | 286 |
287 // | 287 // |
288 // Accessors::ScriptColumnOffset | 288 // Accessors::ScriptColumnOffset |
289 // | 289 // |
290 | 290 |
291 | 291 |
292 void Accessors::ScriptColumnOffsetGetter( | 292 void Accessors::ScriptColumnOffsetGetter( |
293 v8::Local<v8::String> name, | 293 v8::Local<v8::Name> name, |
294 const v8::PropertyCallbackInfo<v8::Value>& info) { | 294 const v8::PropertyCallbackInfo<v8::Value>& info) { |
295 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 295 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
296 DisallowHeapAllocation no_allocation; | 296 DisallowHeapAllocation no_allocation; |
297 HandleScope scope(isolate); | 297 HandleScope scope(isolate); |
298 Object* object = *Utils::OpenHandle(*info.This()); | 298 Object* object = *Utils::OpenHandle(*info.This()); |
299 Object* res = Script::cast(JSValue::cast(object)->value())->column_offset(); | 299 Object* res = Script::cast(JSValue::cast(object)->value())->column_offset(); |
300 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); | 300 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); |
301 } | 301 } |
302 | 302 |
303 | 303 |
304 void Accessors::ScriptColumnOffsetSetter( | 304 void Accessors::ScriptColumnOffsetSetter( |
305 v8::Local<v8::String> name, | 305 v8::Local<v8::Name> name, |
306 v8::Local<v8::Value> value, | 306 v8::Local<v8::Value> value, |
307 const v8::PropertyCallbackInfo<void>& info) { | 307 const v8::PropertyCallbackInfo<void>& info) { |
308 UNREACHABLE(); | 308 UNREACHABLE(); |
309 } | 309 } |
310 | 310 |
311 | 311 |
312 Handle<AccessorInfo> Accessors::ScriptColumnOffsetInfo( | 312 Handle<AccessorInfo> Accessors::ScriptColumnOffsetInfo( |
313 Isolate* isolate, PropertyAttributes attributes) { | 313 Isolate* isolate, PropertyAttributes attributes) { |
314 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 314 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
315 STATIC_ASCII_VECTOR("column_offset"))); | 315 STATIC_ASCII_VECTOR("column_offset"))); |
316 return MakeAccessor(isolate, | 316 return MakeAccessor(isolate, |
317 name, | 317 name, |
318 &ScriptColumnOffsetGetter, | 318 &ScriptColumnOffsetGetter, |
319 &ScriptColumnOffsetSetter, | 319 &ScriptColumnOffsetSetter, |
320 attributes); | 320 attributes); |
321 } | 321 } |
322 | 322 |
323 | 323 |
324 // | 324 // |
325 // Accessors::ScriptId | 325 // Accessors::ScriptId |
326 // | 326 // |
327 | 327 |
328 | 328 |
329 void Accessors::ScriptIdGetter( | 329 void Accessors::ScriptIdGetter( |
330 v8::Local<v8::String> name, | 330 v8::Local<v8::Name> name, |
331 const v8::PropertyCallbackInfo<v8::Value>& info) { | 331 const v8::PropertyCallbackInfo<v8::Value>& info) { |
332 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 332 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
333 DisallowHeapAllocation no_allocation; | 333 DisallowHeapAllocation no_allocation; |
334 HandleScope scope(isolate); | 334 HandleScope scope(isolate); |
335 Object* object = *Utils::OpenHandle(*info.This()); | 335 Object* object = *Utils::OpenHandle(*info.This()); |
336 Object* id = Script::cast(JSValue::cast(object)->value())->id(); | 336 Object* id = Script::cast(JSValue::cast(object)->value())->id(); |
337 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(id, isolate))); | 337 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(id, isolate))); |
338 } | 338 } |
339 | 339 |
340 | 340 |
341 void Accessors::ScriptIdSetter( | 341 void Accessors::ScriptIdSetter( |
342 v8::Local<v8::String> name, | 342 v8::Local<v8::Name> name, |
343 v8::Local<v8::Value> value, | 343 v8::Local<v8::Value> value, |
344 const v8::PropertyCallbackInfo<void>& info) { | 344 const v8::PropertyCallbackInfo<void>& info) { |
345 UNREACHABLE(); | 345 UNREACHABLE(); |
346 } | 346 } |
347 | 347 |
348 | 348 |
349 Handle<AccessorInfo> Accessors::ScriptIdInfo( | 349 Handle<AccessorInfo> Accessors::ScriptIdInfo( |
350 Isolate* isolate, PropertyAttributes attributes) { | 350 Isolate* isolate, PropertyAttributes attributes) { |
351 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 351 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
352 STATIC_ASCII_VECTOR("id"))); | 352 STATIC_ASCII_VECTOR("id"))); |
353 return MakeAccessor(isolate, | 353 return MakeAccessor(isolate, |
354 name, | 354 name, |
355 &ScriptIdGetter, | 355 &ScriptIdGetter, |
356 &ScriptIdSetter, | 356 &ScriptIdSetter, |
357 attributes); | 357 attributes); |
358 } | 358 } |
359 | 359 |
360 | 360 |
361 // | 361 // |
362 // Accessors::ScriptName | 362 // Accessors::ScriptName |
363 // | 363 // |
364 | 364 |
365 | 365 |
366 void Accessors::ScriptNameGetter( | 366 void Accessors::ScriptNameGetter( |
367 v8::Local<v8::String> name, | 367 v8::Local<v8::Name> name, |
368 const v8::PropertyCallbackInfo<v8::Value>& info) { | 368 const v8::PropertyCallbackInfo<v8::Value>& info) { |
369 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 369 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
370 DisallowHeapAllocation no_allocation; | 370 DisallowHeapAllocation no_allocation; |
371 HandleScope scope(isolate); | 371 HandleScope scope(isolate); |
372 Object* object = *Utils::OpenHandle(*info.This()); | 372 Object* object = *Utils::OpenHandle(*info.This()); |
373 Object* source = Script::cast(JSValue::cast(object)->value())->name(); | 373 Object* source = Script::cast(JSValue::cast(object)->value())->name(); |
374 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(source, isolate))); | 374 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(source, isolate))); |
375 } | 375 } |
376 | 376 |
377 | 377 |
378 void Accessors::ScriptNameSetter( | 378 void Accessors::ScriptNameSetter( |
379 v8::Local<v8::String> name, | 379 v8::Local<v8::Name> name, |
380 v8::Local<v8::Value> value, | 380 v8::Local<v8::Value> value, |
381 const v8::PropertyCallbackInfo<void>& info) { | 381 const v8::PropertyCallbackInfo<void>& info) { |
382 UNREACHABLE(); | 382 UNREACHABLE(); |
383 } | 383 } |
384 | 384 |
385 | 385 |
386 Handle<AccessorInfo> Accessors::ScriptNameInfo( | 386 Handle<AccessorInfo> Accessors::ScriptNameInfo( |
387 Isolate* isolate, PropertyAttributes attributes) { | 387 Isolate* isolate, PropertyAttributes attributes) { |
388 return MakeAccessor(isolate, | 388 return MakeAccessor(isolate, |
389 isolate->factory()->name_string(), | 389 isolate->factory()->name_string(), |
390 &ScriptNameGetter, | 390 &ScriptNameGetter, |
391 &ScriptNameSetter, | 391 &ScriptNameSetter, |
392 attributes); | 392 attributes); |
393 } | 393 } |
394 | 394 |
395 | 395 |
396 // | 396 // |
397 // Accessors::ScriptSource | 397 // Accessors::ScriptSource |
398 // | 398 // |
399 | 399 |
400 | 400 |
401 void Accessors::ScriptSourceGetter( | 401 void Accessors::ScriptSourceGetter( |
402 v8::Local<v8::String> name, | 402 v8::Local<v8::Name> name, |
403 const v8::PropertyCallbackInfo<v8::Value>& info) { | 403 const v8::PropertyCallbackInfo<v8::Value>& info) { |
404 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 404 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
405 DisallowHeapAllocation no_allocation; | 405 DisallowHeapAllocation no_allocation; |
406 HandleScope scope(isolate); | 406 HandleScope scope(isolate); |
407 Object* object = *Utils::OpenHandle(*info.This()); | 407 Object* object = *Utils::OpenHandle(*info.This()); |
408 Object* source = Script::cast(JSValue::cast(object)->value())->source(); | 408 Object* source = Script::cast(JSValue::cast(object)->value())->source(); |
409 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(source, isolate))); | 409 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(source, isolate))); |
410 } | 410 } |
411 | 411 |
412 | 412 |
413 void Accessors::ScriptSourceSetter( | 413 void Accessors::ScriptSourceSetter( |
414 v8::Local<v8::String> name, | 414 v8::Local<v8::Name> name, |
415 v8::Local<v8::Value> value, | 415 v8::Local<v8::Value> value, |
416 const v8::PropertyCallbackInfo<void>& info) { | 416 const v8::PropertyCallbackInfo<void>& info) { |
417 UNREACHABLE(); | 417 UNREACHABLE(); |
418 } | 418 } |
419 | 419 |
420 | 420 |
421 Handle<AccessorInfo> Accessors::ScriptSourceInfo( | 421 Handle<AccessorInfo> Accessors::ScriptSourceInfo( |
422 Isolate* isolate, PropertyAttributes attributes) { | 422 Isolate* isolate, PropertyAttributes attributes) { |
423 return MakeAccessor(isolate, | 423 return MakeAccessor(isolate, |
424 isolate->factory()->source_string(), | 424 isolate->factory()->source_string(), |
425 &ScriptSourceGetter, | 425 &ScriptSourceGetter, |
426 &ScriptSourceSetter, | 426 &ScriptSourceSetter, |
427 attributes); | 427 attributes); |
428 } | 428 } |
429 | 429 |
430 | 430 |
431 // | 431 // |
432 // Accessors::ScriptLineOffset | 432 // Accessors::ScriptLineOffset |
433 // | 433 // |
434 | 434 |
435 | 435 |
436 void Accessors::ScriptLineOffsetGetter( | 436 void Accessors::ScriptLineOffsetGetter( |
437 v8::Local<v8::String> name, | 437 v8::Local<v8::Name> name, |
438 const v8::PropertyCallbackInfo<v8::Value>& info) { | 438 const v8::PropertyCallbackInfo<v8::Value>& info) { |
439 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 439 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
440 DisallowHeapAllocation no_allocation; | 440 DisallowHeapAllocation no_allocation; |
441 HandleScope scope(isolate); | 441 HandleScope scope(isolate); |
442 Object* object = *Utils::OpenHandle(*info.This()); | 442 Object* object = *Utils::OpenHandle(*info.This()); |
443 Object* res = Script::cast(JSValue::cast(object)->value())->line_offset(); | 443 Object* res = Script::cast(JSValue::cast(object)->value())->line_offset(); |
444 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); | 444 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); |
445 } | 445 } |
446 | 446 |
447 | 447 |
448 void Accessors::ScriptLineOffsetSetter( | 448 void Accessors::ScriptLineOffsetSetter( |
449 v8::Local<v8::String> name, | 449 v8::Local<v8::Name> name, |
450 v8::Local<v8::Value> value, | 450 v8::Local<v8::Value> value, |
451 const v8::PropertyCallbackInfo<void>& info) { | 451 const v8::PropertyCallbackInfo<void>& info) { |
452 UNREACHABLE(); | 452 UNREACHABLE(); |
453 } | 453 } |
454 | 454 |
455 | 455 |
456 Handle<AccessorInfo> Accessors::ScriptLineOffsetInfo( | 456 Handle<AccessorInfo> Accessors::ScriptLineOffsetInfo( |
457 Isolate* isolate, PropertyAttributes attributes) { | 457 Isolate* isolate, PropertyAttributes attributes) { |
458 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 458 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
459 STATIC_ASCII_VECTOR("line_offset"))); | 459 STATIC_ASCII_VECTOR("line_offset"))); |
460 return MakeAccessor(isolate, | 460 return MakeAccessor(isolate, |
461 name, | 461 name, |
462 &ScriptLineOffsetGetter, | 462 &ScriptLineOffsetGetter, |
463 &ScriptLineOffsetSetter, | 463 &ScriptLineOffsetSetter, |
464 attributes); | 464 attributes); |
465 } | 465 } |
466 | 466 |
467 | 467 |
468 // | 468 // |
469 // Accessors::ScriptType | 469 // Accessors::ScriptType |
470 // | 470 // |
471 | 471 |
472 | 472 |
473 void Accessors::ScriptTypeGetter( | 473 void Accessors::ScriptTypeGetter( |
474 v8::Local<v8::String> name, | 474 v8::Local<v8::Name> name, |
475 const v8::PropertyCallbackInfo<v8::Value>& info) { | 475 const v8::PropertyCallbackInfo<v8::Value>& info) { |
476 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 476 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
477 DisallowHeapAllocation no_allocation; | 477 DisallowHeapAllocation no_allocation; |
478 HandleScope scope(isolate); | 478 HandleScope scope(isolate); |
479 Object* object = *Utils::OpenHandle(*info.This()); | 479 Object* object = *Utils::OpenHandle(*info.This()); |
480 Object* res = Script::cast(JSValue::cast(object)->value())->type(); | 480 Object* res = Script::cast(JSValue::cast(object)->value())->type(); |
481 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); | 481 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); |
482 } | 482 } |
483 | 483 |
484 | 484 |
485 void Accessors::ScriptTypeSetter( | 485 void Accessors::ScriptTypeSetter( |
486 v8::Local<v8::String> name, | 486 v8::Local<v8::Name> name, |
487 v8::Local<v8::Value> value, | 487 v8::Local<v8::Value> value, |
488 const v8::PropertyCallbackInfo<void>& info) { | 488 const v8::PropertyCallbackInfo<void>& info) { |
489 UNREACHABLE(); | 489 UNREACHABLE(); |
490 } | 490 } |
491 | 491 |
492 | 492 |
493 Handle<AccessorInfo> Accessors::ScriptTypeInfo( | 493 Handle<AccessorInfo> Accessors::ScriptTypeInfo( |
494 Isolate* isolate, PropertyAttributes attributes) { | 494 Isolate* isolate, PropertyAttributes attributes) { |
495 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 495 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
496 STATIC_ASCII_VECTOR("type"))); | 496 STATIC_ASCII_VECTOR("type"))); |
497 return MakeAccessor(isolate, | 497 return MakeAccessor(isolate, |
498 name, | 498 name, |
499 &ScriptTypeGetter, | 499 &ScriptTypeGetter, |
500 &ScriptTypeSetter, | 500 &ScriptTypeSetter, |
501 attributes); | 501 attributes); |
502 } | 502 } |
503 | 503 |
504 | 504 |
505 // | 505 // |
506 // Accessors::ScriptCompilationType | 506 // Accessors::ScriptCompilationType |
507 // | 507 // |
508 | 508 |
509 | 509 |
510 void Accessors::ScriptCompilationTypeGetter( | 510 void Accessors::ScriptCompilationTypeGetter( |
511 v8::Local<v8::String> name, | 511 v8::Local<v8::Name> name, |
512 const v8::PropertyCallbackInfo<v8::Value>& info) { | 512 const v8::PropertyCallbackInfo<v8::Value>& info) { |
513 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 513 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
514 DisallowHeapAllocation no_allocation; | 514 DisallowHeapAllocation no_allocation; |
515 HandleScope scope(isolate); | 515 HandleScope scope(isolate); |
516 Object* object = *Utils::OpenHandle(*info.This()); | 516 Object* object = *Utils::OpenHandle(*info.This()); |
517 Object* res = Smi::FromInt( | 517 Object* res = Smi::FromInt( |
518 Script::cast(JSValue::cast(object)->value())->compilation_type()); | 518 Script::cast(JSValue::cast(object)->value())->compilation_type()); |
519 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); | 519 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); |
520 } | 520 } |
521 | 521 |
522 | 522 |
523 void Accessors::ScriptCompilationTypeSetter( | 523 void Accessors::ScriptCompilationTypeSetter( |
524 v8::Local<v8::String> name, | 524 v8::Local<v8::Name> name, |
525 v8::Local<v8::Value> value, | 525 v8::Local<v8::Value> value, |
526 const v8::PropertyCallbackInfo<void>& info) { | 526 const v8::PropertyCallbackInfo<void>& info) { |
527 UNREACHABLE(); | 527 UNREACHABLE(); |
528 } | 528 } |
529 | 529 |
530 | 530 |
531 Handle<AccessorInfo> Accessors::ScriptCompilationTypeInfo( | 531 Handle<AccessorInfo> Accessors::ScriptCompilationTypeInfo( |
532 Isolate* isolate, PropertyAttributes attributes) { | 532 Isolate* isolate, PropertyAttributes attributes) { |
533 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 533 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
534 STATIC_ASCII_VECTOR("compilation_type"))); | 534 STATIC_ASCII_VECTOR("compilation_type"))); |
535 return MakeAccessor(isolate, | 535 return MakeAccessor(isolate, |
536 name, | 536 name, |
537 &ScriptCompilationTypeGetter, | 537 &ScriptCompilationTypeGetter, |
538 &ScriptCompilationTypeSetter, | 538 &ScriptCompilationTypeSetter, |
539 attributes); | 539 attributes); |
540 } | 540 } |
541 | 541 |
542 | 542 |
543 // | 543 // |
544 // Accessors::ScriptGetLineEnds | 544 // Accessors::ScriptGetLineEnds |
545 // | 545 // |
546 | 546 |
547 | 547 |
548 void Accessors::ScriptLineEndsGetter( | 548 void Accessors::ScriptLineEndsGetter( |
549 v8::Local<v8::String> name, | 549 v8::Local<v8::Name> name, |
550 const v8::PropertyCallbackInfo<v8::Value>& info) { | 550 const v8::PropertyCallbackInfo<v8::Value>& info) { |
551 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 551 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
552 HandleScope scope(isolate); | 552 HandleScope scope(isolate); |
553 Handle<Object> object = Utils::OpenHandle(*info.This()); | 553 Handle<Object> object = Utils::OpenHandle(*info.This()); |
554 Handle<Script> script( | 554 Handle<Script> script( |
555 Script::cast(Handle<JSValue>::cast(object)->value()), isolate); | 555 Script::cast(Handle<JSValue>::cast(object)->value()), isolate); |
556 Script::InitLineEnds(script); | 556 Script::InitLineEnds(script); |
557 DCHECK(script->line_ends()->IsFixedArray()); | 557 DCHECK(script->line_ends()->IsFixedArray()); |
558 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); | 558 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); |
559 // We do not want anyone to modify this array from JS. | 559 // We do not want anyone to modify this array from JS. |
560 DCHECK(*line_ends == isolate->heap()->empty_fixed_array() || | 560 DCHECK(*line_ends == isolate->heap()->empty_fixed_array() || |
561 line_ends->map() == isolate->heap()->fixed_cow_array_map()); | 561 line_ends->map() == isolate->heap()->fixed_cow_array_map()); |
562 Handle<JSArray> js_array = | 562 Handle<JSArray> js_array = |
563 isolate->factory()->NewJSArrayWithElements(line_ends); | 563 isolate->factory()->NewJSArrayWithElements(line_ends); |
564 info.GetReturnValue().Set(Utils::ToLocal(js_array)); | 564 info.GetReturnValue().Set(Utils::ToLocal(js_array)); |
565 } | 565 } |
566 | 566 |
567 | 567 |
568 void Accessors::ScriptLineEndsSetter( | 568 void Accessors::ScriptLineEndsSetter( |
569 v8::Local<v8::String> name, | 569 v8::Local<v8::Name> name, |
570 v8::Local<v8::Value> value, | 570 v8::Local<v8::Value> value, |
571 const v8::PropertyCallbackInfo<void>& info) { | 571 const v8::PropertyCallbackInfo<void>& info) { |
572 UNREACHABLE(); | 572 UNREACHABLE(); |
573 } | 573 } |
574 | 574 |
575 | 575 |
576 Handle<AccessorInfo> Accessors::ScriptLineEndsInfo( | 576 Handle<AccessorInfo> Accessors::ScriptLineEndsInfo( |
577 Isolate* isolate, PropertyAttributes attributes) { | 577 Isolate* isolate, PropertyAttributes attributes) { |
578 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 578 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
579 STATIC_ASCII_VECTOR("line_ends"))); | 579 STATIC_ASCII_VECTOR("line_ends"))); |
580 return MakeAccessor(isolate, | 580 return MakeAccessor(isolate, |
581 name, | 581 name, |
582 &ScriptLineEndsGetter, | 582 &ScriptLineEndsGetter, |
583 &ScriptLineEndsSetter, | 583 &ScriptLineEndsSetter, |
584 attributes); | 584 attributes); |
585 } | 585 } |
586 | 586 |
587 | 587 |
588 // | 588 // |
589 // Accessors::ScriptSourceUrl | 589 // Accessors::ScriptSourceUrl |
590 // | 590 // |
591 | 591 |
592 | 592 |
593 void Accessors::ScriptSourceUrlGetter( | 593 void Accessors::ScriptSourceUrlGetter( |
594 v8::Local<v8::String> name, | 594 v8::Local<v8::Name> name, |
595 const v8::PropertyCallbackInfo<v8::Value>& info) { | 595 const v8::PropertyCallbackInfo<v8::Value>& info) { |
596 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 596 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
597 DisallowHeapAllocation no_allocation; | 597 DisallowHeapAllocation no_allocation; |
598 HandleScope scope(isolate); | 598 HandleScope scope(isolate); |
599 Object* object = *Utils::OpenHandle(*info.This()); | 599 Object* object = *Utils::OpenHandle(*info.This()); |
600 Object* url = Script::cast(JSValue::cast(object)->value())->source_url(); | 600 Object* url = Script::cast(JSValue::cast(object)->value())->source_url(); |
601 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(url, isolate))); | 601 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(url, isolate))); |
602 } | 602 } |
603 | 603 |
604 | 604 |
605 void Accessors::ScriptSourceUrlSetter( | 605 void Accessors::ScriptSourceUrlSetter( |
606 v8::Local<v8::String> name, | 606 v8::Local<v8::Name> name, |
607 v8::Local<v8::Value> value, | 607 v8::Local<v8::Value> value, |
608 const v8::PropertyCallbackInfo<void>& info) { | 608 const v8::PropertyCallbackInfo<void>& info) { |
609 UNREACHABLE(); | 609 UNREACHABLE(); |
610 } | 610 } |
611 | 611 |
612 | 612 |
613 Handle<AccessorInfo> Accessors::ScriptSourceUrlInfo( | 613 Handle<AccessorInfo> Accessors::ScriptSourceUrlInfo( |
614 Isolate* isolate, PropertyAttributes attributes) { | 614 Isolate* isolate, PropertyAttributes attributes) { |
615 return MakeAccessor(isolate, | 615 return MakeAccessor(isolate, |
616 isolate->factory()->source_url_string(), | 616 isolate->factory()->source_url_string(), |
617 &ScriptSourceUrlGetter, | 617 &ScriptSourceUrlGetter, |
618 &ScriptSourceUrlSetter, | 618 &ScriptSourceUrlSetter, |
619 attributes); | 619 attributes); |
620 } | 620 } |
621 | 621 |
622 | 622 |
623 // | 623 // |
624 // Accessors::ScriptSourceMappingUrl | 624 // Accessors::ScriptSourceMappingUrl |
625 // | 625 // |
626 | 626 |
627 | 627 |
628 void Accessors::ScriptSourceMappingUrlGetter( | 628 void Accessors::ScriptSourceMappingUrlGetter( |
629 v8::Local<v8::String> name, | 629 v8::Local<v8::Name> name, |
630 const v8::PropertyCallbackInfo<v8::Value>& info) { | 630 const v8::PropertyCallbackInfo<v8::Value>& info) { |
631 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 631 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
632 DisallowHeapAllocation no_allocation; | 632 DisallowHeapAllocation no_allocation; |
633 HandleScope scope(isolate); | 633 HandleScope scope(isolate); |
634 Object* object = *Utils::OpenHandle(*info.This()); | 634 Object* object = *Utils::OpenHandle(*info.This()); |
635 Object* url = | 635 Object* url = |
636 Script::cast(JSValue::cast(object)->value())->source_mapping_url(); | 636 Script::cast(JSValue::cast(object)->value())->source_mapping_url(); |
637 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(url, isolate))); | 637 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(url, isolate))); |
638 } | 638 } |
639 | 639 |
640 | 640 |
641 void Accessors::ScriptSourceMappingUrlSetter( | 641 void Accessors::ScriptSourceMappingUrlSetter( |
642 v8::Local<v8::String> name, | 642 v8::Local<v8::Name> name, |
643 v8::Local<v8::Value> value, | 643 v8::Local<v8::Value> value, |
644 const v8::PropertyCallbackInfo<void>& info) { | 644 const v8::PropertyCallbackInfo<void>& info) { |
645 UNREACHABLE(); | 645 UNREACHABLE(); |
646 } | 646 } |
647 | 647 |
648 | 648 |
649 Handle<AccessorInfo> Accessors::ScriptSourceMappingUrlInfo( | 649 Handle<AccessorInfo> Accessors::ScriptSourceMappingUrlInfo( |
650 Isolate* isolate, PropertyAttributes attributes) { | 650 Isolate* isolate, PropertyAttributes attributes) { |
651 return MakeAccessor(isolate, | 651 return MakeAccessor(isolate, |
652 isolate->factory()->source_mapping_url_string(), | 652 isolate->factory()->source_mapping_url_string(), |
653 &ScriptSourceMappingUrlGetter, | 653 &ScriptSourceMappingUrlGetter, |
654 &ScriptSourceMappingUrlSetter, | 654 &ScriptSourceMappingUrlSetter, |
655 attributes); | 655 attributes); |
656 } | 656 } |
657 | 657 |
658 | 658 |
659 // | 659 // |
660 // Accessors::ScriptGetContextData | 660 // Accessors::ScriptGetContextData |
661 // | 661 // |
662 | 662 |
663 | 663 |
664 void Accessors::ScriptContextDataGetter( | 664 void Accessors::ScriptContextDataGetter( |
665 v8::Local<v8::String> name, | 665 v8::Local<v8::Name> name, |
666 const v8::PropertyCallbackInfo<v8::Value>& info) { | 666 const v8::PropertyCallbackInfo<v8::Value>& info) { |
667 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 667 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
668 DisallowHeapAllocation no_allocation; | 668 DisallowHeapAllocation no_allocation; |
669 HandleScope scope(isolate); | 669 HandleScope scope(isolate); |
670 Object* object = *Utils::OpenHandle(*info.This()); | 670 Object* object = *Utils::OpenHandle(*info.This()); |
671 Object* res = Script::cast(JSValue::cast(object)->value())->context_data(); | 671 Object* res = Script::cast(JSValue::cast(object)->value())->context_data(); |
672 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); | 672 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate))); |
673 } | 673 } |
674 | 674 |
675 | 675 |
676 void Accessors::ScriptContextDataSetter( | 676 void Accessors::ScriptContextDataSetter( |
677 v8::Local<v8::String> name, | 677 v8::Local<v8::Name> name, |
678 v8::Local<v8::Value> value, | 678 v8::Local<v8::Value> value, |
679 const v8::PropertyCallbackInfo<void>& info) { | 679 const v8::PropertyCallbackInfo<void>& info) { |
680 UNREACHABLE(); | 680 UNREACHABLE(); |
681 } | 681 } |
682 | 682 |
683 | 683 |
684 Handle<AccessorInfo> Accessors::ScriptContextDataInfo( | 684 Handle<AccessorInfo> Accessors::ScriptContextDataInfo( |
685 Isolate* isolate, PropertyAttributes attributes) { | 685 Isolate* isolate, PropertyAttributes attributes) { |
686 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 686 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
687 STATIC_ASCII_VECTOR("context_data"))); | 687 STATIC_ASCII_VECTOR("context_data"))); |
688 return MakeAccessor(isolate, | 688 return MakeAccessor(isolate, |
689 name, | 689 name, |
690 &ScriptContextDataGetter, | 690 &ScriptContextDataGetter, |
691 &ScriptContextDataSetter, | 691 &ScriptContextDataSetter, |
692 attributes); | 692 attributes); |
693 } | 693 } |
694 | 694 |
695 | 695 |
696 // | 696 // |
697 // Accessors::ScriptGetEvalFromScript | 697 // Accessors::ScriptGetEvalFromScript |
698 // | 698 // |
699 | 699 |
700 | 700 |
701 void Accessors::ScriptEvalFromScriptGetter( | 701 void Accessors::ScriptEvalFromScriptGetter( |
702 v8::Local<v8::String> name, | 702 v8::Local<v8::Name> name, |
703 const v8::PropertyCallbackInfo<v8::Value>& info) { | 703 const v8::PropertyCallbackInfo<v8::Value>& info) { |
704 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 704 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
705 HandleScope scope(isolate); | 705 HandleScope scope(isolate); |
706 Handle<Object> object = Utils::OpenHandle(*info.This()); | 706 Handle<Object> object = Utils::OpenHandle(*info.This()); |
707 Handle<Script> script( | 707 Handle<Script> script( |
708 Script::cast(Handle<JSValue>::cast(object)->value()), isolate); | 708 Script::cast(Handle<JSValue>::cast(object)->value()), isolate); |
709 Handle<Object> result = isolate->factory()->undefined_value(); | 709 Handle<Object> result = isolate->factory()->undefined_value(); |
710 if (!script->eval_from_shared()->IsUndefined()) { | 710 if (!script->eval_from_shared()->IsUndefined()) { |
711 Handle<SharedFunctionInfo> eval_from_shared( | 711 Handle<SharedFunctionInfo> eval_from_shared( |
712 SharedFunctionInfo::cast(script->eval_from_shared())); | 712 SharedFunctionInfo::cast(script->eval_from_shared())); |
713 if (eval_from_shared->script()->IsScript()) { | 713 if (eval_from_shared->script()->IsScript()) { |
714 Handle<Script> eval_from_script(Script::cast(eval_from_shared->script())); | 714 Handle<Script> eval_from_script(Script::cast(eval_from_shared->script())); |
715 result = Script::GetWrapper(eval_from_script); | 715 result = Script::GetWrapper(eval_from_script); |
716 } | 716 } |
717 } | 717 } |
718 | 718 |
719 info.GetReturnValue().Set(Utils::ToLocal(result)); | 719 info.GetReturnValue().Set(Utils::ToLocal(result)); |
720 } | 720 } |
721 | 721 |
722 | 722 |
723 void Accessors::ScriptEvalFromScriptSetter( | 723 void Accessors::ScriptEvalFromScriptSetter( |
724 v8::Local<v8::String> name, | 724 v8::Local<v8::Name> name, |
725 v8::Local<v8::Value> value, | 725 v8::Local<v8::Value> value, |
726 const v8::PropertyCallbackInfo<void>& info) { | 726 const v8::PropertyCallbackInfo<void>& info) { |
727 UNREACHABLE(); | 727 UNREACHABLE(); |
728 } | 728 } |
729 | 729 |
730 | 730 |
731 Handle<AccessorInfo> Accessors::ScriptEvalFromScriptInfo( | 731 Handle<AccessorInfo> Accessors::ScriptEvalFromScriptInfo( |
732 Isolate* isolate, PropertyAttributes attributes) { | 732 Isolate* isolate, PropertyAttributes attributes) { |
733 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 733 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
734 STATIC_ASCII_VECTOR("eval_from_script"))); | 734 STATIC_ASCII_VECTOR("eval_from_script"))); |
735 return MakeAccessor(isolate, | 735 return MakeAccessor(isolate, |
736 name, | 736 name, |
737 &ScriptEvalFromScriptGetter, | 737 &ScriptEvalFromScriptGetter, |
738 &ScriptEvalFromScriptSetter, | 738 &ScriptEvalFromScriptSetter, |
739 attributes); | 739 attributes); |
740 } | 740 } |
741 | 741 |
742 | 742 |
743 // | 743 // |
744 // Accessors::ScriptGetEvalFromScriptPosition | 744 // Accessors::ScriptGetEvalFromScriptPosition |
745 // | 745 // |
746 | 746 |
747 | 747 |
748 void Accessors::ScriptEvalFromScriptPositionGetter( | 748 void Accessors::ScriptEvalFromScriptPositionGetter( |
749 v8::Local<v8::String> name, | 749 v8::Local<v8::Name> name, |
750 const v8::PropertyCallbackInfo<v8::Value>& info) { | 750 const v8::PropertyCallbackInfo<v8::Value>& info) { |
751 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 751 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
752 HandleScope scope(isolate); | 752 HandleScope scope(isolate); |
753 Handle<Object> object = Utils::OpenHandle(*info.This()); | 753 Handle<Object> object = Utils::OpenHandle(*info.This()); |
754 Handle<Script> script( | 754 Handle<Script> script( |
755 Script::cast(Handle<JSValue>::cast(object)->value()), isolate); | 755 Script::cast(Handle<JSValue>::cast(object)->value()), isolate); |
756 Handle<Object> result = isolate->factory()->undefined_value(); | 756 Handle<Object> result = isolate->factory()->undefined_value(); |
757 if (script->compilation_type() == Script::COMPILATION_TYPE_EVAL) { | 757 if (script->compilation_type() == Script::COMPILATION_TYPE_EVAL) { |
758 Handle<Code> code(SharedFunctionInfo::cast( | 758 Handle<Code> code(SharedFunctionInfo::cast( |
759 script->eval_from_shared())->code()); | 759 script->eval_from_shared())->code()); |
760 result = Handle<Object>( | 760 result = Handle<Object>( |
761 Smi::FromInt(code->SourcePosition(code->instruction_start() + | 761 Smi::FromInt(code->SourcePosition(code->instruction_start() + |
762 script->eval_from_instructions_offset()->value())), | 762 script->eval_from_instructions_offset()->value())), |
763 isolate); | 763 isolate); |
764 } | 764 } |
765 info.GetReturnValue().Set(Utils::ToLocal(result)); | 765 info.GetReturnValue().Set(Utils::ToLocal(result)); |
766 } | 766 } |
767 | 767 |
768 | 768 |
769 void Accessors::ScriptEvalFromScriptPositionSetter( | 769 void Accessors::ScriptEvalFromScriptPositionSetter( |
770 v8::Local<v8::String> name, | 770 v8::Local<v8::Name> name, |
771 v8::Local<v8::Value> value, | 771 v8::Local<v8::Value> value, |
772 const v8::PropertyCallbackInfo<void>& info) { | 772 const v8::PropertyCallbackInfo<void>& info) { |
773 UNREACHABLE(); | 773 UNREACHABLE(); |
774 } | 774 } |
775 | 775 |
776 | 776 |
777 Handle<AccessorInfo> Accessors::ScriptEvalFromScriptPositionInfo( | 777 Handle<AccessorInfo> Accessors::ScriptEvalFromScriptPositionInfo( |
778 Isolate* isolate, PropertyAttributes attributes) { | 778 Isolate* isolate, PropertyAttributes attributes) { |
779 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 779 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
780 STATIC_ASCII_VECTOR("eval_from_script_position"))); | 780 STATIC_ASCII_VECTOR("eval_from_script_position"))); |
781 return MakeAccessor(isolate, | 781 return MakeAccessor(isolate, |
782 name, | 782 name, |
783 &ScriptEvalFromScriptPositionGetter, | 783 &ScriptEvalFromScriptPositionGetter, |
784 &ScriptEvalFromScriptPositionSetter, | 784 &ScriptEvalFromScriptPositionSetter, |
785 attributes); | 785 attributes); |
786 } | 786 } |
787 | 787 |
788 | 788 |
789 // | 789 // |
790 // Accessors::ScriptGetEvalFromFunctionName | 790 // Accessors::ScriptGetEvalFromFunctionName |
791 // | 791 // |
792 | 792 |
793 | 793 |
794 void Accessors::ScriptEvalFromFunctionNameGetter( | 794 void Accessors::ScriptEvalFromFunctionNameGetter( |
795 v8::Local<v8::String> name, | 795 v8::Local<v8::Name> name, |
796 const v8::PropertyCallbackInfo<v8::Value>& info) { | 796 const v8::PropertyCallbackInfo<v8::Value>& info) { |
797 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 797 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
798 HandleScope scope(isolate); | 798 HandleScope scope(isolate); |
799 Handle<Object> object = Utils::OpenHandle(*info.This()); | 799 Handle<Object> object = Utils::OpenHandle(*info.This()); |
800 Handle<Script> script( | 800 Handle<Script> script( |
801 Script::cast(Handle<JSValue>::cast(object)->value()), isolate); | 801 Script::cast(Handle<JSValue>::cast(object)->value()), isolate); |
802 Handle<Object> result; | 802 Handle<Object> result; |
803 Handle<SharedFunctionInfo> shared( | 803 Handle<SharedFunctionInfo> shared( |
804 SharedFunctionInfo::cast(script->eval_from_shared())); | 804 SharedFunctionInfo::cast(script->eval_from_shared())); |
805 // Find the name of the function calling eval. | 805 // Find the name of the function calling eval. |
806 if (!shared->name()->IsUndefined()) { | 806 if (!shared->name()->IsUndefined()) { |
807 result = Handle<Object>(shared->name(), isolate); | 807 result = Handle<Object>(shared->name(), isolate); |
808 } else { | 808 } else { |
809 result = Handle<Object>(shared->inferred_name(), isolate); | 809 result = Handle<Object>(shared->inferred_name(), isolate); |
810 } | 810 } |
811 info.GetReturnValue().Set(Utils::ToLocal(result)); | 811 info.GetReturnValue().Set(Utils::ToLocal(result)); |
812 } | 812 } |
813 | 813 |
814 | 814 |
815 void Accessors::ScriptEvalFromFunctionNameSetter( | 815 void Accessors::ScriptEvalFromFunctionNameSetter( |
816 v8::Local<v8::String> name, | 816 v8::Local<v8::Name> name, |
817 v8::Local<v8::Value> value, | 817 v8::Local<v8::Value> value, |
818 const v8::PropertyCallbackInfo<void>& info) { | 818 const v8::PropertyCallbackInfo<void>& info) { |
819 UNREACHABLE(); | 819 UNREACHABLE(); |
820 } | 820 } |
821 | 821 |
822 | 822 |
823 Handle<AccessorInfo> Accessors::ScriptEvalFromFunctionNameInfo( | 823 Handle<AccessorInfo> Accessors::ScriptEvalFromFunctionNameInfo( |
824 Isolate* isolate, PropertyAttributes attributes) { | 824 Isolate* isolate, PropertyAttributes attributes) { |
825 Handle<String> name(isolate->factory()->InternalizeOneByteString( | 825 Handle<String> name(isolate->factory()->InternalizeOneByteString( |
826 STATIC_ASCII_VECTOR("eval_from_function_name"))); | 826 STATIC_ASCII_VECTOR("eval_from_function_name"))); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 | 877 |
878 Handle<Object> Accessors::FunctionSetPrototype(Handle<JSFunction> function, | 878 Handle<Object> Accessors::FunctionSetPrototype(Handle<JSFunction> function, |
879 Handle<Object> prototype) { | 879 Handle<Object> prototype) { |
880 DCHECK(function->should_have_prototype()); | 880 DCHECK(function->should_have_prototype()); |
881 Isolate* isolate = function->GetIsolate(); | 881 Isolate* isolate = function->GetIsolate(); |
882 return SetFunctionPrototype(isolate, function, prototype); | 882 return SetFunctionPrototype(isolate, function, prototype); |
883 } | 883 } |
884 | 884 |
885 | 885 |
886 void Accessors::FunctionPrototypeGetter( | 886 void Accessors::FunctionPrototypeGetter( |
887 v8::Local<v8::String> name, | 887 v8::Local<v8::Name> name, |
888 const v8::PropertyCallbackInfo<v8::Value>& info) { | 888 const v8::PropertyCallbackInfo<v8::Value>& info) { |
889 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 889 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
890 HandleScope scope(isolate); | 890 HandleScope scope(isolate); |
891 Handle<JSFunction> function = | 891 Handle<JSFunction> function = |
892 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); | 892 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); |
893 Handle<Object> result = GetFunctionPrototype(isolate, function); | 893 Handle<Object> result = GetFunctionPrototype(isolate, function); |
894 info.GetReturnValue().Set(Utils::ToLocal(result)); | 894 info.GetReturnValue().Set(Utils::ToLocal(result)); |
895 } | 895 } |
896 | 896 |
897 | 897 |
898 void Accessors::FunctionPrototypeSetter( | 898 void Accessors::FunctionPrototypeSetter( |
899 v8::Local<v8::String> name, | 899 v8::Local<v8::Name> name, |
900 v8::Local<v8::Value> val, | 900 v8::Local<v8::Value> val, |
901 const v8::PropertyCallbackInfo<void>& info) { | 901 const v8::PropertyCallbackInfo<void>& info) { |
902 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 902 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
903 HandleScope scope(isolate); | 903 HandleScope scope(isolate); |
904 Handle<Object> value = Utils::OpenHandle(*val); | 904 Handle<Object> value = Utils::OpenHandle(*val); |
905 if (SetPropertyOnInstanceIfInherited(isolate, info, name, value)) { | 905 if (SetPropertyOnInstanceIfInherited(isolate, info, name, value)) { |
906 return; | 906 return; |
907 } | 907 } |
908 Handle<JSFunction> object = | 908 Handle<JSFunction> object = |
909 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); | 909 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); |
(...skipping 10 matching lines...) Expand all Loading... |
920 attributes); | 920 attributes); |
921 } | 921 } |
922 | 922 |
923 | 923 |
924 // | 924 // |
925 // Accessors::FunctionLength | 925 // Accessors::FunctionLength |
926 // | 926 // |
927 | 927 |
928 | 928 |
929 void Accessors::FunctionLengthGetter( | 929 void Accessors::FunctionLengthGetter( |
930 v8::Local<v8::String> name, | 930 v8::Local<v8::Name> name, |
931 const v8::PropertyCallbackInfo<v8::Value>& info) { | 931 const v8::PropertyCallbackInfo<v8::Value>& info) { |
932 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 932 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
933 HandleScope scope(isolate); | 933 HandleScope scope(isolate); |
934 Handle<JSFunction> function = | 934 Handle<JSFunction> function = |
935 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); | 935 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); |
936 | 936 |
937 int length = 0; | 937 int length = 0; |
938 if (function->shared()->is_compiled()) { | 938 if (function->shared()->is_compiled()) { |
939 length = function->shared()->length(); | 939 length = function->shared()->length(); |
940 } else { | 940 } else { |
941 // If the function isn't compiled yet, the length is not computed | 941 // If the function isn't compiled yet, the length is not computed |
942 // correctly yet. Compile it now and return the right length. | 942 // correctly yet. Compile it now and return the right length. |
943 if (Compiler::EnsureCompiled(function, KEEP_EXCEPTION)) { | 943 if (Compiler::EnsureCompiled(function, KEEP_EXCEPTION)) { |
944 length = function->shared()->length(); | 944 length = function->shared()->length(); |
945 } | 945 } |
946 if (isolate->has_pending_exception()) { | 946 if (isolate->has_pending_exception()) { |
947 isolate->OptionalRescheduleException(false); | 947 isolate->OptionalRescheduleException(false); |
948 } | 948 } |
949 } | 949 } |
950 Handle<Object> result(Smi::FromInt(length), isolate); | 950 Handle<Object> result(Smi::FromInt(length), isolate); |
951 info.GetReturnValue().Set(Utils::ToLocal(result)); | 951 info.GetReturnValue().Set(Utils::ToLocal(result)); |
952 } | 952 } |
953 | 953 |
954 | 954 |
955 void Accessors::FunctionLengthSetter( | 955 void Accessors::FunctionLengthSetter( |
956 v8::Local<v8::String> name, | 956 v8::Local<v8::Name> name, |
957 v8::Local<v8::Value> val, | 957 v8::Local<v8::Value> val, |
958 const v8::PropertyCallbackInfo<void>& info) { | 958 const v8::PropertyCallbackInfo<void>& info) { |
959 // Function length is non writable, non configurable. | 959 // Function length is non writable, non configurable. |
960 UNREACHABLE(); | 960 UNREACHABLE(); |
961 } | 961 } |
962 | 962 |
963 | 963 |
964 Handle<AccessorInfo> Accessors::FunctionLengthInfo( | 964 Handle<AccessorInfo> Accessors::FunctionLengthInfo( |
965 Isolate* isolate, PropertyAttributes attributes) { | 965 Isolate* isolate, PropertyAttributes attributes) { |
966 return MakeAccessor(isolate, | 966 return MakeAccessor(isolate, |
967 isolate->factory()->length_string(), | 967 isolate->factory()->length_string(), |
968 &FunctionLengthGetter, | 968 &FunctionLengthGetter, |
969 &FunctionLengthSetter, | 969 &FunctionLengthSetter, |
970 attributes); | 970 attributes); |
971 } | 971 } |
972 | 972 |
973 | 973 |
974 // | 974 // |
975 // Accessors::FunctionName | 975 // Accessors::FunctionName |
976 // | 976 // |
977 | 977 |
978 | 978 |
979 void Accessors::FunctionNameGetter( | 979 void Accessors::FunctionNameGetter( |
980 v8::Local<v8::String> name, | 980 v8::Local<v8::Name> name, |
981 const v8::PropertyCallbackInfo<v8::Value>& info) { | 981 const v8::PropertyCallbackInfo<v8::Value>& info) { |
982 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 982 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
983 HandleScope scope(isolate); | 983 HandleScope scope(isolate); |
984 Handle<JSFunction> function = | 984 Handle<JSFunction> function = |
985 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); | 985 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); |
986 Handle<Object> result(function->shared()->name(), isolate); | 986 Handle<Object> result(function->shared()->name(), isolate); |
987 info.GetReturnValue().Set(Utils::ToLocal(result)); | 987 info.GetReturnValue().Set(Utils::ToLocal(result)); |
988 } | 988 } |
989 | 989 |
990 | 990 |
991 void Accessors::FunctionNameSetter( | 991 void Accessors::FunctionNameSetter( |
992 v8::Local<v8::String> name, | 992 v8::Local<v8::Name> name, |
993 v8::Local<v8::Value> val, | 993 v8::Local<v8::Value> val, |
994 const v8::PropertyCallbackInfo<void>& info) { | 994 const v8::PropertyCallbackInfo<void>& info) { |
995 // Function name is non writable, non configurable. | 995 // Function name is non writable, non configurable. |
996 UNREACHABLE(); | 996 UNREACHABLE(); |
997 } | 997 } |
998 | 998 |
999 | 999 |
1000 Handle<AccessorInfo> Accessors::FunctionNameInfo( | 1000 Handle<AccessorInfo> Accessors::FunctionNameInfo( |
1001 Isolate* isolate, PropertyAttributes attributes) { | 1001 Isolate* isolate, PropertyAttributes attributes) { |
1002 return MakeAccessor(isolate, | 1002 return MakeAccessor(isolate, |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1107 return isolate->factory()->null_value(); | 1107 return isolate->factory()->null_value(); |
1108 } | 1108 } |
1109 | 1109 |
1110 | 1110 |
1111 Handle<Object> Accessors::FunctionGetArguments(Handle<JSFunction> function) { | 1111 Handle<Object> Accessors::FunctionGetArguments(Handle<JSFunction> function) { |
1112 return GetFunctionArguments(function->GetIsolate(), function); | 1112 return GetFunctionArguments(function->GetIsolate(), function); |
1113 } | 1113 } |
1114 | 1114 |
1115 | 1115 |
1116 void Accessors::FunctionArgumentsGetter( | 1116 void Accessors::FunctionArgumentsGetter( |
1117 v8::Local<v8::String> name, | 1117 v8::Local<v8::Name> name, |
1118 const v8::PropertyCallbackInfo<v8::Value>& info) { | 1118 const v8::PropertyCallbackInfo<v8::Value>& info) { |
1119 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 1119 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
1120 HandleScope scope(isolate); | 1120 HandleScope scope(isolate); |
1121 Handle<JSFunction> function = | 1121 Handle<JSFunction> function = |
1122 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); | 1122 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); |
1123 Handle<Object> result = GetFunctionArguments(isolate, function); | 1123 Handle<Object> result = GetFunctionArguments(isolate, function); |
1124 info.GetReturnValue().Set(Utils::ToLocal(result)); | 1124 info.GetReturnValue().Set(Utils::ToLocal(result)); |
1125 } | 1125 } |
1126 | 1126 |
1127 | 1127 |
1128 void Accessors::FunctionArgumentsSetter( | 1128 void Accessors::FunctionArgumentsSetter( |
1129 v8::Local<v8::String> name, | 1129 v8::Local<v8::Name> name, |
1130 v8::Local<v8::Value> val, | 1130 v8::Local<v8::Value> val, |
1131 const v8::PropertyCallbackInfo<void>& info) { | 1131 const v8::PropertyCallbackInfo<void>& info) { |
1132 // Function arguments is non writable, non configurable. | 1132 // Function arguments is non writable, non configurable. |
1133 UNREACHABLE(); | 1133 UNREACHABLE(); |
1134 } | 1134 } |
1135 | 1135 |
1136 | 1136 |
1137 Handle<AccessorInfo> Accessors::FunctionArgumentsInfo( | 1137 Handle<AccessorInfo> Accessors::FunctionArgumentsInfo( |
1138 Isolate* isolate, PropertyAttributes attributes) { | 1138 Isolate* isolate, PropertyAttributes attributes) { |
1139 return MakeAccessor(isolate, | 1139 return MakeAccessor(isolate, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 } | 1250 } |
1251 // Don't return caller from another security context. | 1251 // Don't return caller from another security context. |
1252 if (!AllowAccessToFunction(isolate->context(), caller)) { | 1252 if (!AllowAccessToFunction(isolate->context(), caller)) { |
1253 return MaybeHandle<JSFunction>(); | 1253 return MaybeHandle<JSFunction>(); |
1254 } | 1254 } |
1255 return Handle<JSFunction>(caller); | 1255 return Handle<JSFunction>(caller); |
1256 } | 1256 } |
1257 | 1257 |
1258 | 1258 |
1259 void Accessors::FunctionCallerGetter( | 1259 void Accessors::FunctionCallerGetter( |
1260 v8::Local<v8::String> name, | 1260 v8::Local<v8::Name> name, |
1261 const v8::PropertyCallbackInfo<v8::Value>& info) { | 1261 const v8::PropertyCallbackInfo<v8::Value>& info) { |
1262 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 1262 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
1263 HandleScope scope(isolate); | 1263 HandleScope scope(isolate); |
1264 Handle<JSFunction> function = | 1264 Handle<JSFunction> function = |
1265 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); | 1265 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); |
1266 Handle<Object> result; | 1266 Handle<Object> result; |
1267 MaybeHandle<JSFunction> maybe_caller; | 1267 MaybeHandle<JSFunction> maybe_caller; |
1268 maybe_caller = FindCaller(isolate, function); | 1268 maybe_caller = FindCaller(isolate, function); |
1269 Handle<JSFunction> caller; | 1269 Handle<JSFunction> caller; |
1270 if (maybe_caller.ToHandle(&caller)) { | 1270 if (maybe_caller.ToHandle(&caller)) { |
1271 result = caller; | 1271 result = caller; |
1272 } else { | 1272 } else { |
1273 result = isolate->factory()->null_value(); | 1273 result = isolate->factory()->null_value(); |
1274 } | 1274 } |
1275 info.GetReturnValue().Set(Utils::ToLocal(result)); | 1275 info.GetReturnValue().Set(Utils::ToLocal(result)); |
1276 } | 1276 } |
1277 | 1277 |
1278 | 1278 |
1279 void Accessors::FunctionCallerSetter( | 1279 void Accessors::FunctionCallerSetter( |
1280 v8::Local<v8::String> name, | 1280 v8::Local<v8::Name> name, |
1281 v8::Local<v8::Value> val, | 1281 v8::Local<v8::Value> val, |
1282 const v8::PropertyCallbackInfo<void>& info) { | 1282 const v8::PropertyCallbackInfo<void>& info) { |
1283 // Function caller is non writable, non configurable. | 1283 // Function caller is non writable, non configurable. |
1284 UNREACHABLE(); | 1284 UNREACHABLE(); |
1285 } | 1285 } |
1286 | 1286 |
1287 | 1287 |
1288 Handle<AccessorInfo> Accessors::FunctionCallerInfo( | 1288 Handle<AccessorInfo> Accessors::FunctionCallerInfo( |
1289 Isolate* isolate, PropertyAttributes attributes) { | 1289 Isolate* isolate, PropertyAttributes attributes) { |
1290 return MakeAccessor(isolate, | 1290 return MakeAccessor(isolate, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 info->set_data(Smi::FromInt(index)); | 1354 info->set_data(Smi::FromInt(index)); |
1355 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); | 1355 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); |
1356 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); | 1356 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); |
1357 info->set_getter(*getter); | 1357 info->set_getter(*getter); |
1358 if (!(attributes & ReadOnly)) info->set_setter(*setter); | 1358 if (!(attributes & ReadOnly)) info->set_setter(*setter); |
1359 return info; | 1359 return info; |
1360 } | 1360 } |
1361 | 1361 |
1362 | 1362 |
1363 } } // namespace v8::internal | 1363 } } // namespace v8::internal |
OLD | NEW |