Chromium Code Reviews| 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 201 void CodeStub::PrintName(StringStream* stream) { | 201 void CodeStub::PrintName(StringStream* stream) { |
| 202 PrintBaseName(stream); | 202 PrintBaseName(stream); |
| 203 PrintState(stream); | 203 PrintState(stream); |
| 204 } | 204 } |
| 205 | 205 |
| 206 | 206 |
| 207 Builtins::JavaScript UnaryOpStub::ToJSBuiltin() { | 207 Builtins::JavaScript UnaryOpStub::ToJSBuiltin() { |
| 208 switch (operation_) { | 208 switch (operation_) { |
| 209 default: | 209 default: |
| 210 UNREACHABLE(); | 210 UNREACHABLE(); |
| 211 case Token::SUB: | |
| 212 return Builtins::UNARY_MINUS; | |
|
Sven Panne
2013/08/05 06:22:43
I think that the whole builtin can be nuked, I'll
| |
| 213 case Token::BIT_NOT: | 211 case Token::BIT_NOT: |
| 214 return Builtins::BIT_NOT; | 212 return Builtins::BIT_NOT; |
| 215 } | 213 } |
| 216 } | 214 } |
| 217 | 215 |
| 218 | 216 |
| 219 Handle<JSFunction> UnaryOpStub::ToJSFunction(Isolate* isolate) { | 217 Handle<JSFunction> UnaryOpStub::ToJSFunction(Isolate* isolate) { |
| 220 Handle<JSBuiltinsObject> builtins(isolate->js_builtins_object()); | 218 Handle<JSBuiltinsObject> builtins(isolate->js_builtins_object()); |
| 221 Object* builtin = builtins->javascript_builtin(ToJSBuiltin()); | 219 Object* builtin = builtins->javascript_builtin(ToJSBuiltin()); |
| 222 return Handle<JSFunction>(JSFunction::cast(builtin), isolate); | 220 return Handle<JSFunction>(JSFunction::cast(builtin), isolate); |
| 223 } | 221 } |
| 224 | 222 |
| 225 | 223 |
| 226 MaybeObject* UnaryOpStub::Result(Handle<Object> object, Isolate* isolate) { | 224 MaybeObject* UnaryOpStub::Result(Handle<Object> object, Isolate* isolate) { |
| 227 Handle<JSFunction> builtin_function = ToJSFunction(isolate); | 225 Handle<JSFunction> builtin_function = ToJSFunction(isolate); |
| 228 bool caught_exception; | 226 bool caught_exception; |
| 229 Handle<Object> result = Execution::Call(builtin_function, object, | 227 Handle<Object> result = Execution::Call(builtin_function, object, |
| 230 0, NULL, &caught_exception); | 228 0, NULL, &caught_exception); |
| 231 if (caught_exception) { | 229 if (caught_exception) { |
| 232 return Failure::Exception(); | 230 return Failure::Exception(); |
| 233 } | 231 } |
| 234 return *result; | 232 return *result; |
| 235 } | 233 } |
| 236 | 234 |
| 237 | 235 |
| 238 void UnaryOpStub::UpdateStatus(Handle<Object> object) { | 236 void UnaryOpStub::UpdateStatus(Handle<Object> object) { |
| 239 State old_state(state_); | 237 State old_state(state_); |
| 240 if (object->IsSmi()) { | 238 if (object->IsSmi()) { |
| 241 state_.Add(SMI); | 239 state_.Add(SMI); |
| 242 if (operation_ == Token::SUB && *object == 0) { | |
| 243 // The result (-0) has to be represented as double. | |
| 244 state_.Add(HEAP_NUMBER); | |
| 245 } | |
| 246 } else if (object->IsHeapNumber()) { | 240 } else if (object->IsHeapNumber()) { |
| 247 state_.Add(HEAP_NUMBER); | 241 state_.Add(HEAP_NUMBER); |
| 248 } else { | 242 } else { |
| 249 state_.Add(GENERIC); | 243 state_.Add(GENERIC); |
| 250 } | 244 } |
| 251 TraceTransition(old_state, state_); | 245 TraceTransition(old_state, state_); |
| 252 } | 246 } |
| 253 | 247 |
| 254 | 248 |
| 255 Handle<Type> UnaryOpStub::GetType(Isolate* isolate) { | 249 Handle<Type> UnaryOpStub::GetType(Isolate* isolate) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 349 UNREACHABLE(); | 343 UNREACHABLE(); |
| 350 } | 344 } |
| 351 } | 345 } |
| 352 | 346 |
| 353 | 347 |
| 354 #undef __ | 348 #undef __ |
| 355 | 349 |
| 356 | 350 |
| 357 void UnaryOpStub::PrintBaseName(StringStream* stream) { | 351 void UnaryOpStub::PrintBaseName(StringStream* stream) { |
| 358 CodeStub::PrintBaseName(stream); | 352 CodeStub::PrintBaseName(stream); |
| 359 if (operation_ == Token::SUB) stream->Add("Minus"); | |
| 360 if (operation_ == Token::BIT_NOT) stream->Add("Not"); | 353 if (operation_ == Token::BIT_NOT) stream->Add("Not"); |
| 361 } | 354 } |
| 362 | 355 |
| 363 | 356 |
| 364 void UnaryOpStub::PrintState(StringStream* stream) { | 357 void UnaryOpStub::PrintState(StringStream* stream) { |
| 365 state_.Print(stream); | 358 state_.Print(stream); |
| 366 } | 359 } |
| 367 | 360 |
| 368 | 361 |
| 369 void UnaryOpStub::State::Print(StringStream* stream) const { | 362 void UnaryOpStub::State::Print(StringStream* stream) const { |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 884 InstallDescriptor(isolate, &stub3); | 877 InstallDescriptor(isolate, &stub3); |
| 885 } | 878 } |
| 886 | 879 |
| 887 InternalArrayConstructorStub::InternalArrayConstructorStub( | 880 InternalArrayConstructorStub::InternalArrayConstructorStub( |
| 888 Isolate* isolate) { | 881 Isolate* isolate) { |
| 889 InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); | 882 InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); |
| 890 } | 883 } |
| 891 | 884 |
| 892 | 885 |
| 893 } } // namespace v8::internal | 886 } } // namespace v8::internal |
| OLD | NEW |