OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 Object* result; | 62 Object* result; |
63 { MaybeObject* maybe_result = | 63 { MaybeObject* maybe_result = |
64 constructor->GetHeap()->AllocateJSObject(constructor); | 64 constructor->GetHeap()->AllocateJSObject(constructor); |
65 if (!maybe_result->ToObject(&result)) return maybe_result; | 65 if (!maybe_result->ToObject(&result)) return maybe_result; |
66 } | 66 } |
67 JSValue::cast(result)->set_value(value); | 67 JSValue::cast(result)->set_value(value); |
68 return result; | 68 return result; |
69 } | 69 } |
70 | 70 |
71 | 71 |
72 MaybeObject* Object::ToObject(Context* global_context) { | 72 MaybeObject* Object::ToObject(Context* native_context) { |
73 if (IsNumber()) { | 73 if (IsNumber()) { |
74 return CreateJSValue(global_context->number_function(), this); | 74 return CreateJSValue(native_context->number_function(), this); |
75 } else if (IsBoolean()) { | 75 } else if (IsBoolean()) { |
76 return CreateJSValue(global_context->boolean_function(), this); | 76 return CreateJSValue(native_context->boolean_function(), this); |
77 } else if (IsString()) { | 77 } else if (IsString()) { |
78 return CreateJSValue(global_context->string_function(), this); | 78 return CreateJSValue(native_context->string_function(), this); |
79 } | 79 } |
80 ASSERT(IsJSObject()); | 80 ASSERT(IsJSObject()); |
81 return this; | 81 return this; |
82 } | 82 } |
83 | 83 |
84 | 84 |
85 MaybeObject* Object::ToObject() { | 85 MaybeObject* Object::ToObject() { |
86 if (IsJSReceiver()) { | 86 if (IsJSReceiver()) { |
87 return this; | 87 return this; |
88 } else if (IsNumber()) { | 88 } else if (IsNumber()) { |
89 Isolate* isolate = Isolate::Current(); | 89 Isolate* isolate = Isolate::Current(); |
90 Context* global_context = isolate->context()->global_context(); | 90 Context* native_context = isolate->context()->native_context(); |
91 return CreateJSValue(global_context->number_function(), this); | 91 return CreateJSValue(native_context->number_function(), this); |
92 } else if (IsBoolean()) { | 92 } else if (IsBoolean()) { |
93 Isolate* isolate = HeapObject::cast(this)->GetIsolate(); | 93 Isolate* isolate = HeapObject::cast(this)->GetIsolate(); |
94 Context* global_context = isolate->context()->global_context(); | 94 Context* native_context = isolate->context()->native_context(); |
95 return CreateJSValue(global_context->boolean_function(), this); | 95 return CreateJSValue(native_context->boolean_function(), this); |
96 } else if (IsString()) { | 96 } else if (IsString()) { |
97 Isolate* isolate = HeapObject::cast(this)->GetIsolate(); | 97 Isolate* isolate = HeapObject::cast(this)->GetIsolate(); |
98 Context* global_context = isolate->context()->global_context(); | 98 Context* native_context = isolate->context()->native_context(); |
99 return CreateJSValue(global_context->string_function(), this); | 99 return CreateJSValue(native_context->string_function(), this); |
100 } | 100 } |
101 | 101 |
102 // Throw a type error. | 102 // Throw a type error. |
103 return Failure::InternalError(); | 103 return Failure::InternalError(); |
104 } | 104 } |
105 | 105 |
106 | 106 |
107 Object* Object::ToBoolean() { | 107 Object* Object::ToBoolean() { |
108 if (IsTrue()) return this; | 108 if (IsTrue()) return this; |
109 if (IsFalse()) return this; | 109 if (IsFalse()) return this; |
(...skipping 17 matching lines...) Expand all Loading... |
127 } | 127 } |
128 return heap_object->GetHeap()->true_value(); | 128 return heap_object->GetHeap()->true_value(); |
129 } | 129 } |
130 | 130 |
131 | 131 |
132 void Object::Lookup(String* name, LookupResult* result) { | 132 void Object::Lookup(String* name, LookupResult* result) { |
133 Object* holder = NULL; | 133 Object* holder = NULL; |
134 if (IsJSReceiver()) { | 134 if (IsJSReceiver()) { |
135 holder = this; | 135 holder = this; |
136 } else { | 136 } else { |
137 Context* global_context = Isolate::Current()->context()->global_context(); | 137 Context* native_context = Isolate::Current()->context()->native_context(); |
138 if (IsNumber()) { | 138 if (IsNumber()) { |
139 holder = global_context->number_function()->instance_prototype(); | 139 holder = native_context->number_function()->instance_prototype(); |
140 } else if (IsString()) { | 140 } else if (IsString()) { |
141 holder = global_context->string_function()->instance_prototype(); | 141 holder = native_context->string_function()->instance_prototype(); |
142 } else if (IsBoolean()) { | 142 } else if (IsBoolean()) { |
143 holder = global_context->boolean_function()->instance_prototype(); | 143 holder = native_context->boolean_function()->instance_prototype(); |
144 } | 144 } |
145 } | 145 } |
146 ASSERT(holder != NULL); // Cannot handle null or undefined. | 146 ASSERT(holder != NULL); // Cannot handle null or undefined. |
147 JSReceiver::cast(holder)->Lookup(name, result); | 147 JSReceiver::cast(holder)->Lookup(name, result); |
148 } | 148 } |
149 | 149 |
150 | 150 |
151 MaybeObject* Object::GetPropertyWithReceiver(Object* receiver, | 151 MaybeObject* Object::GetPropertyWithReceiver(Object* receiver, |
152 String* name, | 152 String* name, |
153 PropertyAttributes* attributes) { | 153 PropertyAttributes* attributes) { |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 : HeapObject::cast(this)->GetHeap(); | 655 : HeapObject::cast(this)->GetHeap(); |
656 Object* holder = this; | 656 Object* holder = this; |
657 | 657 |
658 // Iterate up the prototype chain until an element is found or the null | 658 // Iterate up the prototype chain until an element is found or the null |
659 // prototype is encountered. | 659 // prototype is encountered. |
660 for (holder = this; | 660 for (holder = this; |
661 holder != heap->null_value(); | 661 holder != heap->null_value(); |
662 holder = holder->GetPrototype()) { | 662 holder = holder->GetPrototype()) { |
663 if (!holder->IsJSObject()) { | 663 if (!holder->IsJSObject()) { |
664 Isolate* isolate = heap->isolate(); | 664 Isolate* isolate = heap->isolate(); |
665 Context* global_context = isolate->context()->global_context(); | 665 Context* native_context = isolate->context()->native_context(); |
666 if (holder->IsNumber()) { | 666 if (holder->IsNumber()) { |
667 holder = global_context->number_function()->instance_prototype(); | 667 holder = native_context->number_function()->instance_prototype(); |
668 } else if (holder->IsString()) { | 668 } else if (holder->IsString()) { |
669 holder = global_context->string_function()->instance_prototype(); | 669 holder = native_context->string_function()->instance_prototype(); |
670 } else if (holder->IsBoolean()) { | 670 } else if (holder->IsBoolean()) { |
671 holder = global_context->boolean_function()->instance_prototype(); | 671 holder = native_context->boolean_function()->instance_prototype(); |
672 } else if (holder->IsJSProxy()) { | 672 } else if (holder->IsJSProxy()) { |
673 return JSProxy::cast(holder)->GetElementWithHandler(receiver, index); | 673 return JSProxy::cast(holder)->GetElementWithHandler(receiver, index); |
674 } else { | 674 } else { |
675 // Undefined and null have no indexed properties. | 675 // Undefined and null have no indexed properties. |
676 ASSERT(holder->IsUndefined() || holder->IsNull()); | 676 ASSERT(holder->IsUndefined() || holder->IsNull()); |
677 return heap->undefined_value(); | 677 return heap->undefined_value(); |
678 } | 678 } |
679 } | 679 } |
680 | 680 |
681 // Inline the case for JSObjects. Doing so significantly improves the | 681 // Inline the case for JSObjects. Doing so significantly improves the |
(...skipping 21 matching lines...) Expand all Loading... |
703 } | 703 } |
704 } | 704 } |
705 | 705 |
706 return heap->undefined_value(); | 706 return heap->undefined_value(); |
707 } | 707 } |
708 | 708 |
709 | 709 |
710 Object* Object::GetPrototype() { | 710 Object* Object::GetPrototype() { |
711 if (IsSmi()) { | 711 if (IsSmi()) { |
712 Heap* heap = Isolate::Current()->heap(); | 712 Heap* heap = Isolate::Current()->heap(); |
713 Context* context = heap->isolate()->context()->global_context(); | 713 Context* context = heap->isolate()->context()->native_context(); |
714 return context->number_function()->instance_prototype(); | 714 return context->number_function()->instance_prototype(); |
715 } | 715 } |
716 | 716 |
717 HeapObject* heap_object = HeapObject::cast(this); | 717 HeapObject* heap_object = HeapObject::cast(this); |
718 | 718 |
719 // The object is either a number, a string, a boolean, | 719 // The object is either a number, a string, a boolean, |
720 // a real JS object, or a Harmony proxy. | 720 // a real JS object, or a Harmony proxy. |
721 if (heap_object->IsJSReceiver()) { | 721 if (heap_object->IsJSReceiver()) { |
722 return heap_object->map()->prototype(); | 722 return heap_object->map()->prototype(); |
723 } | 723 } |
724 Heap* heap = heap_object->GetHeap(); | 724 Heap* heap = heap_object->GetHeap(); |
725 Context* context = heap->isolate()->context()->global_context(); | 725 Context* context = heap->isolate()->context()->native_context(); |
726 | 726 |
727 if (heap_object->IsHeapNumber()) { | 727 if (heap_object->IsHeapNumber()) { |
728 return context->number_function()->instance_prototype(); | 728 return context->number_function()->instance_prototype(); |
729 } | 729 } |
730 if (heap_object->IsString()) { | 730 if (heap_object->IsString()) { |
731 return context->string_function()->instance_prototype(); | 731 return context->string_function()->instance_prototype(); |
732 } | 732 } |
733 if (heap_object->IsBoolean()) { | 733 if (heap_object->IsBoolean()) { |
734 return context->boolean_function()->instance_prototype(); | 734 return context->boolean_function()->instance_prototype(); |
735 } else { | 735 } else { |
(...skipping 2599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3335 } | 3335 } |
3336 | 3336 |
3337 Heap* current_heap = GetHeap(); | 3337 Heap* current_heap = GetHeap(); |
3338 | 3338 |
3339 // Copy the next enumeration index from instance descriptor. | 3339 // Copy the next enumeration index from instance descriptor. |
3340 int index = map_of_this->instance_descriptors()->NextEnumerationIndex(); | 3340 int index = map_of_this->instance_descriptors()->NextEnumerationIndex(); |
3341 dictionary->SetNextEnumerationIndex(index); | 3341 dictionary->SetNextEnumerationIndex(index); |
3342 | 3342 |
3343 Map* new_map; | 3343 Map* new_map; |
3344 MaybeObject* maybe_map = | 3344 MaybeObject* maybe_map = |
3345 current_heap->isolate()->context()->global_context()-> | 3345 current_heap->isolate()->context()->native_context()-> |
3346 normalized_map_cache()->Get(this, mode); | 3346 normalized_map_cache()->Get(this, mode); |
3347 if (!maybe_map->To(&new_map)) return maybe_map; | 3347 if (!maybe_map->To(&new_map)) return maybe_map; |
3348 ASSERT(new_map->is_dictionary_map()); | 3348 ASSERT(new_map->is_dictionary_map()); |
3349 | 3349 |
3350 // We have now successfully allocated all the necessary objects. | 3350 // We have now successfully allocated all the necessary objects. |
3351 // Changes can now be made with the guarantee that all of them take effect. | 3351 // Changes can now be made with the guarantee that all of them take effect. |
3352 | 3352 |
3353 // Resize the object in the heap if necessary. | 3353 // Resize the object in the heap if necessary. |
3354 int new_instance_size = new_map->instance_size(); | 3354 int new_instance_size = new_map->instance_size(); |
3355 int instance_size_delta = map_of_this->instance_size() - new_instance_size; | 3355 int instance_size_delta = map_of_this->instance_size() - new_instance_size; |
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4050 FAST_HOLEY_ELEMENTS; | 4050 FAST_HOLEY_ELEMENTS; |
4051 if (ReferencesObjectFromElements(arguments, kind, obj)) return true; | 4051 if (ReferencesObjectFromElements(arguments, kind, obj)) return true; |
4052 break; | 4052 break; |
4053 } | 4053 } |
4054 } | 4054 } |
4055 | 4055 |
4056 // For functions check the context. | 4056 // For functions check the context. |
4057 if (IsJSFunction()) { | 4057 if (IsJSFunction()) { |
4058 // Get the constructor function for arguments array. | 4058 // Get the constructor function for arguments array. |
4059 JSObject* arguments_boilerplate = | 4059 JSObject* arguments_boilerplate = |
4060 heap->isolate()->context()->global_context()-> | 4060 heap->isolate()->context()->native_context()-> |
4061 arguments_boilerplate(); | 4061 arguments_boilerplate(); |
4062 JSFunction* arguments_function = | 4062 JSFunction* arguments_function = |
4063 JSFunction::cast(arguments_boilerplate->map()->constructor()); | 4063 JSFunction::cast(arguments_boilerplate->map()->constructor()); |
4064 | 4064 |
4065 // Get the context and don't check if it is the global context. | 4065 // Get the context and don't check if it is the native context. |
4066 JSFunction* f = JSFunction::cast(this); | 4066 JSFunction* f = JSFunction::cast(this); |
4067 Context* context = f->context(); | 4067 Context* context = f->context(); |
4068 if (context->IsGlobalContext()) { | 4068 if (context->IsNativeContext()) { |
4069 return false; | 4069 return false; |
4070 } | 4070 } |
4071 | 4071 |
4072 // Check the non-special context slots. | 4072 // Check the non-special context slots. |
4073 for (int i = Context::MIN_CONTEXT_SLOTS; i < context->length(); i++) { | 4073 for (int i = Context::MIN_CONTEXT_SLOTS; i < context->length(); i++) { |
4074 // Only check JS objects. | 4074 // Only check JS objects. |
4075 if (context->get(i)->IsJSObject()) { | 4075 if (context->get(i)->IsJSObject()) { |
4076 JSObject* ctxobj = JSObject::cast(context->get(i)); | 4076 JSObject* ctxobj = JSObject::cast(context->get(i)); |
4077 // If it is an arguments array check the content. | 4077 // If it is an arguments array check the content. |
4078 if (ctxobj->map()->constructor() == arguments_function) { | 4078 if (ctxobj->map()->constructor() == arguments_function) { |
(...skipping 3290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7369 } | 7369 } |
7370 | 7370 |
7371 | 7371 |
7372 void SharedFunctionInfo::ClearOptimizedCodeMap() { | 7372 void SharedFunctionInfo::ClearOptimizedCodeMap() { |
7373 set_optimized_code_map(Smi::FromInt(0)); | 7373 set_optimized_code_map(Smi::FromInt(0)); |
7374 } | 7374 } |
7375 | 7375 |
7376 | 7376 |
7377 void SharedFunctionInfo::AddToOptimizedCodeMap( | 7377 void SharedFunctionInfo::AddToOptimizedCodeMap( |
7378 Handle<SharedFunctionInfo> shared, | 7378 Handle<SharedFunctionInfo> shared, |
7379 Handle<Context> global_context, | 7379 Handle<Context> native_context, |
7380 Handle<Code> code, | 7380 Handle<Code> code, |
7381 Handle<FixedArray> literals) { | 7381 Handle<FixedArray> literals) { |
7382 ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION); | 7382 ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION); |
7383 ASSERT(global_context->IsGlobalContext()); | 7383 ASSERT(native_context->IsNativeContext()); |
7384 STATIC_ASSERT(kEntryLength == 3); | 7384 STATIC_ASSERT(kEntryLength == 3); |
7385 Object* value = shared->optimized_code_map(); | 7385 Object* value = shared->optimized_code_map(); |
7386 Handle<FixedArray> new_code_map; | 7386 Handle<FixedArray> new_code_map; |
7387 if (value->IsSmi()) { | 7387 if (value->IsSmi()) { |
7388 // No optimized code map. | 7388 // No optimized code map. |
7389 ASSERT_EQ(0, Smi::cast(value)->value()); | 7389 ASSERT_EQ(0, Smi::cast(value)->value()); |
7390 // Crate 3 entries per context {context, code, literals}. | 7390 // Crate 3 entries per context {context, code, literals}. |
7391 new_code_map = FACTORY->NewFixedArray(kEntryLength); | 7391 new_code_map = FACTORY->NewFixedArray(kEntryLength); |
7392 new_code_map->set(0, *global_context); | 7392 new_code_map->set(0, *native_context); |
7393 new_code_map->set(1, *code); | 7393 new_code_map->set(1, *code); |
7394 new_code_map->set(2, *literals); | 7394 new_code_map->set(2, *literals); |
7395 } else { | 7395 } else { |
7396 // Copy old map and append one new entry. | 7396 // Copy old map and append one new entry. |
7397 Handle<FixedArray> old_code_map(FixedArray::cast(value)); | 7397 Handle<FixedArray> old_code_map(FixedArray::cast(value)); |
7398 ASSERT_EQ(-1, shared->SearchOptimizedCodeMap(*global_context)); | 7398 ASSERT_EQ(-1, shared->SearchOptimizedCodeMap(*native_context)); |
7399 int old_length = old_code_map->length(); | 7399 int old_length = old_code_map->length(); |
7400 int new_length = old_length + kEntryLength; | 7400 int new_length = old_length + kEntryLength; |
7401 new_code_map = FACTORY->NewFixedArray(new_length); | 7401 new_code_map = FACTORY->NewFixedArray(new_length); |
7402 old_code_map->CopyTo(0, *new_code_map, 0, old_length); | 7402 old_code_map->CopyTo(0, *new_code_map, 0, old_length); |
7403 new_code_map->set(old_length, *global_context); | 7403 new_code_map->set(old_length, *native_context); |
7404 new_code_map->set(old_length + 1, *code); | 7404 new_code_map->set(old_length + 1, *code); |
7405 new_code_map->set(old_length + 2, *literals); | 7405 new_code_map->set(old_length + 2, *literals); |
7406 } | 7406 } |
7407 #ifdef DEBUG | 7407 #ifdef DEBUG |
7408 for (int i = 0; i < new_code_map->length(); i += kEntryLength) { | 7408 for (int i = 0; i < new_code_map->length(); i += kEntryLength) { |
7409 ASSERT(new_code_map->get(i)->IsGlobalContext()); | 7409 ASSERT(new_code_map->get(i)->IsNativeContext()); |
7410 ASSERT(new_code_map->get(i + 1)->IsCode()); | 7410 ASSERT(new_code_map->get(i + 1)->IsCode()); |
7411 ASSERT(Code::cast(new_code_map->get(i + 1))->kind() == | 7411 ASSERT(Code::cast(new_code_map->get(i + 1))->kind() == |
7412 Code::OPTIMIZED_FUNCTION); | 7412 Code::OPTIMIZED_FUNCTION); |
7413 ASSERT(new_code_map->get(i + 2)->IsFixedArray()); | 7413 ASSERT(new_code_map->get(i + 2)->IsFixedArray()); |
7414 } | 7414 } |
7415 #endif | 7415 #endif |
7416 shared->set_optimized_code_map(*new_code_map); | 7416 shared->set_optimized_code_map(*new_code_map); |
7417 } | 7417 } |
7418 | 7418 |
7419 | 7419 |
7420 void SharedFunctionInfo::InstallFromOptimizedCodeMap(JSFunction* function, | 7420 void SharedFunctionInfo::InstallFromOptimizedCodeMap(JSFunction* function, |
7421 int index) { | 7421 int index) { |
7422 ASSERT(index > 0); | 7422 ASSERT(index > 0); |
7423 ASSERT(optimized_code_map()->IsFixedArray()); | 7423 ASSERT(optimized_code_map()->IsFixedArray()); |
7424 FixedArray* code_map = FixedArray::cast(optimized_code_map()); | 7424 FixedArray* code_map = FixedArray::cast(optimized_code_map()); |
7425 if (!bound()) { | 7425 if (!bound()) { |
7426 FixedArray* cached_literals = FixedArray::cast(code_map->get(index + 1)); | 7426 FixedArray* cached_literals = FixedArray::cast(code_map->get(index + 1)); |
7427 ASSERT(cached_literals != NULL); | 7427 ASSERT(cached_literals != NULL); |
7428 function->set_literals(cached_literals); | 7428 function->set_literals(cached_literals); |
7429 } | 7429 } |
7430 Code* code = Code::cast(code_map->get(index)); | 7430 Code* code = Code::cast(code_map->get(index)); |
7431 ASSERT(code != NULL); | 7431 ASSERT(code != NULL); |
7432 ASSERT(function->context()->global_context() == code_map->get(index - 1)); | 7432 ASSERT(function->context()->native_context() == code_map->get(index - 1)); |
7433 function->ReplaceCode(code); | 7433 function->ReplaceCode(code); |
7434 } | 7434 } |
7435 | 7435 |
7436 | 7436 |
7437 bool JSFunction::CompileLazy(Handle<JSFunction> function, | 7437 bool JSFunction::CompileLazy(Handle<JSFunction> function, |
7438 ClearExceptionFlag flag) { | 7438 ClearExceptionFlag flag) { |
7439 bool result = true; | 7439 bool result = true; |
7440 if (function->shared()->is_compiled()) { | 7440 if (function->shared()->is_compiled()) { |
7441 function->ReplaceCode(function->shared()->code()); | 7441 function->ReplaceCode(function->shared()->code()); |
7442 function->shared()->set_code_age(0); | 7442 function->shared()->set_code_age(0); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7540 // different prototype. | 7540 // different prototype. |
7541 Map* new_map; | 7541 Map* new_map; |
7542 MaybeObject* maybe_new_map = map()->Copy(); | 7542 MaybeObject* maybe_new_map = map()->Copy(); |
7543 if (!maybe_new_map->To(&new_map)) return maybe_new_map; | 7543 if (!maybe_new_map->To(&new_map)) return maybe_new_map; |
7544 | 7544 |
7545 Heap* heap = new_map->GetHeap(); | 7545 Heap* heap = new_map->GetHeap(); |
7546 set_map(new_map); | 7546 set_map(new_map); |
7547 new_map->set_constructor(value); | 7547 new_map->set_constructor(value); |
7548 new_map->set_non_instance_prototype(true); | 7548 new_map->set_non_instance_prototype(true); |
7549 construct_prototype = | 7549 construct_prototype = |
7550 heap->isolate()->context()->global_context()-> | 7550 heap->isolate()->context()->native_context()-> |
7551 initial_object_prototype(); | 7551 initial_object_prototype(); |
7552 } else { | 7552 } else { |
7553 map()->set_non_instance_prototype(false); | 7553 map()->set_non_instance_prototype(false); |
7554 } | 7554 } |
7555 | 7555 |
7556 return SetInstancePrototype(construct_prototype); | 7556 return SetInstancePrototype(construct_prototype); |
7557 } | 7557 } |
7558 | 7558 |
7559 | 7559 |
7560 Object* JSFunction::RemovePrototype() { | 7560 Object* JSFunction::RemovePrototype() { |
7561 Context* global_context = context()->global_context(); | 7561 Context* native_context = context()->native_context(); |
7562 Map* no_prototype_map = shared()->is_classic_mode() | 7562 Map* no_prototype_map = shared()->is_classic_mode() |
7563 ? global_context->function_without_prototype_map() | 7563 ? native_context->function_without_prototype_map() |
7564 : global_context->strict_mode_function_without_prototype_map(); | 7564 : native_context->strict_mode_function_without_prototype_map(); |
7565 | 7565 |
7566 if (map() == no_prototype_map) { | 7566 if (map() == no_prototype_map) { |
7567 // Be idempotent. | 7567 // Be idempotent. |
7568 return this; | 7568 return this; |
7569 } | 7569 } |
7570 | 7570 |
7571 ASSERT(map() == (shared()->is_classic_mode() | 7571 ASSERT(map() == (shared()->is_classic_mode() |
7572 ? global_context->function_map() | 7572 ? native_context->function_map() |
7573 : global_context->strict_mode_function_map())); | 7573 : native_context->strict_mode_function_map())); |
7574 | 7574 |
7575 set_map(no_prototype_map); | 7575 set_map(no_prototype_map); |
7576 set_prototype_or_initial_map(no_prototype_map->GetHeap()->the_hole_value()); | 7576 set_prototype_or_initial_map(no_prototype_map->GetHeap()->the_hole_value()); |
7577 return this; | 7577 return this; |
7578 } | 7578 } |
7579 | 7579 |
7580 | 7580 |
7581 Object* JSFunction::SetInstanceClassName(String* name) { | 7581 Object* JSFunction::SetInstanceClassName(String* name) { |
7582 shared()->set_instance_class_name(name); | 7582 shared()->set_instance_class_name(name); |
7583 return this; | 7583 return this; |
7584 } | 7584 } |
7585 | 7585 |
7586 | 7586 |
7587 void JSFunction::PrintName(FILE* out) { | 7587 void JSFunction::PrintName(FILE* out) { |
7588 SmartArrayPointer<char> name = shared()->DebugName()->ToCString(); | 7588 SmartArrayPointer<char> name = shared()->DebugName()->ToCString(); |
7589 PrintF(out, "%s", *name); | 7589 PrintF(out, "%s", *name); |
7590 } | 7590 } |
7591 | 7591 |
7592 | 7592 |
7593 Context* JSFunction::GlobalContextFromLiterals(FixedArray* literals) { | 7593 Context* JSFunction::NativeContextFromLiterals(FixedArray* literals) { |
7594 return Context::cast(literals->get(JSFunction::kLiteralGlobalContextIndex)); | 7594 return Context::cast(literals->get(JSFunction::kLiteralNativeContextIndex)); |
7595 } | 7595 } |
7596 | 7596 |
7597 | 7597 |
7598 MaybeObject* Oddball::Initialize(const char* to_string, | 7598 MaybeObject* Oddball::Initialize(const char* to_string, |
7599 Object* to_number, | 7599 Object* to_number, |
7600 byte kind) { | 7600 byte kind) { |
7601 String* symbol; | 7601 String* symbol; |
7602 { MaybeObject* maybe_symbol = | 7602 { MaybeObject* maybe_symbol = |
7603 Isolate::Current()->heap()->LookupAsciiSymbol(to_string); | 7603 Isolate::Current()->heap()->LookupAsciiSymbol(to_string); |
7604 if (!maybe_symbol->To(&symbol)) return maybe_symbol; | 7604 if (!maybe_symbol->To(&symbol)) return maybe_symbol; |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7982 // Resize the initial map and all maps in its transition tree. | 7982 // Resize the initial map and all maps in its transition tree. |
7983 map->TraverseTransitionTree(&ShrinkInstanceSize, &slack); | 7983 map->TraverseTransitionTree(&ShrinkInstanceSize, &slack); |
7984 | 7984 |
7985 // Give the correct expected_nof_properties to initial maps created later. | 7985 // Give the correct expected_nof_properties to initial maps created later. |
7986 ASSERT(expected_nof_properties() >= slack); | 7986 ASSERT(expected_nof_properties() >= slack); |
7987 set_expected_nof_properties(expected_nof_properties() - slack); | 7987 set_expected_nof_properties(expected_nof_properties() - slack); |
7988 } | 7988 } |
7989 } | 7989 } |
7990 | 7990 |
7991 | 7991 |
7992 int SharedFunctionInfo::SearchOptimizedCodeMap(Context* global_context) { | 7992 int SharedFunctionInfo::SearchOptimizedCodeMap(Context* native_context) { |
7993 ASSERT(global_context->IsGlobalContext()); | 7993 ASSERT(native_context->IsNativeContext()); |
7994 if (!FLAG_cache_optimized_code) return -1; | 7994 if (!FLAG_cache_optimized_code) return -1; |
7995 Object* value = optimized_code_map(); | 7995 Object* value = optimized_code_map(); |
7996 if (!value->IsSmi()) { | 7996 if (!value->IsSmi()) { |
7997 FixedArray* optimized_code_map = FixedArray::cast(value); | 7997 FixedArray* optimized_code_map = FixedArray::cast(value); |
7998 int length = optimized_code_map->length(); | 7998 int length = optimized_code_map->length(); |
7999 for (int i = 0; i < length; i += 3) { | 7999 for (int i = 0; i < length; i += 3) { |
8000 if (optimized_code_map->get(i) == global_context) { | 8000 if (optimized_code_map->get(i) == native_context) { |
8001 return i + 1; | 8001 return i + 1; |
8002 } | 8002 } |
8003 } | 8003 } |
8004 } | 8004 } |
8005 return -1; | 8005 return -1; |
8006 } | 8006 } |
8007 | 8007 |
8008 | 8008 |
8009 #define DECLARE_TAG(ignore1, name, ignore2) name, | 8009 #define DECLARE_TAG(ignore1, name, ignore2) name, |
8010 const char* const VisitorSynchronization::kTags[ | 8010 const char* const VisitorSynchronization::kTags[ |
(...skipping 5144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13155 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13155 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
13156 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13156 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
13157 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13157 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
13158 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13158 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
13159 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13159 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
13160 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13160 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
13161 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13161 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
13162 } | 13162 } |
13163 | 13163 |
13164 } } // namespace v8::internal | 13164 } } // namespace v8::internal |
OLD | NEW |