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

Side by Side Diff: src/api.cc

Issue 4100005: Version 2.5.2 (Closed)
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/api.h ('k') | src/arm/codegen-arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 450
451 void V8::DisposeGlobal(i::Object** obj) { 451 void V8::DisposeGlobal(i::Object** obj) {
452 LOG_API("DisposeGlobal"); 452 LOG_API("DisposeGlobal");
453 if (!i::V8::IsRunning()) return; 453 if (!i::V8::IsRunning()) return;
454 i::GlobalHandles::Destroy(obj); 454 i::GlobalHandles::Destroy(obj);
455 } 455 }
456 456
457 // --- H a n d l e s --- 457 // --- H a n d l e s ---
458 458
459 459
460 HandleScope::HandleScope() : is_closed_(false) { 460 HandleScope::HandleScope()
461 : prev_next_(i::HandleScope::current_.next),
462 prev_limit_(i::HandleScope::current_.limit),
463 is_closed_(false) {
461 API_ENTRY_CHECK("HandleScope::HandleScope"); 464 API_ENTRY_CHECK("HandleScope::HandleScope");
462 i::HandleScope::Enter(&previous_); 465 i::HandleScope::current_.level++;
463 } 466 }
464 467
465 468
466 HandleScope::~HandleScope() { 469 HandleScope::~HandleScope() {
467 if (!is_closed_) { 470 if (!is_closed_) {
468 i::HandleScope::Leave(&previous_); 471 Leave();
469 } 472 }
470 } 473 }
471 474
472 475
476 void HandleScope::Leave() {
477 i::HandleScope::current_.level--;
478 ASSERT(i::HandleScope::current_.level >= 0);
479 i::HandleScope::current_.next = prev_next_;
480 if (i::HandleScope::current_.limit != prev_limit_) {
481 i::HandleScope::current_.limit = prev_limit_;
482 i::HandleScope::DeleteExtensions();
483 }
484
485 #ifdef DEBUG
486 i::HandleScope::ZapRange(prev_next_, prev_limit_);
487 #endif
488 }
489
490
473 int HandleScope::NumberOfHandles() { 491 int HandleScope::NumberOfHandles() {
474 return i::HandleScope::NumberOfHandles(); 492 return i::HandleScope::NumberOfHandles();
475 } 493 }
476 494
477 495
478 i::Object** v8::HandleScope::CreateHandle(i::Object* value) { 496 i::Object** v8::HandleScope::CreateHandle(i::Object* value) {
479 return i::HandleScope::CreateHandle(value); 497 return i::HandleScope::CreateHandle(value);
480 } 498 }
481 499
482 500
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 return 0; 564 return 0;
547 } 565 }
548 LOG_API("CloseHandleScope"); 566 LOG_API("CloseHandleScope");
549 567
550 // Read the result before popping the handle block. 568 // Read the result before popping the handle block.
551 i::Object* result = NULL; 569 i::Object* result = NULL;
552 if (value != NULL) { 570 if (value != NULL) {
553 result = *value; 571 result = *value;
554 } 572 }
555 is_closed_ = true; 573 is_closed_ = true;
556 i::HandleScope::Leave(&previous_); 574 Leave();
557 575
558 if (value == NULL) { 576 if (value == NULL) {
559 return NULL; 577 return NULL;
560 } 578 }
561 579
562 // Allocate a new handle on the previous handle block. 580 // Allocate a new handle on the previous handle block.
563 i::Handle<i::Object> handle(result); 581 i::Handle<i::Object> handle(result);
564 return handle.location(); 582 return handle.location();
565 } 583 }
566 584
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 return scope.Close(Utils::StackTraceToLocal(stackTrace)); 1500 return scope.Close(Utils::StackTraceToLocal(stackTrace));
1483 } 1501 }
1484 1502
1485 1503
1486 static i::Handle<i::Object> CallV8HeapFunction(const char* name, 1504 static i::Handle<i::Object> CallV8HeapFunction(const char* name,
1487 i::Handle<i::Object> recv, 1505 i::Handle<i::Object> recv,
1488 int argc, 1506 int argc,
1489 i::Object** argv[], 1507 i::Object** argv[],
1490 bool* has_pending_exception) { 1508 bool* has_pending_exception) {
1491 i::Handle<i::String> fmt_str = i::Factory::LookupAsciiSymbol(name); 1509 i::Handle<i::String> fmt_str = i::Factory::LookupAsciiSymbol(name);
1492 i::Object* object_fun = i::Top::builtins()->GetProperty(*fmt_str); 1510 i::Object* object_fun =
1511 i::Top::builtins()->GetPropertyNoExceptionThrown(*fmt_str);
1493 i::Handle<i::JSFunction> fun = 1512 i::Handle<i::JSFunction> fun =
1494 i::Handle<i::JSFunction>(i::JSFunction::cast(object_fun)); 1513 i::Handle<i::JSFunction>(i::JSFunction::cast(object_fun));
1495 i::Handle<i::Object> value = 1514 i::Handle<i::Object> value =
1496 i::Execution::Call(fun, recv, argc, argv, has_pending_exception); 1515 i::Execution::Call(fun, recv, argc, argv, has_pending_exception);
1497 return value; 1516 return value;
1498 } 1517 }
1499 1518
1500 1519
1501 static i::Handle<i::Object> CallV8HeapFunction(const char* name, 1520 static i::Handle<i::Object> CallV8HeapFunction(const char* name,
1502 i::Handle<i::Object> data, 1521 i::Handle<i::Object> data,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1598 } 1617 }
1599 1618
1600 1619
1601 // --- S t a c k T r a c e --- 1620 // --- S t a c k T r a c e ---
1602 1621
1603 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const { 1622 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const {
1604 if (IsDeadCheck("v8::StackTrace::GetFrame()")) return Local<StackFrame>(); 1623 if (IsDeadCheck("v8::StackTrace::GetFrame()")) return Local<StackFrame>();
1605 ENTER_V8; 1624 ENTER_V8;
1606 HandleScope scope; 1625 HandleScope scope;
1607 i::Handle<i::JSArray> self = Utils::OpenHandle(this); 1626 i::Handle<i::JSArray> self = Utils::OpenHandle(this);
1608 i::Handle<i::JSObject> obj(i::JSObject::cast(self->GetElement(index))); 1627 i::Object* raw_object = self->GetElementNoExceptionThrown(index);
1628 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_object));
1609 return scope.Close(Utils::StackFrameToLocal(obj)); 1629 return scope.Close(Utils::StackFrameToLocal(obj));
1610 } 1630 }
1611 1631
1612 1632
1613 int StackTrace::GetFrameCount() const { 1633 int StackTrace::GetFrameCount() const {
1614 if (IsDeadCheck("v8::StackTrace::GetFrameCount()")) return -1; 1634 if (IsDeadCheck("v8::StackTrace::GetFrameCount()")) return -1;
1615 ENTER_V8; 1635 ENTER_V8;
1616 return i::Smi::cast(Utils::OpenHandle(this)->length())->value(); 1636 return i::Smi::cast(Utils::OpenHandle(this)->length())->value();
1617 } 1637 }
1618 1638
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
2514 Handle<String> key) { 2534 Handle<String> key) {
2515 ON_BAILOUT("v8::Object::GetRealNamedPropertyInPrototypeChain()", 2535 ON_BAILOUT("v8::Object::GetRealNamedPropertyInPrototypeChain()",
2516 return Local<Value>()); 2536 return Local<Value>());
2517 ENTER_V8; 2537 ENTER_V8;
2518 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); 2538 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this);
2519 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 2539 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
2520 i::LookupResult lookup; 2540 i::LookupResult lookup;
2521 self_obj->LookupRealNamedPropertyInPrototypes(*key_obj, &lookup); 2541 self_obj->LookupRealNamedPropertyInPrototypes(*key_obj, &lookup);
2522 if (lookup.IsProperty()) { 2542 if (lookup.IsProperty()) {
2523 PropertyAttributes attributes; 2543 PropertyAttributes attributes;
2524 i::Handle<i::Object> result(self_obj->GetProperty(*self_obj, 2544 i::Object* property =
2525 &lookup, 2545 self_obj->GetProperty(*self_obj,
2526 *key_obj, 2546 &lookup,
2527 &attributes)); 2547 *key_obj,
2548 &attributes)->ToObjectUnchecked();
2549 i::Handle<i::Object> result(property);
2528 return Utils::ToLocal(result); 2550 return Utils::ToLocal(result);
2529 } 2551 }
2530 return Local<Value>(); // No real property was found in prototype chain. 2552 return Local<Value>(); // No real property was found in prototype chain.
2531 } 2553 }
2532 2554
2533 2555
2534 Local<Value> v8::Object::GetRealNamedProperty(Handle<String> key) { 2556 Local<Value> v8::Object::GetRealNamedProperty(Handle<String> key) {
2535 ON_BAILOUT("v8::Object::GetRealNamedProperty()", return Local<Value>()); 2557 ON_BAILOUT("v8::Object::GetRealNamedProperty()", return Local<Value>());
2536 ENTER_V8; 2558 ENTER_V8;
2537 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); 2559 i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this);
2538 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 2560 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
2539 i::LookupResult lookup; 2561 i::LookupResult lookup;
2540 self_obj->LookupRealNamedProperty(*key_obj, &lookup); 2562 self_obj->LookupRealNamedProperty(*key_obj, &lookup);
2541 if (lookup.IsProperty()) { 2563 if (lookup.IsProperty()) {
2542 PropertyAttributes attributes; 2564 PropertyAttributes attributes;
2543 i::Handle<i::Object> result(self_obj->GetProperty(*self_obj, 2565 i::Object* property =
2544 &lookup, 2566 self_obj->GetProperty(*self_obj,
2545 *key_obj, 2567 &lookup,
2546 &attributes)); 2568 *key_obj,
2569 &attributes)->ToObjectUnchecked();
2570 i::Handle<i::Object> result(property);
2547 return Utils::ToLocal(result); 2571 return Utils::ToLocal(result);
2548 } 2572 }
2549 return Local<Value>(); // No real property was found in prototype chain. 2573 return Local<Value>(); // No real property was found in prototype chain.
2550 } 2574 }
2551 2575
2552 2576
2553 // Turns on access checks by copying the map and setting the check flag. 2577 // Turns on access checks by copying the map and setting the check flag.
2554 // Because the object gets a new map, existing inline cache caching 2578 // Because the object gets a new map, existing inline cache caching
2555 // the old map of this object will fail. 2579 // the old map of this object will fail.
2556 void v8::Object::TurnOnAccessCheck() { 2580 void v8::Object::TurnOnAccessCheck() {
(...skipping 2412 matching lines...) Expand 10 before | Expand all | Expand 10 after
4969 4993
4970 4994
4971 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 4995 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
4972 HandleScopeImplementer* thread_local = 4996 HandleScopeImplementer* thread_local =
4973 reinterpret_cast<HandleScopeImplementer*>(storage); 4997 reinterpret_cast<HandleScopeImplementer*>(storage);
4974 thread_local->IterateThis(v); 4998 thread_local->IterateThis(v);
4975 return storage + ArchiveSpacePerThread(); 4999 return storage + ArchiveSpacePerThread();
4976 } 5000 }
4977 5001
4978 } } // namespace v8::internal 5002 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.h ('k') | src/arm/codegen-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698